Class: Verizon::Certificate

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

Overview

Structure for the credentials required to connect to the ETX MQTT 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(cert_pem:, key_pem:, ca_pem:, expiration_time:) ⇒ Certificate

Returns a new instance of Certificate.



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

def initialize(cert_pem:, key_pem:, ca_pem:, expiration_time:)
  @cert_pem = cert_pem
  @key_pem = key_pem
  @ca_pem = ca_pem
  @expiration_time = expiration_time
end

Instance Attribute Details

#ca_pemString

The string containing the CA certificate

Returns:

  • (String)


24
25
26
# File 'lib/verizon/models/certificate.rb', line 24

def ca_pem
  @ca_pem
end

#cert_pemString

The string containing the certificate

Returns:

  • (String)


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

def cert_pem
  @cert_pem
end

#expiration_timeDateTime

The string describing the expiration timestamp of the certificate

Returns:

  • (DateTime)


28
29
30
# File 'lib/verizon/models/certificate.rb', line 28

def expiration_time
  @expiration_time
end

#key_pemString

The string containing the private key

Returns:

  • (String)


20
21
22
# File 'lib/verizon/models/certificate.rb', line 20

def key_pem
  @key_pem
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
# File 'lib/verizon/models/certificate.rb', line 58

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  cert_pem = hash.key?('cert.pem') ? hash['cert.pem'] : nil
  key_pem = hash.key?('key.pem') ? hash['key.pem'] : nil
  ca_pem = hash.key?('ca.pem') ? hash['ca.pem'] : nil
  expiration_time = if hash.key?('ExpirationTime')
                      (DateTimeHelper.from_rfc3339(hash['ExpirationTime']) if hash['ExpirationTime'])
                    end

  # Create object from extracted values.
  Certificate.new(cert_pem: cert_pem,
                  key_pem: key_pem,
                  ca_pem: ca_pem,
                  expiration_time: expiration_time)
end

.namesObject

A mapping from model property names to API property names.



31
32
33
34
35
36
37
38
# File 'lib/verizon/models/certificate.rb', line 31

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['cert_pem'] = 'cert.pem'
  @_hash['key_pem'] = 'key.pem'
  @_hash['ca_pem'] = 'ca.pem'
  @_hash['expiration_time'] = 'ExpirationTime'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  []
end

.optionalsObject

An array for optional fields



41
42
43
# File 'lib/verizon/models/certificate.rb', line 41

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



88
89
90
91
92
# File 'lib/verizon/models/certificate.rb', line 88

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} cert_pem: #{@cert_pem.inspect}, key_pem: #{@key_pem.inspect}, ca_pem:"\
  " #{@ca_pem.inspect}, expiration_time: #{@expiration_time.inspect}>"
end

#to_custom_expiration_timeObject



76
77
78
# File 'lib/verizon/models/certificate.rb', line 76

def to_custom_expiration_time
  DateTimeHelper.to_rfc3339(expiration_time)
end

#to_sObject

Provides a human-readable string representation of the object.



81
82
83
84
85
# File 'lib/verizon/models/certificate.rb', line 81

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} cert_pem: #{@cert_pem}, key_pem: #{@key_pem}, ca_pem: #{@ca_pem},"\
  " expiration_time: #{@expiration_time}>"
end