Class: NewStoreApi::ExternalIdentifiers
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- NewStoreApi::ExternalIdentifiers
- Defined in:
- lib/new_store_api/models/external_identifiers.rb
Overview
Per-unit external identifiers for a serialised item (a specific physical unit).
Instance Attribute Summary collapse
-
#epc ⇒ String
The unit's Electronic Product Code, e.g.
-
#serial_number ⇒ String
The unit's serial number.
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(epc = SKIP, serial_number = SKIP) ⇒ ExternalIdentifiers
constructor
A new instance of ExternalIdentifiers.
-
#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(epc = SKIP, serial_number = SKIP) ⇒ ExternalIdentifiers
Returns a new instance of ExternalIdentifiers.
45 46 47 48 |
# File 'lib/new_store_api/models/external_identifiers.rb', line 45 def initialize(epc = SKIP, serial_number = SKIP) @epc = epc unless epc == SKIP @serial_number = serial_number unless serial_number == SKIP end |
Instance Attribute Details
#epc ⇒ String
The unit's Electronic Product Code, e.g. read from its RFID tag.
15 16 17 |
# File 'lib/new_store_api/models/external_identifiers.rb', line 15 def epc @epc end |
#serial_number ⇒ String
The unit's serial number.
19 20 21 |
# File 'lib/new_store_api/models/external_identifiers.rb', line 19 def serial_number @serial_number end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/new_store_api/models/external_identifiers.rb', line 51 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. epc = hash.key?('epc') ? hash['epc'] : SKIP serial_number = hash.key?('serial_number') ? hash['serial_number'] : SKIP # Create object from extracted values. ExternalIdentifiers.new(epc, serial_number) end |
.names ⇒ Object
A mapping from model property names to API property names.
22 23 24 25 26 27 |
# File 'lib/new_store_api/models/external_identifiers.rb', line 22 def self.names @_hash = {} if @_hash.nil? @_hash['epc'] = 'epc' @_hash['serial_number'] = 'serial_number' @_hash end |
.nullables ⇒ Object
An array for nullable fields
38 39 40 41 42 43 |
# File 'lib/new_store_api/models/external_identifiers.rb', line 38 def self.nullables %w[ epc serial_number ] end |
.optionals ⇒ Object
An array for optional fields
30 31 32 33 34 35 |
# File 'lib/new_store_api/models/external_identifiers.rb', line 30 def self.optionals %w[ epc serial_number ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
70 71 72 73 |
# File 'lib/new_store_api/models/external_identifiers.rb', line 70 def inspect class_name = self.class.name.split('::').last "<#{class_name} epc: #{@epc.inspect}, serial_number: #{@serial_number.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
64 65 66 67 |
# File 'lib/new_store_api/models/external_identifiers.rb', line 64 def to_s class_name = self.class.name.split('::').last "<#{class_name} epc: #{@epc}, serial_number: #{@serial_number}>" end |