Class: Verizon::ConnectionRequest

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

Overview

Request for /clients/connection. It requires the device ID acquired in the registration request call; the geolocation of the device at the time of the request; and the network type (Verizon or non-Verizon). The system uses this information to determine with MQTT endpoint the device should use to connect the ETX Message Exchange.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(device_id:, geolocation:, network_type:) ⇒ ConnectionRequest

Returns a new instance of ConnectionRequest.



56
57
58
59
60
# File 'lib/verizon/models/connection_request.rb', line 56

def initialize(device_id:, geolocation:, network_type:)
  @device_id = device_id
  @geolocation = geolocation
  @network_type = network_type
end

Instance Attribute Details

#device_idUUID | String

The generated ID (UUID v4) for the device. It can be used as:

- the MQTT Client ID when connecting to the Message Exchange system
- a parameter when asking for the connection endpoint
- a parameter when finishing the device registration
- a parameter when unregistering the device

Returns:

  • (UUID | String)


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

def device_id
  @device_id
end

#geolocationGeolocation

Geolocation of the device at the time of the connection request in GPS coordinates.

Returns:



27
28
29
# File 'lib/verizon/models/connection_request.rb', line 27

def geolocation
  @geolocation
end

#network_typeEtxNetworkType

The type of the device’s network connection at the time of the request. If the device is on the Verizon cellular network it should use the “VZ” value otherwise the “non-VZ” value. Devices on the Verizon network can directly access the ETX Message Exchange on the MEC (Mobile Edge Compute server)

Returns:



35
36
37
# File 'lib/verizon/models/connection_request.rb', line 35

def network_type
  @network_type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/verizon/models/connection_request.rb', line 63

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  device_id = hash.key?('DeviceID') ? hash['DeviceID'] : nil
  geolocation = Geolocation.from_hash(hash['Geolocation']) if hash['Geolocation']
  network_type = hash.key?('NetworkType') ? hash['NetworkType'] : nil

  # Create object from extracted values.
  ConnectionRequest.new(device_id: device_id,
                        geolocation: geolocation,
                        network_type: network_type)
end

.namesObject

A mapping from model property names to API property names.



38
39
40
41
42
43
44
# File 'lib/verizon/models/connection_request.rb', line 38

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['device_id'] = 'DeviceID'
  @_hash['geolocation'] = 'Geolocation'
  @_hash['network_type'] = 'NetworkType'
  @_hash
end

.nullablesObject

An array for nullable fields



52
53
54
# File 'lib/verizon/models/connection_request.rb', line 52

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



85
86
87
88
89
# File 'lib/verizon/models/connection_request.rb', line 85

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} device_id: #{@device_id.inspect}, geolocation: #{@geolocation.inspect},"\
  " network_type: #{@network_type.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



78
79
80
81
82
# File 'lib/verizon/models/connection_request.rb', line 78

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} device_id: #{@device_id}, geolocation: #{@geolocation}, network_type:"\
  " #{@network_type}>"
end