Class: NestApi::Api
- Inherits:
-
Object
- Object
- NestApi::Api
- Defined in:
- lib/nest_api/api.rb
Instance Method Summary collapse
-
#get_thermostat_by_name(name) ⇒ Object
Retrieve a single thermostat by name.
-
#get_thermostat_list ⇒ Object
Retrieve a list of all thermostats registered to this account.
-
#initialize(product_id: ENV.fetch("NEST_PRODUCT_ID"), product_secret: ENV.fetch("NEST_PRODUCT_SECRET"), file: NestApi::CONFIG_FILE) ⇒ Api
constructor
A new instance of Api.
Constructor Details
#initialize(product_id: ENV.fetch("NEST_PRODUCT_ID"), product_secret: ENV.fetch("NEST_PRODUCT_SECRET"), file: NestApi::CONFIG_FILE) ⇒ Api
Returns a new instance of Api.
3 4 5 |
# File 'lib/nest_api/api.rb', line 3 def initialize(product_id: ENV.fetch("NEST_PRODUCT_ID"), product_secret: ENV.fetch("NEST_PRODUCT_SECRET"), file: NestApi::CONFIG_FILE) @token = NestApi::AccessToken.new(product_id, product_secret, file) end |
Instance Method Details
#get_thermostat_by_name(name) ⇒ Object
Retrieve a single thermostat by name
13 14 15 |
# File 'lib/nest_api/api.rb', line 13 def get_thermostat_by_name(name) get_thermostat_list[name] end |
#get_thermostat_list ⇒ Object
Retrieve a list of all thermostats registered to this account
8 9 10 |
# File 'lib/nest_api/api.rb', line 8 def get_thermostat_list create_thermostats(HTTParty.get("#{NestApi::API_URL}/devices/thermostats", query: { auth: @token.access_token })) end |