Class: NewStoreApi::SalesOrderDetail

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

Overview

SalesOrderDetail Model.

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(id = nil, origin_id = nil, price = nil, product_attributes = nil, status = nil, addon_parent_item_id = SKIP, discounts = SKIP, extended_attributes = SKIP, external_identifier = SKIP, fulfillment_group_type = SKIP, price_catalog = SKIP, product_id = SKIP, shipping_method = SKIP, tax_class = SKIP, tax_lines = SKIP) ⇒ SalesOrderDetail

Returns a new instance of SalesOrderDetail.



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/new_store_api/models/sales_order_detail.rb', line 127

def initialize(id = nil, origin_id = nil, price = nil,
               product_attributes = nil, status = nil,
               addon_parent_item_id = SKIP, discounts = SKIP,
               extended_attributes = SKIP, external_identifier = SKIP,
               fulfillment_group_type = SKIP, price_catalog = SKIP,
               product_id = SKIP, shipping_method = SKIP, tax_class = SKIP,
               tax_lines = SKIP)
  @addon_parent_item_id = addon_parent_item_id unless addon_parent_item_id == SKIP
  @discounts = discounts unless discounts == SKIP
  @extended_attributes = extended_attributes unless extended_attributes == SKIP
  @external_identifier = external_identifier unless external_identifier == SKIP
  @fulfillment_group_type = fulfillment_group_type unless fulfillment_group_type == SKIP
  @id = id
  @origin_id = origin_id
  @price = price
  @price_catalog = price_catalog unless price_catalog == SKIP
  @product_attributes = product_attributes
  @product_id = product_id unless product_id == SKIP
  @shipping_method = shipping_method unless shipping_method == SKIP
  @status = status
  @tax_class = tax_class unless tax_class == SKIP
  @tax_lines = tax_lines unless tax_lines == SKIP
end

Instance Attribute Details

#addon_parent_item_idString

Represents the ID of this addon item parent.

Returns:

  • (String)


14
15
16
# File 'lib/new_store_api/models/sales_order_detail.rb', line 14

def addon_parent_item_id
  @addon_parent_item_id
end

#discountsArray[SalesOrderDiscount]

A list of applied discounts

Returns:



18
19
20
# File 'lib/new_store_api/models/sales_order_detail.rb', line 18

def discounts
  @discounts
end

#extended_attributesArray[SalesOrderExtendedAttribute]

Extended attributes of the sales order item.

Returns:



22
23
24
# File 'lib/new_store_api/models/sales_order_detail.rb', line 22

def extended_attributes
  @extended_attributes
end

#external_identifierSalesOrderExternalIdentifier

External identifier for the order item



26
27
28
# File 'lib/new_store_api/models/sales_order_detail.rb', line 26

def external_identifier
  @external_identifier
end

#fulfillment_group_typeFulfillmentEnum

The method by which the item was or will be fulfilled. This field is optional and is only populated when the capture path supplies it. For orders captured while the POS is offline (offline order sync), the value is null and the field is omitted from the response. To reliably identify cash-and-carry (in-store handover) orders, use the order-level fulfillment_type field (value in_store_purchase) rather than relying on this item-level field.

Returns:



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

def fulfillment_group_type
  @fulfillment_group_type
end

#idString

Order item UUID

Returns:

  • (String)


40
41
42
# File 'lib/new_store_api/models/sales_order_detail.rb', line 40

def id
  @id
end

#origin_idString

If the origin of the order is 'newstore', this should be the order item identifier. If the order originated in an external system, it should be the identifier from the external system.

Returns:

  • (String)


46
47
48
# File 'lib/new_store_api/models/sales_order_detail.rb', line 46

def origin_id
  @origin_id
end

#priceSalesOrderPrice1

The response for retrieving price information.

Returns:



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

def price
  @price
end

#price_catalogFloat

The catalog price of the item.

Returns:

  • (Float)


54
55
56
# File 'lib/new_store_api/models/sales_order_detail.rb', line 54

def price_catalog
  @price_catalog
end

#product_attributesSalesOrderProductAttributes

Additional product-related information.



58
59
60
# File 'lib/new_store_api/models/sales_order_detail.rb', line 58

def product_attributes
  @product_attributes
end

#product_idString

Product ID for order item.

Returns:

  • (String)


62
63
64
# File 'lib/new_store_api/models/sales_order_detail.rb', line 62

def product_id
  @product_id
end

#shipping_methodString

The shipping method, if applicable

Returns:

  • (String)


66
67
68
# File 'lib/new_store_api/models/sales_order_detail.rb', line 66

def shipping_method
  @shipping_method
end

#statusSalesOrderItemStatusEnum

Current status of the order item. 'pending' means the item is in the grace period, 'on_hold' means the item couldn't be fulfilled and is in a conflict status.



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

def status
  @status
end

#tax_classString

The tax classification code of the item.

Returns:

  • (String)


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

def tax_class
  @tax_class
end

#tax_linesArray[SalesOrderTaxLine]

Detailed tax information.

Returns:



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

def tax_lines
  @tax_lines
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
188
189
190
191
192
193
194
195
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
# File 'lib/new_store_api/models/sales_order_detail.rb', line 152

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : nil
  origin_id = hash.key?('origin_id') ? hash['origin_id'] : nil
  price = SalesOrderPrice1.from_hash(hash['price']) if hash['price']
  product_attributes = SalesOrderProductAttributes.from_hash(hash['product_attributes']) if
    hash['product_attributes']
  status = hash.key?('status') ? hash['status'] : nil
  addon_parent_item_id =
    hash.key?('addon_parent_item_id') ? hash['addon_parent_item_id'] : SKIP
  # Parameter is an array, so we need to iterate through it
  discounts = nil
  unless hash['discounts'].nil?
    discounts = []
    hash['discounts'].each do |structure|
      discounts << (SalesOrderDiscount.from_hash(structure) if structure)
    end
  end

  discounts = SKIP unless hash.key?('discounts')
  # 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')
  external_identifier = SalesOrderExternalIdentifier.from_hash(hash['external_identifier']) if
    hash['external_identifier']
  fulfillment_group_type =
    hash.key?('fulfillment_group_type') ? hash['fulfillment_group_type'] : SKIP
  price_catalog = hash.key?('price_catalog') ? hash['price_catalog'] : SKIP
  product_id = hash.key?('product_id') ? hash['product_id'] : SKIP
  shipping_method =
    hash.key?('shipping_method') ? hash['shipping_method'] : SKIP
  tax_class = hash.key?('tax_class') ? hash['tax_class'] : SKIP
  # Parameter is an array, so we need to iterate through it
  tax_lines = nil
  unless hash['tax_lines'].nil?
    tax_lines = []
    hash['tax_lines'].each do |structure|
      tax_lines << (SalesOrderTaxLine.from_hash(structure) if structure)
    end
  end

  tax_lines = SKIP unless hash.key?('tax_lines')

  # Create object from extracted values.
  SalesOrderDetail.new(id,
                       origin_id,
                       price,
                       product_attributes,
                       status,
                       addon_parent_item_id,
                       discounts,
                       extended_attributes,
                       external_identifier,
                       fulfillment_group_type,
                       price_catalog,
                       product_id,
                       shipping_method,
                       tax_class,
                       tax_lines)
end

.namesObject

A mapping from model property names to API property names.



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/new_store_api/models/sales_order_detail.rb', line 83

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['addon_parent_item_id'] = 'addon_parent_item_id'
  @_hash['discounts'] = 'discounts'
  @_hash['extended_attributes'] = 'extended_attributes'
  @_hash['external_identifier'] = 'external_identifier'
  @_hash['fulfillment_group_type'] = 'fulfillment_group_type'
  @_hash['id'] = 'id'
  @_hash['origin_id'] = 'origin_id'
  @_hash['price'] = 'price'
  @_hash['price_catalog'] = 'price_catalog'
  @_hash['product_attributes'] = 'product_attributes'
  @_hash['product_id'] = 'product_id'
  @_hash['shipping_method'] = 'shipping_method'
  @_hash['status'] = 'status'
  @_hash['tax_class'] = 'tax_class'
  @_hash['tax_lines'] = 'tax_lines'
  @_hash
end

.nullablesObject

An array for nullable fields



120
121
122
123
124
125
# File 'lib/new_store_api/models/sales_order_detail.rb', line 120

def self.nullables
  %w[
    extended_attributes
    fulfillment_group_type
  ]
end

.optionalsObject

An array for optional fields



104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/new_store_api/models/sales_order_detail.rb', line 104

def self.optionals
  %w[
    addon_parent_item_id
    discounts
    extended_attributes
    external_identifier
    fulfillment_group_type
    price_catalog
    product_id
    shipping_method
    tax_class
    tax_lines
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



235
236
237
238
239
240
241
242
243
244
245
# File 'lib/new_store_api/models/sales_order_detail.rb', line 235

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} addon_parent_item_id: #{@addon_parent_item_id.inspect}, discounts:"\
  " #{@discounts.inspect}, extended_attributes: #{@extended_attributes.inspect},"\
  " external_identifier: #{@external_identifier.inspect}, fulfillment_group_type:"\
  " #{@fulfillment_group_type.inspect}, id: #{@id.inspect}, origin_id: #{@origin_id.inspect},"\
  " price: #{@price.inspect}, price_catalog: #{@price_catalog.inspect}, product_attributes:"\
  " #{@product_attributes.inspect}, product_id: #{@product_id.inspect}, shipping_method:"\
  " #{@shipping_method.inspect}, status: #{@status.inspect}, tax_class: #{@tax_class.inspect},"\
  " tax_lines: #{@tax_lines.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



223
224
225
226
227
228
229
230
231
232
# File 'lib/new_store_api/models/sales_order_detail.rb', line 223

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} addon_parent_item_id: #{@addon_parent_item_id}, discounts: #{@discounts},"\
  " extended_attributes: #{@extended_attributes}, external_identifier:"\
  " #{@external_identifier}, fulfillment_group_type: #{@fulfillment_group_type}, id: #{@id},"\
  " origin_id: #{@origin_id}, price: #{@price}, price_catalog: #{@price_catalog},"\
  " product_attributes: #{@product_attributes}, product_id: #{@product_id}, shipping_method:"\
  " #{@shipping_method}, status: #{@status}, tax_class: #{@tax_class}, tax_lines:"\
  " #{@tax_lines}>"
end