Class: NewStoreApi::ResponseUnitItem
- Defined in:
- lib/new_store_api/models/response_unit_item.rb
Overview
An item identifier triplet echoed back in the order response.
Instance Attribute Summary collapse
-
#external_item_id ⇒ String
The external order item id as specified in the request (
unit_external_id). -
#id ⇒ String
An identifier that is assigned to the item by the system.
-
#product_id ⇒ String
The product id from the catalog.
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(id = nil, product_id = nil, external_item_id = SKIP) ⇒ ResponseUnitItem
constructor
A new instance of ResponseUnitItem.
-
#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 = nil, product_id = nil, external_item_id = SKIP) ⇒ ResponseUnitItem
Returns a new instance of ResponseUnitItem.
48 49 50 51 52 |
# File 'lib/new_store_api/models/response_unit_item.rb', line 48 def initialize(id = nil, product_id = nil, external_item_id = SKIP) @external_item_id = external_item_id unless external_item_id == SKIP @id = id @product_id = product_id end |
Instance Attribute Details
#external_item_id ⇒ String
The external order item id as specified in the request
(unit_external_id). Null when not supplied.
15 16 17 |
# File 'lib/new_store_api/models/response_unit_item.rb', line 15 def external_item_id @external_item_id end |
#id ⇒ String
An identifier that is assigned to the item by the system.
19 20 21 |
# File 'lib/new_store_api/models/response_unit_item.rb', line 19 def id @id end |
#product_id ⇒ String
The product id from the catalog.
23 24 25 |
# File 'lib/new_store_api/models/response_unit_item.rb', line 23 def product_id @product_id end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/new_store_api/models/response_unit_item.rb', line 55 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : nil product_id = hash.key?('product_id') ? hash['product_id'] : nil external_item_id = hash.key?('external_item_id') ? hash['external_item_id'] : SKIP # Create object from extracted values. ResponseUnitItem.new(id, product_id, external_item_id) end |
.names ⇒ Object
A mapping from model property names to API property names.
26 27 28 29 30 31 32 |
# File 'lib/new_store_api/models/response_unit_item.rb', line 26 def self.names @_hash = {} if @_hash.nil? @_hash['external_item_id'] = 'external_item_id' @_hash['id'] = 'id' @_hash['product_id'] = 'product_id' @_hash end |
.nullables ⇒ Object
An array for nullable fields
42 43 44 45 46 |
# File 'lib/new_store_api/models/response_unit_item.rb', line 42 def self.nullables %w[ external_item_id ] end |
.optionals ⇒ Object
An array for optional fields
35 36 37 38 39 |
# File 'lib/new_store_api/models/response_unit_item.rb', line 35 def self.optionals %w[ external_item_id ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
78 79 80 81 82 |
# File 'lib/new_store_api/models/response_unit_item.rb', line 78 def inspect class_name = self.class.name.split('::').last "<#{class_name} external_item_id: #{@external_item_id.inspect}, id: #{@id.inspect},"\ " product_id: #{@product_id.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
71 72 73 74 75 |
# File 'lib/new_store_api/models/response_unit_item.rb', line 71 def to_s class_name = self.class.name.split('::').last "<#{class_name} external_item_id: #{@external_item_id}, id: #{@id}, product_id:"\ " #{@product_id}>" end |