Class: Verizon::ConnectionResponse

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

Overview

response for /clients/connection

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(mqtt_url = nil, host = SKIP, port = SKIP) ⇒ ConnectionResponse

Returns a new instance of ConnectionResponse.



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

def initialize(mqtt_url = nil, host = SKIP, port = SKIP)
  @mqtt_url = mqtt_url
  @host = host unless host == SKIP
  @port = port unless port == SKIP
end

Instance Attribute Details

#hostString

The hostname of the MQTT broker to connect to.

Returns:

  • (String)


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

def host
  @host
end

#mqtt_urlString

The full MQTT URL including protocol, host, and port.

Returns:

  • (String)


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

def mqtt_url
  @mqtt_url
end

#portInteger

The port number of the MQTT broker.

Returns:

  • (Integer)


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

def port
  @port
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/verizon/models/connection_response.rb', line 53

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  mqtt_url = hash.key?('MqttURL') ? hash['MqttURL'] : nil
  host = hash.key?('Host') ? hash['Host'] : SKIP
  port = hash.key?('Port') ? hash['Port'] : SKIP

  # Create object from extracted values.
  ConnectionResponse.new(mqtt_url,
                         host,
                         port)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['mqtt_url'] = 'MqttURL'
  @_hash['host'] = 'Host'
  @_hash['port'] = 'Port'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    host
    port
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



74
75
76
77
78
# File 'lib/verizon/models/connection_response.rb', line 74

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

#to_sObject

Provides a human-readable string representation of the object.



68
69
70
71
# File 'lib/verizon/models/connection_response.rb', line 68

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} mqtt_url: #{@mqtt_url}, host: #{@host}, port: #{@port}>"
end