Class: MyTankInfo::AlarmHistoryResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/my_tank_info/resources/alarm_history.rb

Instance Attribute Summary

Attributes inherited from Resource

#client

Instance Method Summary collapse

Methods inherited from Resource

#delete_request, #get_request, #initialize, #patch_request, #post_request, #put_request

Constructor Details

This class inherits a constructor from MyTankInfo::Resource

Instance Method Details

#list(site_id: nil, **params) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/my_tank_info/resources/alarm_history.rb', line 5

def list(site_id: nil, **params)
  response =
    if site_id.nil?
      get_request("api/alarmhistory", params: params)
    else
      get_request("api/sites/#{site_id}/alarmhistory", params: params)
    end

  Collection.from_response(response, type: Alarm)
end

#list_notes(alarm_id:) ⇒ Object



16
17
18
19
# File 'lib/my_tank_info/resources/alarm_history.rb', line 16

def list_notes(alarm_id:)
  response = get_request("api/alarmhistory/#{alarm_id}/notes")
  Collection.from_response(response, type: AlarmNote)
end

#retrieve(alarm_id:) ⇒ Object



21
22
23
# File 'lib/my_tank_info/resources/alarm_history.rb', line 21

def retrieve(alarm_id:)
  Alarm.new get_request("api/alarmhistory/#{alarm_id}").body
end