Class: Verizon::Certificate
- 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
-
#ca_pem ⇒ String
The string containing the CA certificate.
-
#cert_pem ⇒ String
The string containing the certificate.
-
#expiration_time ⇒ DateTime
The string describing the expiration timestamp of the certificate.
-
#key_pem ⇒ String
The string containing the private key.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(cert_pem:, key_pem:, ca_pem:, expiration_time:) ⇒ Certificate
constructor
A new instance of Certificate.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_expiration_time ⇒ Object
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
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_pem ⇒ String
The string containing the CA certificate
24 25 26 |
# File 'lib/verizon/models/certificate.rb', line 24 def ca_pem @ca_pem end |
#cert_pem ⇒ String
The string containing the certificate
16 17 18 |
# File 'lib/verizon/models/certificate.rb', line 16 def cert_pem @cert_pem end |
#expiration_time ⇒ DateTime
The string describing the expiration timestamp of the certificate
28 29 30 |
# File 'lib/verizon/models/certificate.rb', line 28 def expiration_time @expiration_time end |
#key_pem ⇒ String
The string containing the private key
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 |
.names ⇒ Object
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 |
.nullables ⇒ Object
An array for nullable fields
46 47 48 |
# File 'lib/verizon/models/certificate.rb', line 46 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
41 42 43 |
# File 'lib/verizon/models/certificate.rb', line 41 def self.optionals [] end |
Instance Method Details
#inspect ⇒ Object
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_time ⇒ Object
76 77 78 |
# File 'lib/verizon/models/certificate.rb', line 76 def to_custom_expiration_time DateTimeHelper.to_rfc3339(expiration_time) end |
#to_s ⇒ Object
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 |