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:, devices:, attributes:, frequency: SKIP, duration: SKIP, additional_properties: nil) ⇒ ObservationRequest
constructor
A new instance of ObservationRequest.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(account_name:, devices:, attributes:, frequency: SKIP, duration: SKIP, additional_properties: nil) ⇒ ObservationRequest
Returns a new instance of ObservationRequest.
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/verizon/models/observation_request.rb', line 58 def initialize(account_name:, devices:, attributes:, frequency: SKIP, duration: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @account_name = account_name @devices = devices @attributes = attributes @frequency = frequency unless frequency == SKIP @duration = duration unless duration == SKIP @additional_properties = additional_properties 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.
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 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/verizon/models/observation_request.rb', line 72 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 a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. ObservationRequest.new(account_name: account_name, devices: devices, attributes: attributes, frequency: frequency, duration: duration, additional_properties: additional_properties) 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 |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
125 126 127 128 129 130 |
# File 'lib/verizon/models/observation_request.rb', line 125 def inspect class_name = self.class.name.split('::').last "<#{class_name} account_name: #{@account_name.inspect}, devices: #{@devices.inspect},"\ " attributes: #{@attributes.inspect}, frequency: #{@frequency.inspect}, duration:"\ " #{@duration.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
117 118 119 120 121 122 |
# File 'lib/verizon/models/observation_request.rb', line 117 def to_s class_name = self.class.name.split('::').last "<#{class_name} account_name: #{@account_name}, devices: #{@devices}, attributes:"\ " #{@attributes}, frequency: #{@frequency}, duration: #{@duration}, additional_properties:"\ " #{@additional_properties}>" end |