Class: NestApi::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/nest_api/api.rb

Instance Method Summary collapse

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_listObject

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