Class: Duraflame::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/duraflame/client.rb

Overview

Wraps HTTPClient with knowledge of hostname and authentication

Instance Method Summary collapse

Constructor Details

#initialize(company, token) ⇒ Client

Returns a new instance of Client.



7
8
9
10
11
# File 'lib/duraflame/client.rb', line 7

def initialize(company, token)
  @http_client = HTTPClient.new
  @http_client.set_auth(nil, token, nil)
  @uri = URI.parse("https://#{company}.campfirenow.com")
end

Instance Method Details

#get(path) ⇒ Object



13
14
15
16
17
18
# File 'lib/duraflame/client.rb', line 13

def get(path)
  uri = @uri.dup
  uri.path = path
  body = @http_client.get_content(uri)
  Yajl::Parser.parse(body)
end