Class: NewStoreApi::ReverseCalculationQuotationItemDto

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

Overview

ReverseCalculationQuotationItemDto 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(currency_consumer = nil, item_price = nil, price_line_item = nil, price_net = nil, price_tax = nil, quantity = nil, shipping_address = nil, shipping_origin = nil, tax_class = nil, tax_method = nil, tax_rates = nil, type = nil, consumer_uuid = SKIP, extended_attributes = SKIP, handling_charges = SKIP, id = SKIP, product_id = SKIP, product_name = SKIP, product_sku = SKIP) ⇒ ReverseCalculationQuotationItemDto

Returns a new instance of ReverseCalculationQuotationItemDto.



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

def initialize(currency_consumer = nil, item_price = nil,
               price_line_item = nil, price_net = nil, price_tax = nil,
               quantity = nil, shipping_address = nil,
               shipping_origin = nil, tax_class = nil, tax_method = nil,
               tax_rates = nil, type = nil, consumer_uuid = SKIP,
               extended_attributes = SKIP, handling_charges = SKIP,
               id = SKIP, product_id = SKIP, product_name = SKIP,
               product_sku = SKIP)
  @consumer_uuid = consumer_uuid unless consumer_uuid == SKIP
  @currency_consumer = currency_consumer
  @extended_attributes = extended_attributes unless extended_attributes == SKIP
  @handling_charges = handling_charges unless handling_charges == SKIP
  @id = id unless id == SKIP
  @item_price = item_price
  @price_line_item = price_line_item
  @price_net = price_net
  @price_tax = price_tax
  @product_id = product_id unless product_id == SKIP
  @product_name = product_name unless product_name == SKIP
  @product_sku = product_sku unless product_sku == SKIP
  @quantity = quantity
  @shipping_address = shipping_address
  @shipping_origin = shipping_origin
  @tax_class = tax_class
  @tax_method = tax_method
  @tax_rates = tax_rates
  @type = type
end

Instance Attribute Details

#consumer_uuidString

UUID of the consumer.

Returns:

  • (String)


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

def consumer_uuid
  @consumer_uuid
end

#currency_consumerString

ISO 4217 currency code shown and billed to the consumer. Determines the minor-unit exponent used for all monetary fields (e.g. USD=2, JPY=0). Must be identical across all items.

Returns:

  • (String)


20
21
22
# File 'lib/new_store_api/models/reverse_calculation_quotation_item_dto.rb', line 20

def currency_consumer
  @currency_consumer
end

#extended_attributesArray[ExtAttrResource]

The item's list of extended attributes.

Returns:



24
25
26
# File 'lib/new_store_api/models/reverse_calculation_quotation_item_dto.rb', line 24

def extended_attributes
  @extended_attributes
end

#handling_chargesInteger

Cost of handling. Expressed in the currency's minor unit.

Returns:

  • (Integer)


28
29
30
# File 'lib/new_store_api/models/reverse_calculation_quotation_item_dto.rb', line 28

def handling_charges
  @handling_charges
end

#idString

Unique identifier of the item.

Returns:

  • (String)


32
33
34
# File 'lib/new_store_api/models/reverse_calculation_quotation_item_dto.rb', line 32

def id
  @id
end

#item_priceInteger

Price per quantity 1 of the item, can be incl. or excl. tax depending on tax_method. Expressed in the currency's minor unit.

Returns:

  • (Integer)


37
38
39
# File 'lib/new_store_api/models/reverse_calculation_quotation_item_dto.rb', line 37

def item_price
  @item_price
end

#price_line_itemInteger

Gross price for the total quantity of the line item, after all discounts. Expressed in the currency's minor unit.

Returns:

  • (Integer)


42
43
44
# File 'lib/new_store_api/models/reverse_calculation_quotation_item_dto.rb', line 42

def price_line_item
  @price_line_item
end

#price_netInteger

Net price for total quantity of line item, after applying all discounts. Expressed in the currency's minor unit.

Returns:

  • (Integer)


47
48
49
# File 'lib/new_store_api/models/reverse_calculation_quotation_item_dto.rb', line 47

def price_net
  @price_net
end

#price_taxInteger

Total amount of tax added to the net price, after appplying all discounts. Expressed in the currency's minor unit.

Returns:

  • (Integer)


52
53
54
# File 'lib/new_store_api/models/reverse_calculation_quotation_item_dto.rb', line 52

def price_tax
  @price_tax
end

#product_idString

Unique identifier of the product.

Returns:

  • (String)


56
57
58
# File 'lib/new_store_api/models/reverse_calculation_quotation_item_dto.rb', line 56

def product_id
  @product_id
end

#product_nameString

Human-readable name of the product.

Returns:

  • (String)


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

def product_name
  @product_name
end

#product_skuString

SKU of the product.

Returns:

  • (String)


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

def product_sku
  @product_sku
end

#quantityInteger

Item quantity. Positive number for sold items and negative number for returned items

Returns:

  • (Integer)


69
70
71
# File 'lib/new_store_api/models/reverse_calculation_quotation_item_dto.rb', line 69

def quantity
  @quantity
end

#shipping_addressTransactionAddressDto

Consumer's shipping address.



73
74
75
# File 'lib/new_store_api/models/reverse_calculation_quotation_item_dto.rb', line 73

def shipping_address
  @shipping_address
end

#shipping_originTransactionAddressDto

The origin of goods address, e.g. physical address of a store.



77
78
79
# File 'lib/new_store_api/models/reverse_calculation_quotation_item_dto.rb', line 77

def shipping_origin
  @shipping_origin
end

#tax_classString

Tax classification identifier for the line item.

Returns:

  • (String)


81
82
83
# File 'lib/new_store_api/models/reverse_calculation_quotation_item_dto.rb', line 81

def tax_class
  @tax_class
end

#tax_methodSalesOrderTaxMethodEnum

Tax classification identifier for the line item.



85
86
87
# File 'lib/new_store_api/models/reverse_calculation_quotation_item_dto.rb', line 85

def tax_method
  @tax_method
end

#tax_ratesArray[QuotationTaxRateDto]

All applied tax percent values and tax amounts for total quantity of line item (usually more than one rate per line item).

Returns:



90
91
92
# File 'lib/new_store_api/models/reverse_calculation_quotation_item_dto.rb', line 90

def tax_rates
  @tax_rates
end

#typeItemTypeEnum

All applied tax percent values and tax amounts for total quantity of line item (usually more than one rate per line item).

Returns:



95
96
97
# File 'lib/new_store_api/models/reverse_calculation_quotation_item_dto.rb', line 95

def type
  @type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/new_store_api/models/reverse_calculation_quotation_item_dto.rb', line 170

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  currency_consumer =
    hash.key?('currency_consumer') ? hash['currency_consumer'] : nil
  item_price = hash.key?('item_price') ? hash['item_price'] : nil
  price_line_item =
    hash.key?('price_line_item') ? hash['price_line_item'] : nil
  price_net = hash.key?('price_net') ? hash['price_net'] : nil
  price_tax = hash.key?('price_tax') ? hash['price_tax'] : nil
  quantity = hash.key?('quantity') ? hash['quantity'] : nil
  shipping_address = TransactionAddressDto.from_hash(hash['shipping_address']) if
    hash['shipping_address']
  shipping_origin = TransactionAddressDto.from_hash(hash['shipping_origin']) if
    hash['shipping_origin']
  tax_class = hash.key?('tax_class') ? hash['tax_class'] : nil
  tax_method = hash.key?('tax_method') ? hash['tax_method'] : nil
  # Parameter is an array, so we need to iterate through it
  tax_rates = nil
  unless hash['tax_rates'].nil?
    tax_rates = []
    hash['tax_rates'].each do |structure|
      tax_rates << (QuotationTaxRateDto.from_hash(structure) if structure)
    end
  end

  tax_rates = nil unless hash.key?('tax_rates')
  type = hash.key?('type') ? hash['type'] : nil
  consumer_uuid = hash.key?('consumer_uuid') ? hash['consumer_uuid'] : 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 << (ExtAttrResource.from_hash(structure) if structure)
    end
  end

  extended_attributes = SKIP unless hash.key?('extended_attributes')
  handling_charges =
    hash.key?('handling_charges') ? hash['handling_charges'] : SKIP
  id = hash.key?('id') ? hash['id'] : SKIP
  product_id = hash.key?('product_id') ? hash['product_id'] : SKIP
  product_name = hash.key?('product_name') ? hash['product_name'] : SKIP
  product_sku = hash.key?('product_sku') ? hash['product_sku'] : SKIP

  # Create object from extracted values.
  ReverseCalculationQuotationItemDto.new(currency_consumer,
                                         item_price,
                                         price_line_item,
                                         price_net,
                                         price_tax,
                                         quantity,
                                         shipping_address,
                                         shipping_origin,
                                         tax_class,
                                         tax_method,
                                         tax_rates,
                                         type,
                                         consumer_uuid,
                                         extended_attributes,
                                         handling_charges,
                                         id,
                                         product_id,
                                         product_name,
                                         product_sku)
end

.namesObject

A mapping from model property names to API property names.



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/new_store_api/models/reverse_calculation_quotation_item_dto.rb', line 98

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['consumer_uuid'] = 'consumer_uuid'
  @_hash['currency_consumer'] = 'currency_consumer'
  @_hash['extended_attributes'] = 'extended_attributes'
  @_hash['handling_charges'] = 'handling_charges'
  @_hash['id'] = 'id'
  @_hash['item_price'] = 'item_price'
  @_hash['price_line_item'] = 'price_line_item'
  @_hash['price_net'] = 'price_net'
  @_hash['price_tax'] = 'price_tax'
  @_hash['product_id'] = 'product_id'
  @_hash['product_name'] = 'product_name'
  @_hash['product_sku'] = 'product_sku'
  @_hash['quantity'] = 'quantity'
  @_hash['shipping_address'] = 'shipping_address'
  @_hash['shipping_origin'] = 'shipping_origin'
  @_hash['tax_class'] = 'tax_class'
  @_hash['tax_method'] = 'tax_method'
  @_hash['tax_rates'] = 'tax_rates'
  @_hash['type'] = 'type'
  @_hash
end

.nullablesObject

An array for nullable fields



136
137
138
# File 'lib/new_store_api/models/reverse_calculation_quotation_item_dto.rb', line 136

def self.nullables
  []
end

.optionalsObject

An array for optional fields



123
124
125
126
127
128
129
130
131
132
133
# File 'lib/new_store_api/models/reverse_calculation_quotation_item_dto.rb', line 123

def self.optionals
  %w[
    consumer_uuid
    extended_attributes
    handling_charges
    id
    product_id
    product_name
    product_sku
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



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

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.currency_consumer,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.item_price,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.price_line_item,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.price_net,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.price_tax,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.quantity,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.shipping_address,
                              ->(val) { TransactionAddressDto.validate(val) },
                              is_model_hash: true) and
        APIHelper.valid_type?(value.shipping_origin,
                              ->(val) { TransactionAddressDto.validate(val) },
                              is_model_hash: true) and
        APIHelper.valid_type?(value.tax_class,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.tax_method,
                              ->(val) { SalesOrderTaxMethodEnum.validate(val) }) and
        APIHelper.valid_type?(value.tax_rates,
                              ->(val) { QuotationTaxRateDto.validate(val) },
                              is_model_hash: true,
                              is_inner_model_hash: true) and
        APIHelper.valid_type?(value.type,
                              ->(val) { ItemTypeEnum.validate(val) })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['currency_consumer'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['item_price'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['price_line_item'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['price_net'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['price_tax'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['quantity'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['shipping_address'],
                            ->(val) { TransactionAddressDto.validate(val) },
                            is_model_hash: true) and
      APIHelper.valid_type?(value['shipping_origin'],
                            ->(val) { TransactionAddressDto.validate(val) },
                            is_model_hash: true) and
      APIHelper.valid_type?(value['tax_class'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['tax_method'],
                            ->(val) { SalesOrderTaxMethodEnum.validate(val) }) and
      APIHelper.valid_type?(value['tax_rates'],
                            ->(val) { QuotationTaxRateDto.validate(val) },
                            is_model_hash: true,
                            is_inner_model_hash: true) and
      APIHelper.valid_type?(value['type'],
                            ->(val) { ItemTypeEnum.validate(val) })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



322
323
324
325
326
327
328
329
330
331
332
333
334
# File 'lib/new_store_api/models/reverse_calculation_quotation_item_dto.rb', line 322

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} consumer_uuid: #{@consumer_uuid.inspect}, currency_consumer:"\
  " #{@currency_consumer.inspect}, extended_attributes: #{@extended_attributes.inspect},"\
  " handling_charges: #{@handling_charges.inspect}, id: #{@id.inspect}, item_price:"\
  " #{@item_price.inspect}, price_line_item: #{@price_line_item.inspect}, price_net:"\
  " #{@price_net.inspect}, price_tax: #{@price_tax.inspect}, product_id:"\
  " #{@product_id.inspect}, product_name: #{@product_name.inspect}, product_sku:"\
  " #{@product_sku.inspect}, quantity: #{@quantity.inspect}, shipping_address:"\
  " #{@shipping_address.inspect}, shipping_origin: #{@shipping_origin.inspect}, tax_class:"\
  " #{@tax_class.inspect}, tax_method: #{@tax_method.inspect}, tax_rates:"\
  " #{@tax_rates.inspect}, type: #{@type.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



310
311
312
313
314
315
316
317
318
319
# File 'lib/new_store_api/models/reverse_calculation_quotation_item_dto.rb', line 310

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} consumer_uuid: #{@consumer_uuid}, currency_consumer: #{@currency_consumer},"\
  " extended_attributes: #{@extended_attributes}, handling_charges: #{@handling_charges}, id:"\
  " #{@id}, item_price: #{@item_price}, price_line_item: #{@price_line_item}, price_net:"\
  " #{@price_net}, price_tax: #{@price_tax}, product_id: #{@product_id}, product_name:"\
  " #{@product_name}, product_sku: #{@product_sku}, quantity: #{@quantity}, shipping_address:"\
  " #{@shipping_address}, shipping_origin: #{@shipping_origin}, tax_class: #{@tax_class},"\
  " tax_method: #{@tax_method}, tax_rates: #{@tax_rates}, type: #{@type}>"
end