Class: Verizon::ConnectionEvent

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

Overview

Network connection events for a device during a specified time period.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(connection_event_attributes = SKIP, extended_attributes = SKIP, occurred_at = SKIP) ⇒ ConnectionEvent

Returns a new instance of ConnectionEvent.



47
48
49
50
51
52
53
54
55
# File 'lib/verizon/models/connection_event.rb', line 47

def initialize(connection_event_attributes = SKIP,
               extended_attributes = SKIP, occurred_at = SKIP)
  unless connection_event_attributes == SKIP
    @connection_event_attributes =
      connection_event_attributes
  end
  @extended_attributes = extended_attributes unless extended_attributes == SKIP
  @occurred_at = occurred_at unless occurred_at == SKIP
end

Instance Attribute Details

#connection_event_attributesArray[CustomFields]

The attributes that describe the connection event.

Returns:



14
15
16
# File 'lib/verizon/models/connection_event.rb', line 14

def connection_event_attributes
  @connection_event_attributes
end

#extended_attributesArray[CustomFields]

Currently not used.

Returns:



18
19
20
# File 'lib/verizon/models/connection_event.rb', line 18

def extended_attributes
  @extended_attributes
end

#occurred_atString

The date and time when the connection event occured.

Returns:

  • (String)


22
23
24
# File 'lib/verizon/models/connection_event.rb', line 22

def occurred_at
  @occurred_at
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/connection_event.rb', line 58

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_event_attributes = nil
  unless hash['connectionEventAttributes'].nil?
    connection_event_attributes = []
    hash['connectionEventAttributes'].each do |structure|
      connection_event_attributes << (CustomFields.from_hash(structure) if structure)
    end
  end

  connection_event_attributes = SKIP unless hash.key?('connectionEventAttributes')
  # Parameter is an array, so we need to iterate through it
  extended_attributes = nil
  unless hash['extendedAttributes'].nil?
    extended_attributes = []
    hash['extendedAttributes'].each do |structure|
      extended_attributes << (CustomFields.from_hash(structure) if structure)
    end
  end

  extended_attributes = SKIP unless hash.key?('extendedAttributes')
  occurred_at = hash.key?('occurredAt') ? hash['occurredAt'] : SKIP

  # Create object from extracted values.
  ConnectionEvent.new(connection_event_attributes,
                      extended_attributes,
                      occurred_at)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['connection_event_attributes'] = 'connectionEventAttributes'
  @_hash['extended_attributes'] = 'extendedAttributes'
  @_hash['occurred_at'] = 'occurredAt'
  @_hash
end

.nullablesObject

An array for nullable fields



43
44
45
# File 'lib/verizon/models/connection_event.rb', line 43

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    connection_event_attributes
    extended_attributes
    occurred_at
  ]
end