Class: NewStoreApi::OrderResponse
- Defined in:
- lib/new_store_api/models/order_response.rb
Overview
The response returned after an order is accepted.
Instance Attribute Summary collapse
-
#external_id ⇒ String
Caller-provided external identifier echoed back when supplied in the request.
-
#id ⇒ String
The unique identifier of the order assigned by the system.
-
#items ⇒ Array[ResponseUnitItem]
Identifiers of the order items.
-
#order_number ⇒ String
Human-readable order number generated by the system.
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, items = nil, order_number = nil, external_id = SKIP) ⇒ OrderResponse
constructor
A new instance of OrderResponse.
-
#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, items = nil, order_number = nil, external_id = SKIP) ⇒ OrderResponse
Returns a new instance of OrderResponse.
53 54 55 56 57 58 59 |
# File 'lib/new_store_api/models/order_response.rb', line 53 def initialize(id = nil, items = nil, order_number = nil, external_id = SKIP) @external_id = external_id unless external_id == SKIP @id = id @items = items @order_number = order_number end |
Instance Attribute Details
#external_id ⇒ String
Caller-provided external identifier echoed back when supplied in the request.
15 16 17 |
# File 'lib/new_store_api/models/order_response.rb', line 15 def external_id @external_id end |
#id ⇒ String
The unique identifier of the order assigned by the system.
19 20 21 |
# File 'lib/new_store_api/models/order_response.rb', line 19 def id @id end |
#items ⇒ Array[ResponseUnitItem]
Identifiers of the order items.
23 24 25 |
# File 'lib/new_store_api/models/order_response.rb', line 23 def items @items end |
#order_number ⇒ String
Human-readable order number generated by the system.
27 28 29 |
# File 'lib/new_store_api/models/order_response.rb', line 27 def order_number @order_number end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/new_store_api/models/order_response.rb', line 62 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : nil # Parameter is an array, so we need to iterate through it items = nil unless hash['items'].nil? items = [] hash['items'].each do |structure| items << (ResponseUnitItem.from_hash(structure) if structure) end end items = nil unless hash.key?('items') order_number = hash.key?('order_number') ? hash['order_number'] : nil external_id = hash.key?('external_id') ? hash['external_id'] : SKIP # Create object from extracted values. OrderResponse.new(id, items, order_number, external_id) end |
.names ⇒ Object
A mapping from model property names to API property names.
30 31 32 33 34 35 36 37 |
# File 'lib/new_store_api/models/order_response.rb', line 30 def self.names @_hash = {} if @_hash.nil? @_hash['external_id'] = 'external_id' @_hash['id'] = 'id' @_hash['items'] = 'items' @_hash['order_number'] = 'order_number' @_hash end |
.nullables ⇒ Object
An array for nullable fields
47 48 49 50 51 |
# File 'lib/new_store_api/models/order_response.rb', line 47 def self.nullables %w[ external_id ] end |
.optionals ⇒ Object
An array for optional fields
40 41 42 43 44 |
# File 'lib/new_store_api/models/order_response.rb', line 40 def self.optionals %w[ external_id ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
95 96 97 98 99 |
# File 'lib/new_store_api/models/order_response.rb', line 95 def inspect class_name = self.class.name.split('::').last "<#{class_name} external_id: #{@external_id.inspect}, id: #{@id.inspect}, items:"\ " #{@items.inspect}, order_number: #{@order_number.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
88 89 90 91 92 |
# File 'lib/new_store_api/models/order_response.rb', line 88 def to_s class_name = self.class.name.split('::').last "<#{class_name} external_id: #{@external_id}, id: #{@id}, items: #{@items}, order_number:"\ " #{@order_number}>" end |