Class: Verizon::DeviceId
- Defined in:
- lib/verizon/models/device_id.rb
Overview
An identifier for a single device.
Instance Attribute Summary collapse
-
#id ⇒ String
The value of the device identifier.
-
#kind ⇒ String
The type of the device identifier.
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.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(id:, kind:, additional_properties: nil) ⇒ DeviceId
constructor
A new instance of DeviceId.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#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(id:, kind:, additional_properties: nil) ⇒ DeviceId
Returns a new instance of DeviceId.
40 41 42 43 44 45 46 47 |
# File 'lib/verizon/models/device_id.rb', line 40 def initialize(id:, kind:, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @id = id @kind = kind @additional_properties = additional_properties end |
Instance Attribute Details
#id ⇒ String
The value of the device identifier.
14 15 16 |
# File 'lib/verizon/models/device_id.rb', line 14 def id @id end |
#kind ⇒ String
The type of the device identifier. Valid types of identifiers are:ESN (decimal),EID,ICCID (up to 20 digits),IMEI (up to 16 digits),MDN,MEID (hexadecimal),MSISDN.
20 21 22 |
# File 'lib/verizon/models/device_id.rb', line 20 def kind @kind end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/verizon/models/device_id.rb', line 50 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : nil kind = hash.key?('kind') ? hash['kind'] : nil # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. DeviceId.new(id: id, kind: kind, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
23 24 25 26 27 28 |
# File 'lib/verizon/models/device_id.rb', line 23 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['kind'] = 'kind' @_hash end |
.nullables ⇒ Object
An array for nullable fields
36 37 38 |
# File 'lib/verizon/models/device_id.rb', line 36 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
31 32 33 |
# File 'lib/verizon/models/device_id.rb', line 31 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/verizon/models/device_id.rb', line 72 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.id, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.kind, ->(val) { val.instance_of? String }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['id'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['kind'], ->(val) { val.instance_of? String }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
100 101 102 103 104 |
# File 'lib/verizon/models/device_id.rb', line 100 def inspect class_name = self.class.name.split('::').last "<#{class_name} id: #{@id.inspect}, kind: #{@kind.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
93 94 95 96 97 |
# File 'lib/verizon/models/device_id.rb', line 93 def to_s class_name = self.class.name.split('::').last "<#{class_name} id: #{@id}, kind: #{@kind}, additional_properties:"\ " #{@additional_properties}>" end |