Class: Ari::DeviceState
- Defined in:
- lib/ari/resources/device_state.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Class Method Summary collapse
-
.delete(options = {}) ⇒ Object
DELETE /deviceStates/%deviceName.
-
.get(options = {}) ⇒ Object
GET /deviceStates/%deviceName.
-
.list(options = {}) ⇒ Object
GET /deviceStates.
-
.update(options = {}) ⇒ Object
PUT /deviceStates/%deviceName.
Instance Method Summary collapse
Methods inherited from Resource
#add_listener, client, #client, #remove_all_listeners!, #remove_listener
Methods inherited from Model
Constructor Details
This class inherits a constructor from Ari::Model
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
15 16 17 |
# File 'lib/ari/resources/device_state.rb', line 15 def name @name end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
15 16 17 |
# File 'lib/ari/resources/device_state.rb', line 15 def state @state end |
Class Method Details
.delete(options = {}) ⇒ Object
DELETE /deviceStates/%deviceName
Device state
Parameters:
deviceName (required) - Name of the device
80 81 82 83 84 85 86 |
# File 'lib/ari/resources/device_state.rb', line 80 def self.delete( = {}) raise ArgumentError.new("Parameter deviceName must be passed in options hash.") unless [:deviceName] path = '/deviceStates/%{deviceName}' % response = client().delete(path, ) rescue Ari::RequestError => e raise unless e.code == '404' end |
.get(options = {}) ⇒ Object
GET /deviceStates/%deviceName
Device state
Parameters:
deviceName (required) - Name of the device
38 39 40 41 42 43 |
# File 'lib/ari/resources/device_state.rb', line 38 def self.get( = {}) raise ArgumentError.new("Parameter deviceName must be passed in options hash.") unless [:deviceName] path = '/deviceStates/%{deviceName}' % response = client().get(path, ) DeviceState.new(response.merge(client: [:client])) end |
.list(options = {}) ⇒ Object
GET /deviceStates
Device states
23 24 25 26 27 |
# File 'lib/ari/resources/device_state.rb', line 23 def self.list( = {}) path = '/deviceStates' response = client().get(path, ) response.map { |hash| DeviceState.new(hash.merge(client: [:client])) } end |
.update(options = {}) ⇒ Object
PUT /deviceStates/%deviceName
Device state
Change the state of a device controlled by ARI. (Note - implicitly creates the d
Parameters:
deviceName (required) - Name of the device deviceState (required) - Device state value
60 61 62 63 64 65 |
# File 'lib/ari/resources/device_state.rb', line 60 def self.update( = {}) raise ArgumentError.new("Parameter deviceName must be passed in options hash.") unless [:deviceName] raise ArgumentError.new("Parameter deviceState must be passed in options hash.") unless [:deviceState] path = '/deviceStates/%{deviceName}' % response = client().put(path, ) end |
Instance Method Details
#delete(options = {}) ⇒ Object
88 89 90 |
# File 'lib/ari/resources/device_state.rb', line 88 def delete( = {}) self.class.delete(.merge(deviceStateId: self.id, client: @client)) end |
#get(options = {}) ⇒ Object
45 46 47 |
# File 'lib/ari/resources/device_state.rb', line 45 def get( = {}) self.class.get(.merge(deviceStateId: self.id, client: @client)) end |
#update(options = {}) ⇒ Object
67 68 69 |
# File 'lib/ari/resources/device_state.rb', line 67 def update( = {}) self.class.update(.merge(deviceStateId: self.id, client: @client)) end |