Class: NewStoreApi::OrderRequest
- Defined in:
- lib/new_store_api/models/order_request.rb
Overview
The minimum-viable order placement request. Required fields only. This first slice supports in-store cash-and-carry orders from self-checkout machines and Associate App.
Instance Attribute Summary collapse
-
#catalog ⇒ Catalog
The catalogue and locale used to resolve the order's items.
-
#channel ⇒ Channel1
Describes the origin of the order.
-
#checkout_id ⇒ String
Associated checkout ID for reconciliation.
-
#customer ⇒ Customer
The customer placing the order.
-
#extended_attributes ⇒ Array[ExtendedAttribute]
Tenant-defined name/value pairs for the order, propagated through the platform.
-
#external_id ⇒ String
Caller-supplied external identifier for correlation and external lookup.
-
#fulfillments ⇒ Array[Fulfillment1]
Caller-supplied external identifier for correlation and external lookup.
-
#gift_wrappings ⇒ Array[GiftWrapping]
Gift wrapping applied to the order's line items.
-
#line_items ⇒ Array[LineItem2]
Gift wrapping applied to the order's line items.
-
#payment ⇒ Payment
The payments attached to an order.
-
#pricing ⇒ Pricing
Currency and tax treatment for all prices in the payload.
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(catalog = nil, channel = nil, fulfillments = nil, line_items = nil, payment = nil, pricing = nil, checkout_id = SKIP, customer = SKIP, extended_attributes = SKIP, external_id = SKIP, gift_wrappings = SKIP) ⇒ OrderRequest
constructor
A new instance of OrderRequest.
-
#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(catalog = nil, channel = nil, fulfillments = nil, line_items = nil, payment = nil, pricing = nil, checkout_id = SKIP, customer = SKIP, extended_attributes = SKIP, external_id = SKIP, gift_wrappings = SKIP) ⇒ OrderRequest
Returns a new instance of OrderRequest.
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/new_store_api/models/order_request.rb', line 104 def initialize(catalog = nil, channel = nil, fulfillments = nil, line_items = nil, payment = nil, pricing = nil, checkout_id = SKIP, customer = SKIP, extended_attributes = SKIP, external_id = SKIP, gift_wrappings = SKIP) @catalog = catalog @channel = channel @checkout_id = checkout_id unless checkout_id == SKIP @customer = customer unless customer == SKIP @extended_attributes = extended_attributes unless extended_attributes == SKIP @external_id = external_id unless external_id == SKIP @fulfillments = fulfillments @gift_wrappings = gift_wrappings unless gift_wrappings == SKIP @line_items = line_items @payment = payment @pricing = pricing end |
Instance Attribute Details
#catalog ⇒ Catalog
The catalogue and locale used to resolve the order's items.
16 17 18 |
# File 'lib/new_store_api/models/order_request.rb', line 16 def catalog @catalog end |
#channel ⇒ Channel1
Describes the origin of the order.
20 21 22 |
# File 'lib/new_store_api/models/order_request.rb', line 20 def channel @channel end |
#checkout_id ⇒ String
Associated checkout ID for reconciliation.
24 25 26 |
# File 'lib/new_store_api/models/order_request.rb', line 24 def checkout_id @checkout_id end |
#customer ⇒ Customer
The customer placing the order. Omitted for anonymous orders.
28 29 30 |
# File 'lib/new_store_api/models/order_request.rb', line 28 def customer @customer end |
#extended_attributes ⇒ Array[ExtendedAttribute]
Tenant-defined name/value pairs for the order, propagated through the platform.
33 34 35 |
# File 'lib/new_store_api/models/order_request.rb', line 33 def extended_attributes @extended_attributes end |
#external_id ⇒ String
Caller-supplied external identifier for correlation and external lookup. Must be unique per tenant when supplied. The order number is generated by the system.
39 40 41 |
# File 'lib/new_store_api/models/order_request.rb', line 39 def external_id @external_id end |
#fulfillments ⇒ Array[Fulfillment1]
Caller-supplied external identifier for correlation and external lookup. Must be unique per tenant when supplied. The order number is generated by the system.
45 46 47 |
# File 'lib/new_store_api/models/order_request.rb', line 45 def fulfillments @fulfillments end |
#gift_wrappings ⇒ Array[GiftWrapping]
Gift wrapping applied to the order's line items. At most one, and it must cover every line item — partial gift wrapping (wrapping only some items) is not yet supported. Omitted when nothing is gift-wrapped.
51 52 53 |
# File 'lib/new_store_api/models/order_request.rb', line 51 def gift_wrappings @gift_wrappings end |
#line_items ⇒ Array[LineItem2]
Gift wrapping applied to the order's line items. At most one, and it must cover every line item — partial gift wrapping (wrapping only some items) is not yet supported. Omitted when nothing is gift-wrapped.
57 58 59 |
# File 'lib/new_store_api/models/order_request.rb', line 57 def line_items @line_items end |
#payment ⇒ Payment
The payments attached to an order.
61 62 63 |
# File 'lib/new_store_api/models/order_request.rb', line 61 def payment @payment end |
#pricing ⇒ Pricing
Currency and tax treatment for all prices in the payload.
65 66 67 |
# File 'lib/new_store_api/models/order_request.rb', line 65 def pricing @pricing end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/new_store_api/models/order_request.rb', line 123 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. catalog = Catalog.from_hash(hash['catalog']) if hash['catalog'] channel = Channel1.from_hash(hash['channel']) if hash['channel'] # Parameter is an array, so we need to iterate through it fulfillments = nil unless hash['fulfillments'].nil? fulfillments = [] hash['fulfillments'].each do |structure| fulfillments << (Fulfillment1.from_hash(structure) if structure) end end fulfillments = nil unless hash.key?('fulfillments') # Parameter is an array, so we need to iterate through it line_items = nil unless hash['line_items'].nil? line_items = [] hash['line_items'].each do |structure| line_items << (LineItem2.from_hash(structure) if structure) end end line_items = nil unless hash.key?('line_items') payment = Payment.from_hash(hash['payment']) if hash['payment'] pricing = Pricing.from_hash(hash['pricing']) if hash['pricing'] checkout_id = hash.key?('checkout_id') ? hash['checkout_id'] : SKIP customer = Customer.from_hash(hash['customer']) if hash['customer'] # Parameter is an array, so we need to iterate through it extended_attributes = nil unless hash['extended_attributes'].nil? extended_attributes = [] hash['extended_attributes'].each do |structure| extended_attributes << (ExtendedAttribute.from_hash(structure) if structure) end end extended_attributes = SKIP unless hash.key?('extended_attributes') external_id = hash.key?('external_id') ? hash['external_id'] : SKIP # Parameter is an array, so we need to iterate through it gift_wrappings = nil unless hash['gift_wrappings'].nil? gift_wrappings = [] hash['gift_wrappings'].each do |structure| gift_wrappings << (GiftWrapping.from_hash(structure) if structure) end end gift_wrappings = SKIP unless hash.key?('gift_wrappings') # Create object from extracted values. OrderRequest.new(catalog, channel, fulfillments, line_items, payment, pricing, checkout_id, customer, extended_attributes, external_id, gift_wrappings) end |
.names ⇒ Object
A mapping from model property names to API property names.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/new_store_api/models/order_request.rb', line 68 def self.names @_hash = {} if @_hash.nil? @_hash['catalog'] = 'catalog' @_hash['channel'] = 'channel' @_hash['checkout_id'] = 'checkout_id' @_hash['customer'] = 'customer' @_hash['extended_attributes'] = 'extended_attributes' @_hash['external_id'] = 'external_id' @_hash['fulfillments'] = 'fulfillments' @_hash['gift_wrappings'] = 'gift_wrappings' @_hash['line_items'] = 'line_items' @_hash['payment'] = 'payment' @_hash['pricing'] = 'pricing' @_hash end |
.nullables ⇒ Object
An array for nullable fields
96 97 98 99 100 101 102 |
# File 'lib/new_store_api/models/order_request.rb', line 96 def self.nullables %w[ checkout_id customer external_id ] end |
.optionals ⇒ Object
An array for optional fields
85 86 87 88 89 90 91 92 93 |
# File 'lib/new_store_api/models/order_request.rb', line 85 def self.optionals %w[ checkout_id customer extended_attributes external_id gift_wrappings ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
199 200 201 202 203 204 205 206 |
# File 'lib/new_store_api/models/order_request.rb', line 199 def inspect class_name = self.class.name.split('::').last "<#{class_name} catalog: #{@catalog.inspect}, channel: #{@channel.inspect}, checkout_id:"\ " #{@checkout_id.inspect}, customer: #{@customer.inspect}, extended_attributes:"\ " #{@extended_attributes.inspect}, external_id: #{@external_id.inspect}, fulfillments:"\ " #{@fulfillments.inspect}, gift_wrappings: #{@gift_wrappings.inspect}, line_items:"\ " #{@line_items.inspect}, payment: #{@payment.inspect}, pricing: #{@pricing.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
190 191 192 193 194 195 196 |
# File 'lib/new_store_api/models/order_request.rb', line 190 def to_s class_name = self.class.name.split('::').last "<#{class_name} catalog: #{@catalog}, channel: #{@channel}, checkout_id: #{@checkout_id},"\ " customer: #{@customer}, extended_attributes: #{@extended_attributes}, external_id:"\ " #{@external_id}, fulfillments: #{@fulfillments}, gift_wrappings: #{@gift_wrappings},"\ " line_items: #{@line_items}, payment: #{@payment}, pricing: #{@pricing}>" end |