Class: Verizon::AggregateSessionReport

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/verizon/models/aggregate_session_report.rb

Overview

Session and usage details for up to 10 devices.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(txid = nil, usage = SKIP, errors = SKIP) ⇒ AggregateSessionReport

Returns a new instance of AggregateSessionReport.



51
52
53
54
55
# File 'lib/verizon/models/aggregate_session_report.rb', line 51

def initialize(txid = nil, usage = SKIP, errors = SKIP)
  @txid = txid
  @usage = usage unless usage == SKIP
  @errors = errors unless errors == SKIP
end

Instance Attribute Details

#errorsArray[AggregateUsageError]

An object containing any errors reported by the device.

Returns:



25
26
27
# File 'lib/verizon/models/aggregate_session_report.rb', line 25

def errors
  @errors
end

#txidString

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.

Returns:

  • (String)


17
18
19
# File 'lib/verizon/models/aggregate_session_report.rb', line 17

def txid
  @txid
end

#usageArray[AggregateUsageItem]

Contains usage per device.

Returns:



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.



58
59
60
61
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
# File 'lib/verizon/models/aggregate_session_report.rb', line 58

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 object from extracted values.
  AggregateSessionReport.new(txid,
                             usage,
                             errors)
end

.namesObject

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

.nullablesObject

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

.optionalsObject

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