class Librato::Client

Constants

HOST

Private Instance Methods

client() click to toggle source
# File lib/librato/client.rb, line 23
def client
  Faraday.new(HOST) do |c|
    c.basic_auth(user, token)
    c.use Faraday::Adapter::NetHttp
  end
end
request(method, path, data = nil) click to toggle source
# File lib/librato/client.rb, line 14
def request(method, path, data = nil)
  # puts "#{method.to_s.upcase} #{path}"
  args = [method, path]
  args << JSON.dump(data) if data
  response = client.send(*args) { |r| r.headers['Content-Type'] = 'application/json' }
  fail "#{response.status} #{response.body}" if response.status >= 299
  response
end