Class: Tendril::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/tendril/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



8
9
10
11
12
13
14
15
16
17
# File 'lib/tendril/client.rb', line 8

def initialize(options={})
  @subdomain = options[:subdomain] || Tendril.subdomain
  @email = options[:email] || Tendril.email
  @password = options[:password] || Tendril.password
  @account_id = options[:account_id] || Tendril.            
  
  self.class.base_uri "https://#{@subdomain}.tendrildemo.com/api/rest"
  self.class.headers 'Accept' => 'application/json', 
                     'Emsauthtoken' => "#{@email}:#{@password}"
end

Instance Attribute Details

#account_idObject (readonly)

Returns the value of attribute account_id.



6
7
8
# File 'lib/tendril/client.rb', line 6

def 
  @account_id
end

#emailObject (readonly)

Returns the value of attribute email.



6
7
8
# File 'lib/tendril/client.rb', line 6

def email
  @email
end

#passwordObject (readonly)

Returns the value of attribute password.



6
7
8
# File 'lib/tendril/client.rb', line 6

def password
  @password
end

#subdomainObject (readonly)

Returns the value of attribute subdomain.



6
7
8
# File 'lib/tendril/client.rb', line 6

def subdomain
  @subdomain
end

Instance Method Details

#meter(secondary, options = {}) ⇒ Object



23
24
25
# File 'lib/tendril/client.rb', line 23

def meter(secondary, options={})              
  mashup(self.class.get("/meter/#{secondary}#{hash_to_querystring(options)}"))
end

#pricing(secondary, options = {}) ⇒ Object



19
20
21
# File 'lib/tendril/client.rb', line 19

def pricing(secondary, options={})
  mashup(self.class.get("/pricing/#{secondary}#{hash_to_querystring(options)}"))
end