Class: Verizon::ConnectionHistoryResult

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

Overview

Response containing the connection history. It is a list of Network Connection Events for a device.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(connection_history = SKIP, has_more_data = SKIP) ⇒ ConnectionHistoryResult

Returns a new instance of ConnectionHistoryResult.



46
47
48
49
# File 'lib/verizon/models/connection_history_result.rb', line 46

def initialize(connection_history = SKIP, has_more_data = SKIP)
  @connection_history = connection_history unless connection_history == SKIP
  @has_more_data = has_more_data unless has_more_data == SKIP
end

Instance Attribute Details

#connection_historyArray[ConnectionEvent]

Device connection events, sorted by the occurredAt timestamp, oldest first.

Returns:



16
17
18
# File 'lib/verizon/models/connection_history_result.rb', line 16

def connection_history
  @connection_history
end

#has_more_dataTrueClass | FalseClass

False for a status 200 response.True for a status 202 response, indicating that there is more data to be retrieved. Send another request, adjusting the earliest value in the request based on the occuredAt value for the last device in the current response.

Returns:

  • (TrueClass | FalseClass)


23
24
25
# File 'lib/verizon/models/connection_history_result.rb', line 23

def has_more_data
  @has_more_data
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/verizon/models/connection_history_result.rb', line 52

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  # Parameter is an array, so we need to iterate through it
  connection_history = nil
  unless hash['connectionHistory'].nil?
    connection_history = []
    hash['connectionHistory'].each do |structure|
      connection_history << (ConnectionEvent.from_hash(structure) if structure)
    end
  end

  connection_history = SKIP unless hash.key?('connectionHistory')
  has_more_data = hash.key?('hasMoreData') ? hash['hasMoreData'] : SKIP

  # Create object from extracted values.
  ConnectionHistoryResult.new(connection_history,
                              has_more_data)
end

.namesObject

A mapping from model property names to API property names.



26
27
28
29
30
31
# File 'lib/verizon/models/connection_history_result.rb', line 26

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['connection_history'] = 'connectionHistory'
  @_hash['has_more_data'] = 'hasMoreData'
  @_hash
end

.nullablesObject

An array for nullable fields



42
43
44
# File 'lib/verizon/models/connection_history_result.rb', line 42

def self.nullables
  []
end

.optionalsObject

An array for optional fields



34
35
36
37
38
39
# File 'lib/verizon/models/connection_history_result.rb', line 34

def self.optionals
  %w[
    connection_history
    has_more_data
  ]
end