Class: Heater::API

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/heater.rb

Constant Summary collapse

API_ENDPOINT =
'http://heater.flatlab.info'.freeze
VERSION =
1.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#api_endpointObject

Returns the value of attribute api_endpoint.



22
23
24
# File 'lib/heater.rb', line 22

def api_endpoint
  @api_endpoint
end

#api_keyObject

Returns the value of attribute api_key.



21
22
23
# File 'lib/heater.rb', line 21

def api_key
  @api_key
end

Instance Method Details

#get_api_key(url = 'http://localhost:3000') ⇒ Object



29
30
31
32
33
# File 'lib/heater.rb', line 29

def get_api_key(url = 'http://localhost:3000')
  result = JSON.parse(RestClient.post("#{self.api_endpoint}/api_keys", :api_key => {:url => url}).body)
  @api_key = result['api_key']
  result
end