Class: Verizon::AggregateSessionReport
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- Verizon::AggregateSessionReport
- Defined in:
- lib/verizon/models/aggregate_session_report.rb
Overview
Session and usage details for up to 10 devices.
Instance Attribute Summary collapse
-
#errors ⇒ Array[AggregateUsageError]
An object containing any errors reported by the device.
-
#txid ⇒ String
A unique string that associates the request with the location report information that is sent in asynchronous callback message.ThingSpace will send a separate callback message for each device that was in the request.
-
#usage ⇒ Array[AggregateUsageItem]
Contains usage per device.
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(txid:, usage: SKIP, errors: SKIP, additional_properties: nil) ⇒ AggregateSessionReport
constructor
A new instance of AggregateSessionReport.
-
#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(txid:, usage: SKIP, errors: SKIP, additional_properties: nil) ⇒ AggregateSessionReport
Returns a new instance of AggregateSessionReport.
51 52 53 54 55 56 57 58 59 |
# File 'lib/verizon/models/aggregate_session_report.rb', line 51 def initialize(txid:, usage: SKIP, errors: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @txid = txid @usage = usage unless usage == SKIP @errors = errors unless errors == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#errors ⇒ Array[AggregateUsageError]
An object containing any errors reported by the device.
25 26 27 |
# File 'lib/verizon/models/aggregate_session_report.rb', line 25 def errors @errors end |
#txid ⇒ String
A unique string that associates the request with the location report information that is sent in asynchronous callback message.ThingSpace will send a separate callback message for each device that was in the request. All of the callback messages will have the same txid.
17 18 19 |
# File 'lib/verizon/models/aggregate_session_report.rb', line 17 def txid @txid end |
#usage ⇒ Array[AggregateUsageItem]
Contains usage per device.
21 22 23 |
# File 'lib/verizon/models/aggregate_session_report.rb', line 21 def usage @usage end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
62 63 64 65 66 67 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 |
# File 'lib/verizon/models/aggregate_session_report.rb', line 62 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. txid = hash.key?('txid') ? hash['txid'] : nil # Parameter is an array, so we need to iterate through it usage = nil unless hash['usage'].nil? usage = [] hash['usage'].each do |structure| usage << (AggregateUsageItem.from_hash(structure) if structure) end end usage = SKIP unless hash.key?('usage') # Parameter is an array, so we need to iterate through it errors = nil unless hash['errors'].nil? errors = [] hash['errors'].each do |structure| errors << (AggregateUsageError.from_hash(structure) if structure) end end errors = SKIP unless hash.key?('errors') # 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. AggregateSessionReport.new(txid: txid, usage: usage, errors: errors, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
28 29 30 31 32 33 34 |
# File 'lib/verizon/models/aggregate_session_report.rb', line 28 def self.names @_hash = {} if @_hash.nil? @_hash['txid'] = 'txid' @_hash['usage'] = 'usage' @_hash['errors'] = 'errors' @_hash end |
.nullables ⇒ Object
An array for nullable fields
45 46 47 48 49 |
# File 'lib/verizon/models/aggregate_session_report.rb', line 45 def self.nullables %w[ txid ] end |
.optionals ⇒ Object
An array for optional fields
37 38 39 40 41 42 |
# File 'lib/verizon/models/aggregate_session_report.rb', line 37 def self.optionals %w[ usage errors ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
110 111 112 113 114 |
# File 'lib/verizon/models/aggregate_session_report.rb', line 110 def inspect class_name = self.class.name.split('::').last "<#{class_name} txid: #{@txid.inspect}, usage: #{@usage.inspect}, errors:"\ " #{@errors.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
103 104 105 106 107 |
# File 'lib/verizon/models/aggregate_session_report.rb', line 103 def to_s class_name = self.class.name.split('::').last "<#{class_name} txid: #{@txid}, usage: #{@usage}, errors: #{@errors},"\ " additional_properties: #{@additional_properties}>" end |