Class: NewStoreApi::SalesOrderDetailResponse

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/new_store_api/models/sales_order_detail_response.rb

Overview

Schema for fetching sales order using external ID

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(channel_type = nil, currency = nil, fulfillment_type = nil, id = nil, items = nil, origin = nil, origin_id = nil, placed_at = nil, status = nil, totals = nil, billing_address = SKIP, catalog = SKIP, customer = SKIP, exemption_class = SKIP, exemption_number = SKIP, extended_attributes = SKIP, fulfillments = SKIP, gift_wrapping = SKIP, is_offline = SKIP, notification_blacklist = SKIP, payment_history = SKIP, shipments = SKIP, shipping_address = SKIP, shop_locale = SKIP, store_id = SKIP, tax_exempt = SKIP, tax_method = SKIP) ⇒ SalesOrderDetailResponse

Returns a new instance of SalesOrderDetailResponse.



196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 196

def initialize(channel_type = nil, currency = nil, fulfillment_type = nil,
               id = nil, items = nil, origin = nil, origin_id = nil,
               placed_at = nil, status = nil, totals = nil,
               billing_address = SKIP, catalog = SKIP, customer = SKIP,
               exemption_class = SKIP, exemption_number = SKIP,
               extended_attributes = SKIP, fulfillments = SKIP,
               gift_wrapping = SKIP, is_offline = SKIP,
               notification_blacklist = SKIP, payment_history = SKIP,
               shipments = SKIP, shipping_address = SKIP,
               shop_locale = SKIP, store_id = SKIP, tax_exempt = SKIP,
               tax_method = SKIP)
  @billing_address = billing_address unless billing_address == SKIP
  @catalog = catalog unless catalog == SKIP
  @channel_type = channel_type
  @currency = currency
  @customer = customer unless customer == SKIP
  @exemption_class = exemption_class unless exemption_class == SKIP
  @exemption_number = exemption_number unless exemption_number == SKIP
  @extended_attributes = extended_attributes unless extended_attributes == SKIP
  @fulfillment_type = fulfillment_type
  @fulfillments = fulfillments unless fulfillments == SKIP
  @gift_wrapping = gift_wrapping unless gift_wrapping == SKIP
  @id = id
  @is_offline = is_offline unless is_offline == SKIP
  @items = items
  @notification_blacklist = notification_blacklist unless notification_blacklist == SKIP
  @origin = origin
  @origin_id = origin_id
  @payment_history = payment_history unless payment_history == SKIP
  @placed_at = placed_at
  @shipments = shipments unless shipments == SKIP
  @shipping_address = shipping_address unless shipping_address == SKIP
  @shop_locale = shop_locale unless shop_locale == SKIP
  @status = status
  @store_id = store_id unless store_id == SKIP
  @tax_exempt = tax_exempt unless tax_exempt == SKIP
  @tax_method = tax_method unless tax_method == SKIP
  @totals = totals
end

Instance Attribute Details

#billing_addressSalesOrderAddress

Address

Returns:



15
16
17
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 15

def billing_address
  @billing_address
end

#catalogString

The catalog identifier (shop) associated with the order.

Returns:

  • (String)


19
20
21
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 19

def catalog
  @catalog
end

#channel_typeSalesOrderChannelTypeEnum

The channel through which the order was placed.



23
24
25
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 23

def channel_type
  @channel_type
end

#currencyString

Currency code (ISO 4217) used in internal accounting

Returns:

  • (String)


27
28
29
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 27

def currency
  @currency
end

#customerSalesOrderCustomer

Currency code (ISO 4217) used in internal accounting

Returns:



31
32
33
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 31

def customer
  @customer
end

#exemption_classString

The tax exemption class for the order (e.g. CHARITY_ORGANIZATION). Only present when the order carries a tax exemption.

Returns:

  • (String)


36
37
38
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 36

def exemption_class
  @exemption_class
end

#exemption_numberString

The tax exemption certificate number for the order. Only present when the order carries a tax exemption.

Returns:

  • (String)


41
42
43
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 41

def exemption_number
  @exemption_number
end

#extended_attributesArray[SalesOrderExtendedAttribute]

Extended attributes of the sales order item.

Returns:



45
46
47
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 45

def extended_attributes
  @extended_attributes
end

#fulfillment_typeSalesOrderFulfillmentTypeEnum

The fulfillment type of the order. In case of mixed cart orders, fulfillment type is always 'multiple'



50
51
52
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 50

def fulfillment_type
  @fulfillment_type
end

#fulfillmentsArray[SalesOrderFulfillment]

Fulfillment groups for the order. Each group references its order items and carries the ship-from origin for those items.

Returns:



55
56
57
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 55

def fulfillments
  @fulfillments
end

#gift_wrappingSalesOrderGiftWrapping

Gift wrapping information. This field is not required and will not be present if gift wrapping is not applicable for the order



60
61
62
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 60

def gift_wrapping
  @gift_wrapping
end

#idString

External ID of an order

Returns:

  • (String)


64
65
66
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 64

def id
  @id
end

#is_offlineTrueClass | FalseClass

Set to true if sales order item was created in offline mode.

Returns:

  • (TrueClass | FalseClass)


68
69
70
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 68

def is_offline
  @is_offline
end

#itemsArray[SalesOrderDetail]

Contains a list of order items

Returns:



72
73
74
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 72

def items
  @items
end

#notification_blacklistArray[String]

Excludes the specified notifications from being sent to the customer.

Returns:

  • (Array[String])


76
77
78
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 76

def notification_blacklist
  @notification_blacklist
end

#originSalesOrderOriginEnum

Describes in which Order Management System the order originated from.



80
81
82
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 80

def origin
  @origin
end

#origin_idString

The identifier of the order from the Order Management System where it originated from. If it originated in Newstore, it is the system-generated UUID assigned to the order during the order creation process. If it originated in an external OMS, it is the human-readable identifier.

Returns:

  • (String)


87
88
89
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 87

def origin_id
  @origin_id
end

#payment_historyArray[SalesOrderItemPaymentHistory]

Note: This field will be empty if a NewStore internal order is requested. This field is only set when the order is fetched from an external source.

Returns:



92
93
94
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 92

def payment_history
  @payment_history
end

#placed_atDateTime

The time when the order was placed. It should follow https://tools.ietf.org/html/rfc3339 in UTC.

Returns:

  • (DateTime)


97
98
99
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 97

def placed_at
  @placed_at
end

#shipmentsArray[SalesOrderItemShipment]

The time when the order was placed. It should follow https://tools.ietf.org/html/rfc3339 in UTC.

Returns:



102
103
104
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 102

def shipments
  @shipments
end

#shipping_addressSalesOrderAddress

Address

Returns:



106
107
108
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 106

def shipping_address
  @shipping_address
end

#shop_localeString

The locale used for the shop, in RFC 5646.

Returns:

  • (String)


110
111
112
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 110

def shop_locale
  @shop_locale
end

#statusSalesOrderStatusEnum

Current status of the sales order



114
115
116
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 114

def status
  @status
end

#store_idString

The store id where the order was placed.

Returns:

  • (String)


118
119
120
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 118

def store_id
  @store_id
end

#tax_exemptTrueClass | FalseClass

If the tax was exempted for this order. In case of external orders, the flag will always return false.

Returns:

  • (TrueClass | FalseClass)


123
124
125
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 123

def tax_exempt
  @tax_exempt
end

#tax_methodSalesOrderTaxMethodEnum

Method of calculation of the taxes, can be vat_included or vat_excluded.



127
128
129
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 127

def tax_method
  @tax_method
end

#totalsSalesOrderTotals

Method of calculation of the taxes, can be vat_included or vat_excluded.

Returns:



131
132
133
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 131

def totals
  @totals
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 237

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  channel_type = hash.key?('channel_type') ? hash['channel_type'] : nil
  currency = hash.key?('currency') ? hash['currency'] : nil
  fulfillment_type =
    hash.key?('fulfillment_type') ? hash['fulfillment_type'] : nil
  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 << (SalesOrderDetail.from_hash(structure) if structure)
    end
  end

  items = nil unless hash.key?('items')
  origin = hash.key?('origin') ? hash['origin'] : nil
  origin_id = hash.key?('origin_id') ? hash['origin_id'] : nil
  placed_at = if hash.key?('placed_at')
                (DateTimeHelper.from_rfc3339(hash['placed_at']) if hash['placed_at'])
              end
  status = hash.key?('status') ? hash['status'] : nil
  totals = SalesOrderTotals.from_hash(hash['totals']) if hash['totals']
  billing_address = SalesOrderAddress.from_hash(hash['billing_address']) if
    hash['billing_address']
  catalog = hash.key?('catalog') ? hash['catalog'] : SKIP
  customer = SalesOrderCustomer.from_hash(hash['customer']) if hash['customer']
  exemption_class =
    hash.key?('exemption_class') ? hash['exemption_class'] : SKIP
  exemption_number =
    hash.key?('exemption_number') ? hash['exemption_number'] : SKIP
  # 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 << (SalesOrderExtendedAttribute.from_hash(structure) if structure)
    end
  end

  extended_attributes = SKIP unless hash.key?('extended_attributes')
  # Parameter is an array, so we need to iterate through it
  fulfillments = nil
  unless hash['fulfillments'].nil?
    fulfillments = []
    hash['fulfillments'].each do |structure|
      fulfillments << (SalesOrderFulfillment.from_hash(structure) if structure)
    end
  end

  fulfillments = SKIP unless hash.key?('fulfillments')
  gift_wrapping = SalesOrderGiftWrapping.from_hash(hash['gift_wrapping']) if
    hash['gift_wrapping']
  is_offline = hash.key?('is_offline') ? hash['is_offline'] : SKIP
  notification_blacklist =
    hash.key?('notification_blacklist') ? hash['notification_blacklist'] : SKIP
  # Parameter is an array, so we need to iterate through it
  payment_history = nil
  unless hash['payment_history'].nil?
    payment_history = []
    hash['payment_history'].each do |structure|
      payment_history << (SalesOrderItemPaymentHistory.from_hash(structure) if structure)
    end
  end

  payment_history = SKIP unless hash.key?('payment_history')
  # Parameter is an array, so we need to iterate through it
  shipments = nil
  unless hash['shipments'].nil?
    shipments = []
    hash['shipments'].each do |structure|
      shipments << (SalesOrderItemShipment.from_hash(structure) if structure)
    end
  end

  shipments = SKIP unless hash.key?('shipments')
  shipping_address = SalesOrderAddress.from_hash(hash['shipping_address']) if
    hash['shipping_address']
  shop_locale = hash.key?('shop_locale') ? hash['shop_locale'] : SKIP
  store_id = hash.key?('store_id') ? hash['store_id'] : SKIP
  tax_exempt = hash.key?('tax_exempt') ? hash['tax_exempt'] : SKIP
  tax_method = hash.key?('tax_method') ? hash['tax_method'] : SKIP

  # Create object from extracted values.
  SalesOrderDetailResponse.new(channel_type,
                               currency,
                               fulfillment_type,
                               id,
                               items,
                               origin,
                               origin_id,
                               placed_at,
                               status,
                               totals,
                               billing_address,
                               catalog,
                               customer,
                               exemption_class,
                               exemption_number,
                               extended_attributes,
                               fulfillments,
                               gift_wrapping,
                               is_offline,
                               notification_blacklist,
                               payment_history,
                               shipments,
                               shipping_address,
                               shop_locale,
                               store_id,
                               tax_exempt,
                               tax_method)
end

.namesObject

A mapping from model property names to API property names.



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
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 134

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['billing_address'] = 'billing_address'
  @_hash['catalog'] = 'catalog'
  @_hash['channel_type'] = 'channel_type'
  @_hash['currency'] = 'currency'
  @_hash['customer'] = 'customer'
  @_hash['exemption_class'] = 'exemption_class'
  @_hash['exemption_number'] = 'exemption_number'
  @_hash['extended_attributes'] = 'extended_attributes'
  @_hash['fulfillment_type'] = 'fulfillment_type'
  @_hash['fulfillments'] = 'fulfillments'
  @_hash['gift_wrapping'] = 'gift_wrapping'
  @_hash['id'] = 'id'
  @_hash['is_offline'] = 'is_offline'
  @_hash['items'] = 'items'
  @_hash['notification_blacklist'] = 'notification_blacklist'
  @_hash['origin'] = 'origin'
  @_hash['origin_id'] = 'origin_id'
  @_hash['payment_history'] = 'payment_history'
  @_hash['placed_at'] = 'placed_at'
  @_hash['shipments'] = 'shipments'
  @_hash['shipping_address'] = 'shipping_address'
  @_hash['shop_locale'] = 'shop_locale'
  @_hash['status'] = 'status'
  @_hash['store_id'] = 'store_id'
  @_hash['tax_exempt'] = 'tax_exempt'
  @_hash['tax_method'] = 'tax_method'
  @_hash['totals'] = 'totals'
  @_hash
end

.nullablesObject

An array for nullable fields



190
191
192
193
194
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 190

def self.nullables
  %w[
    extended_attributes
  ]
end

.optionalsObject

An array for optional fields



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/sales_order_detail_response.rb', line 167

def self.optionals
  %w[
    billing_address
    catalog
    customer
    exemption_class
    exemption_number
    extended_attributes
    fulfillments
    gift_wrapping
    is_offline
    notification_blacklist
    payment_history
    shipments
    shipping_address
    shop_locale
    store_id
    tax_exempt
    tax_method
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 373

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} billing_address: #{@billing_address.inspect}, catalog: #{@catalog.inspect},"\
  " channel_type: #{@channel_type.inspect}, currency: #{@currency.inspect}, customer:"\
  " #{@customer.inspect}, exemption_class: #{@exemption_class.inspect}, exemption_number:"\
  " #{@exemption_number.inspect}, extended_attributes: #{@extended_attributes.inspect},"\
  " fulfillment_type: #{@fulfillment_type.inspect}, fulfillments: #{@fulfillments.inspect},"\
  " gift_wrapping: #{@gift_wrapping.inspect}, id: #{@id.inspect}, is_offline:"\
  " #{@is_offline.inspect}, items: #{@items.inspect}, notification_blacklist:"\
  " #{@notification_blacklist.inspect}, origin: #{@origin.inspect}, origin_id:"\
  " #{@origin_id.inspect}, payment_history: #{@payment_history.inspect}, placed_at:"\
  " #{@placed_at.inspect}, shipments: #{@shipments.inspect}, shipping_address:"\
  " #{@shipping_address.inspect}, shop_locale: #{@shop_locale.inspect}, status:"\
  " #{@status.inspect}, store_id: #{@store_id.inspect}, tax_exempt: #{@tax_exempt.inspect},"\
  " tax_method: #{@tax_method.inspect}, totals: #{@totals.inspect}>"
end

#to_custom_placed_atObject



353
354
355
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 353

def to_custom_placed_at
  DateTimeHelper.to_rfc3339(placed_at)
end

#to_sObject

Provides a human-readable string representation of the object.



358
359
360
361
362
363
364
365
366
367
368
369
370
# File 'lib/new_store_api/models/sales_order_detail_response.rb', line 358

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} billing_address: #{@billing_address}, catalog: #{@catalog}, channel_type:"\
  " #{@channel_type}, currency: #{@currency}, customer: #{@customer}, exemption_class:"\
  " #{@exemption_class}, exemption_number: #{@exemption_number}, extended_attributes:"\
  " #{@extended_attributes}, fulfillment_type: #{@fulfillment_type}, fulfillments:"\
  " #{@fulfillments}, gift_wrapping: #{@gift_wrapping}, id: #{@id}, is_offline:"\
  " #{@is_offline}, items: #{@items}, notification_blacklist: #{@notification_blacklist},"\
  " origin: #{@origin}, origin_id: #{@origin_id}, payment_history: #{@payment_history},"\
  " placed_at: #{@placed_at}, shipments: #{@shipments}, shipping_address:"\
  " #{@shipping_address}, shop_locale: #{@shop_locale}, status: #{@status}, store_id:"\
  " #{@store_id}, tax_exempt: #{@tax_exempt}, tax_method: #{@tax_method}, totals: #{@totals}>"
end