Class: Verizon::SessionReport
- Defined in:
- lib/verizon/models/session_report.rb
Overview
Session report for a device.
Instance Attribute Summary collapse
-
#id ⇒ String
The 10-digit ID of the device.
-
#sessions ⇒ Array[DailyUsageItem]
An object containing the start and end time of the session with the amount of data transferred.
-
#txid ⇒ String
A unique string (UUID) 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.
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(id = nil, txid = nil, sessions = SKIP) ⇒ SessionReport
constructor
A new instance of SessionReport.
-
#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(id = nil, txid = nil, sessions = SKIP) ⇒ SessionReport
Returns a new instance of SessionReport.
49 50 51 52 53 |
# File 'lib/verizon/models/session_report.rb', line 49 def initialize(id = nil, txid = nil, sessions = SKIP) @id = id @txid = txid @sessions = sessions unless sessions == SKIP end |
Instance Attribute Details
#id ⇒ String
The 10-digit ID of the device.
14 15 16 |
# File 'lib/verizon/models/session_report.rb', line 14 def id @id end |
#sessions ⇒ Array[DailyUsageItem]
An object containing the start and end time of the session with the amount of data transferred.
26 27 28 |
# File 'lib/verizon/models/session_report.rb', line 26 def sessions @sessions end |
#txid ⇒ String
A unique string (UUID) 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 a txid.
21 22 23 |
# File 'lib/verizon/models/session_report.rb', line 21 def txid @txid end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/verizon/models/session_report.rb', line 56 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : nil txid = hash.key?('txid') ? hash['txid'] : nil # Parameter is an array, so we need to iterate through it sessions = nil unless hash['sessions'].nil? sessions = [] hash['sessions'].each do |structure| sessions << (DailyUsageItem.from_hash(structure) if structure) end end sessions = SKIP unless hash.key?('sessions') # Create object from extracted values. SessionReport.new(id, txid, sessions) end |
.names ⇒ Object
A mapping from model property names to API property names.
29 30 31 32 33 34 35 |
# File 'lib/verizon/models/session_report.rb', line 29 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['txid'] = 'txid' @_hash['sessions'] = 'sessions' @_hash end |
.nullables ⇒ Object
An array for nullable fields
45 46 47 |
# File 'lib/verizon/models/session_report.rb', line 45 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
38 39 40 41 42 |
# File 'lib/verizon/models/session_report.rb', line 38 def self.optionals %w[ sessions ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
86 87 88 89 90 |
# File 'lib/verizon/models/session_report.rb', line 86 def inspect class_name = self.class.name.split('::').last "<#{class_name} id: #{@id.inspect}, txid: #{@txid.inspect}, sessions:"\ " #{@sessions.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
80 81 82 83 |
# File 'lib/verizon/models/session_report.rb', line 80 def to_s class_name = self.class.name.split('::').last "<#{class_name} id: #{@id}, txid: #{@txid}, sessions: #{@sessions}>" end |