Class: Ari::DeviceState

Inherits:
Resource show all
Defined in:
lib/ari/resources/device_state.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#add_listener, #client, client, #remove_all_listeners!, #remove_listener

Methods inherited from Model

#attributes=, #initialize

Constructor Details

This class inherits a constructor from Ari::Model

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name


15
16
17
# File 'lib/ari/resources/device_state.rb', line 15

def name
  @name
end

#stateObject (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(options = {})
  raise ArgumentError.new("Parameter deviceName must be passed in options hash.") unless options[:deviceName]
  path = '/deviceStates/%{deviceName}' % options
  response = client(options).delete(path, options)
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

Raises:

  • (ArgumentError)

38
39
40
41
42
43
# File 'lib/ari/resources/device_state.rb', line 38

def self.get(options = {})
  raise ArgumentError.new("Parameter deviceName must be passed in options hash.") unless options[:deviceName]
  path = '/deviceStates/%{deviceName}' % options
  response = client(options).get(path, options)
  DeviceState.new(response.merge(client: options[: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(options = {})
  path = '/deviceStates'
  response = client(options).get(path, options)
  response.map { |hash| DeviceState.new(hash.merge(client: options[: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

Raises:

  • (ArgumentError)

60
61
62
63
64
65
# File 'lib/ari/resources/device_state.rb', line 60

def self.update(options = {})
  raise ArgumentError.new("Parameter deviceName must be passed in options hash.") unless options[:deviceName]
  raise ArgumentError.new("Parameter deviceState must be passed in options hash.") unless options[:deviceState]
  path = '/deviceStates/%{deviceName}' % options
  response = client(options).put(path, options)
end

Instance Method Details

#delete(options = {}) ⇒ Object


88
89
90
# File 'lib/ari/resources/device_state.rb', line 88

def delete(options = {})
  self.class.delete(options.merge(deviceStateId: self.id, client: @client))
end

#get(options = {}) ⇒ Object


45
46
47
# File 'lib/ari/resources/device_state.rb', line 45

def get(options = {})
  self.class.get(options.merge(deviceStateId: self.id, client: @client))
end

#update(options = {}) ⇒ Object


67
68
69
# File 'lib/ari/resources/device_state.rb', line 67

def update(options = {})
  self.class.update(options.merge(deviceStateId: self.id, client: @client))
end