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 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.
Methods inherited from BaseModel
Constructor Details
#initialize(id = nil, txid = nil, sessions = SKIP) ⇒ SessionReport
Returns a new instance of SessionReport.
51 52 53 54 55 |
# File 'lib/verizon/models/session_report.rb', line 51 def initialize(id = nil, txid = nil, sessions = SKIP) @sessions = sessions unless sessions == SKIP @id = id @txid = txid end |
Instance Attribute Details
#id ⇒ String
The 10-digit ID of the device.
19 20 21 |
# File 'lib/verizon/models/session_report.rb', line 19 def id @id end |
#sessions ⇒ Array[DailyUsageItem]
An object containing the start and end time of the session with the amount of data transferred.
15 16 17 |
# File 'lib/verizon/models/session_report.rb', line 15 def sessions @sessions 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.
26 27 28 |
# File 'lib/verizon/models/session_report.rb', line 26 def txid @txid end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/verizon/models/session_report.rb', line 58 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['sessions'] = 'sessions' @_hash['id'] = 'id' @_hash['txid'] = 'txid' @_hash end |
.nullables ⇒ Object
An array for nullable fields
45 46 47 48 49 |
# File 'lib/verizon/models/session_report.rb', line 45 def self.nullables %w[ txid ] 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 |