Class: Seam::Clients::ThermostatsDailyPrograms

Inherits:
Object
  • Object
show all
Defined in:
lib/seam/routes/clients/thermostats_daily_programs.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:, defaults:) ⇒ ThermostatsDailyPrograms

Returns a new instance of ThermostatsDailyPrograms.



8
9
10
11
# File 'lib/seam/routes/clients/thermostats_daily_programs.rb', line 8

def initialize(client:, defaults:)
  @client = client
  @defaults = defaults
end

Instance Method Details

#create(device_id:, name:, periods:) ⇒ Object



13
14
15
16
17
# File 'lib/seam/routes/clients/thermostats_daily_programs.rb', line 13

def create(device_id:, name:, periods:)
  res = @client.post("/thermostats/daily_programs/create", {device_id: device_id, name: name, periods: periods}.compact)

  Seam::Resources::ThermostatDailyProgram.load_from_response(res.body["thermostat_daily_program"])
end

#delete(thermostat_daily_program_id:) ⇒ Object



19
20
21
22
23
# File 'lib/seam/routes/clients/thermostats_daily_programs.rb', line 19

def delete(thermostat_daily_program_id:)
  @client.post("/thermostats/daily_programs/delete", {thermostat_daily_program_id: thermostat_daily_program_id}.compact)

  nil
end

#update(name:, periods:, thermostat_daily_program_id:, wait_for_action_attempt: nil) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/seam/routes/clients/thermostats_daily_programs.rb', line 25

def update(name:, periods:, thermostat_daily_program_id:, wait_for_action_attempt: nil)
  res = @client.post("/thermostats/daily_programs/update", {name: name, periods: periods, thermostat_daily_program_id: thermostat_daily_program_id}.compact)

  wait_for_action_attempt = wait_for_action_attempt.nil? ? @defaults.wait_for_action_attempt : wait_for_action_attempt

  Helpers::ActionAttempt.decide_and_wait(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
end