Class: Verizon::ObservationRequest
- Defined in:
- lib/verizon/models/observation_request.rb
Overview
Used to define callbacks including the device identity, the attribute names, corresponding attribute values and the date/timestamp of when the observation was made.
Instance Attribute Summary collapse
-
#account_name ⇒ String
Account identifier in “##########-#####”.
-
#attributes ⇒ Array[ObservationRequestAttribute]
Attributes are streaming RF parameters that you want to observe.
-
#devices ⇒ Array[Device]
List of devices.
-
#duration ⇒ NumericalData
Describes value and unit of time.
-
#frequency ⇒ NumericalData
Describes value and unit of time.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(account_name = nil, devices = nil, attributes = nil, frequency = SKIP, duration = SKIP) ⇒ ObservationRequest
constructor
A new instance of ObservationRequest.
Methods inherited from BaseModel
Constructor Details
#initialize(account_name = nil, devices = nil, attributes = nil, frequency = SKIP, duration = SKIP) ⇒ ObservationRequest
Returns a new instance of ObservationRequest.
58 59 60 61 62 63 64 65 |
# File 'lib/verizon/models/observation_request.rb', line 58 def initialize(account_name = nil, devices = nil, attributes = nil, frequency = SKIP, duration = SKIP) @account_name = account_name @devices = devices @attributes = attributes @frequency = frequency unless frequency == SKIP @duration = duration unless duration == SKIP end |
Instance Attribute Details
#account_name ⇒ String
Account identifier in “##########-#####”.
16 17 18 |
# File 'lib/verizon/models/observation_request.rb', line 16 def account_name @account_name end |
#attributes ⇒ Array[ObservationRequestAttribute]
Attributes are streaming RF parameters that you want to observe.
24 25 26 |
# File 'lib/verizon/models/observation_request.rb', line 24 def attributes @attributes end |
#devices ⇒ Array[Device]
List of devices.
20 21 22 |
# File 'lib/verizon/models/observation_request.rb', line 20 def devices @devices end |
#duration ⇒ NumericalData
Describes value and unit of time.
32 33 34 |
# File 'lib/verizon/models/observation_request.rb', line 32 def duration @duration end |
#frequency ⇒ NumericalData
Describes value and unit of time.
28 29 30 |
# File 'lib/verizon/models/observation_request.rb', line 28 def frequency @frequency end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/verizon/models/observation_request.rb', line 68 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. account_name = hash.key?('accountName') ? hash['accountName'] : nil # Parameter is an array, so we need to iterate through it devices = nil unless hash['devices'].nil? devices = [] hash['devices'].each do |structure| devices << (Device.from_hash(structure) if structure) end end devices = nil unless hash.key?('devices') # Parameter is an array, so we need to iterate through it attributes = nil unless hash['attributes'].nil? attributes = [] hash['attributes'].each do |structure| attributes << (ObservationRequestAttribute.from_hash(structure) if structure) end end attributes = nil unless hash.key?('attributes') frequency = NumericalData.from_hash(hash['frequency']) if hash['frequency'] duration = NumericalData.from_hash(hash['duration']) if hash['duration'] # Create object from extracted values. ObservationRequest.new(account_name, devices, attributes, frequency, duration) end |
.names ⇒ Object
A mapping from model property names to API property names.
35 36 37 38 39 40 41 42 43 |
# File 'lib/verizon/models/observation_request.rb', line 35 def self.names @_hash = {} if @_hash.nil? @_hash['account_name'] = 'accountName' @_hash['devices'] = 'devices' @_hash['attributes'] = 'attributes' @_hash['frequency'] = 'frequency' @_hash['duration'] = 'duration' @_hash end |
.nullables ⇒ Object
An array for nullable fields
54 55 56 |
# File 'lib/verizon/models/observation_request.rb', line 54 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
46 47 48 49 50 51 |
# File 'lib/verizon/models/observation_request.rb', line 46 def self.optionals %w[ frequency duration ] end |