dear-inventory-ruby 0.2.3 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +11 -4
- data/docs/InventoryApi.md +158 -0
- data/docs/Sale.md +99 -0
- data/docs/SaleInvoice.md +11 -3
- data/docs/SaleInvoicePartial.md +41 -0
- data/docs/SaleInvoices.md +1 -1
- data/docs/SaleItem.md +77 -0
- data/docs/SaleList.md +21 -0
- data/docs/SalePaymentLine.md +29 -0
- data/lib/dear-inventory-ruby/api/inventory_api.rb +171 -0
- data/lib/dear-inventory-ruby/models/sale.rb +615 -0
- data/lib/dear-inventory-ruby/models/sale_invoice.rb +55 -21
- data/lib/dear-inventory-ruby/models/sale_invoice_partial.rb +351 -0
- data/lib/dear-inventory-ruby/models/sale_invoices.rb +1 -1
- data/lib/dear-inventory-ruby/models/sale_item.rb +507 -0
- data/lib/dear-inventory-ruby/models/sale_list.rb +229 -0
- data/lib/dear-inventory-ruby/models/sale_payment_line.rb +267 -0
- data/lib/dear-inventory-ruby/version.rb +1 -1
- data/lib/dear-inventory-ruby.rb +5 -0
- data/spec/.DS_Store +0 -0
- data/spec/api/inventory_api_spec.rb +41 -0
- data/spec/models/sale_invoice_partial_spec.rb +113 -0
- data/spec/models/sale_invoice_spec.rb +30 -6
- data/spec/models/sale_item_spec.rb +221 -0
- data/spec/models/sale_list_spec.rb +53 -0
- data/spec/models/sale_payment_line_spec.rb +77 -0
- data/spec/models/sale_spec.rb +287 -0
- metadata +27 -6
@@ -0,0 +1,615 @@
|
|
1
|
+
=begin
|
2
|
+
#DEAR Inventory API
|
3
|
+
|
4
|
+
#This specifing endpoints for DEAR Inventory API
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 2.0.0
|
7
|
+
Contact: nnhansg@gmail.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module DearInventoryRuby
|
16
|
+
class Sale
|
17
|
+
# Unique DEAR Sale ID. Required for PUT
|
18
|
+
attr_accessor :id
|
19
|
+
|
20
|
+
# Customer name
|
21
|
+
attr_accessor :customer
|
22
|
+
|
23
|
+
# Customer identifier
|
24
|
+
attr_accessor :customer_id
|
25
|
+
|
26
|
+
# Customer Contact name
|
27
|
+
attr_accessor :contact
|
28
|
+
|
29
|
+
# Customer Contact phone
|
30
|
+
attr_accessor :phone
|
31
|
+
|
32
|
+
# Customer Contact email
|
33
|
+
attr_accessor :email
|
34
|
+
|
35
|
+
# Account code used by default for invoice lines when no revenue account is defined on Product. By default it is equal to Customer Sale account
|
36
|
+
attr_accessor :default_account
|
37
|
+
|
38
|
+
# True if there is no quote in the sale
|
39
|
+
attr_accessor :skip_quote
|
40
|
+
|
41
|
+
attr_accessor :billing_address
|
42
|
+
|
43
|
+
attr_accessor :shipping_address
|
44
|
+
|
45
|
+
# Shipping Notes
|
46
|
+
attr_accessor :shipping_notes
|
47
|
+
|
48
|
+
# 3 character currency code of Base Currency defined in General Settings on the moment when Sale was created.
|
49
|
+
attr_accessor :base_currency
|
50
|
+
|
51
|
+
# 3 character currency code of customer Currency defined in Customer card at the moment when customer is selected for the Sale.
|
52
|
+
attr_accessor :customer_currency
|
53
|
+
|
54
|
+
# Default Tax Rule name selected for Sale
|
55
|
+
attr_accessor :tax_rule
|
56
|
+
|
57
|
+
# Inclusive or Exclusive
|
58
|
+
attr_accessor :tax_calculation
|
59
|
+
|
60
|
+
# Payment terms name
|
61
|
+
attr_accessor :terms
|
62
|
+
|
63
|
+
# Price Tier name selected for Sale
|
64
|
+
attr_accessor :price_tier
|
65
|
+
|
66
|
+
# Date when shipment is due
|
67
|
+
attr_accessor :ship_by
|
68
|
+
|
69
|
+
# Default location to pick stock from
|
70
|
+
attr_accessor :location
|
71
|
+
|
72
|
+
# Date when task was created
|
73
|
+
attr_accessor :sale_order_date
|
74
|
+
|
75
|
+
# UTC Time
|
76
|
+
attr_accessor :last_modified_on
|
77
|
+
|
78
|
+
# Custom Sale note
|
79
|
+
attr_accessor :note
|
80
|
+
|
81
|
+
# Reference number used by customer to identify this sale. Could be a purchase order number generated by customer.
|
82
|
+
attr_accessor :customer_reference
|
83
|
+
|
84
|
+
# COGS amount in base currency
|
85
|
+
attr_accessor :cogs_amount
|
86
|
+
|
87
|
+
# Sale Status, see possible values
|
88
|
+
attr_accessor :status
|
89
|
+
|
90
|
+
# Pick status. Possible Values are VOIDED, NOT AVAILABLE, PICKED, PICKING , NOT PICKED , PARTIALLY PICKED
|
91
|
+
attr_accessor :combined_picking_status
|
92
|
+
|
93
|
+
# Pack status. Possible Values are VOIDED, NOT AVAILABLE, PACKED, PACKING, NOT PACKED, PARTIALLY PACKED
|
94
|
+
attr_accessor :combined_packing_status
|
95
|
+
|
96
|
+
# Ship status. Possible Values are VOIDED, NOT AVAILABLE, SHIPPED, SHIPPING , NOT SHIPPED , PARTIALLY SHIPPED
|
97
|
+
attr_accessor :combined_shipping_status
|
98
|
+
|
99
|
+
# Fulfilment status. Possible Values are FULFILLED, PARTIALLY FULFILLED, NOT AVAILABLE, NOT FULFILLED, VOIDED
|
100
|
+
attr_accessor :ful_filment_status
|
101
|
+
|
102
|
+
# Invoice status. Possible Values are INVOICED, INVOICED / CREDITED, NOT AVAILABLE, NOT INVOICED, PARTIALLY INVOICED, PARTIALLY INVOICED / CREDITED
|
103
|
+
attr_accessor :combined_invoice_status
|
104
|
+
|
105
|
+
# Payment status. Possible Values are NOT REFUNDED, PREPAID, PARTIALLY PAID, UNPAID, PAID, VOIDED
|
106
|
+
attr_accessor :combined_payment_status
|
107
|
+
|
108
|
+
# Tracking Numbers
|
109
|
+
attr_accessor :combined_tracking_numbers
|
110
|
+
|
111
|
+
# Name of Carrier/shipping method
|
112
|
+
attr_accessor :carrier
|
113
|
+
|
114
|
+
# Conversion Rate expressed as number of Base currency units for one Customer currency unit
|
115
|
+
attr_accessor :currency_rate
|
116
|
+
|
117
|
+
# Sales representative name
|
118
|
+
attr_accessor :sales_representative
|
119
|
+
|
120
|
+
# Type of sale Simple Sale or Advanced Sale, Service Sale
|
121
|
+
attr_accessor :type
|
122
|
+
|
123
|
+
# Source of the sale. read-only field
|
124
|
+
attr_accessor :source_channel
|
125
|
+
|
126
|
+
# Custom field that is only available in API and allows to set arbitrary value for the sale for later search and any custom logic
|
127
|
+
attr_accessor :external_id
|
128
|
+
|
129
|
+
# true when it is service-only sale
|
130
|
+
attr_accessor :service_only
|
131
|
+
|
132
|
+
attr_accessor :quote
|
133
|
+
|
134
|
+
attr_accessor :order
|
135
|
+
|
136
|
+
# Sale Invoices
|
137
|
+
attr_accessor :invoices
|
138
|
+
|
139
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
140
|
+
def self.attribute_map
|
141
|
+
{
|
142
|
+
:'id' => :'ID',
|
143
|
+
:'customer' => :'Customer',
|
144
|
+
:'customer_id' => :'CustomerID',
|
145
|
+
:'contact' => :'Contact',
|
146
|
+
:'phone' => :'Phone',
|
147
|
+
:'email' => :'Email',
|
148
|
+
:'default_account' => :'DefaultAccount',
|
149
|
+
:'skip_quote' => :'SkipQuote',
|
150
|
+
:'billing_address' => :'BillingAddress',
|
151
|
+
:'shipping_address' => :'ShippingAddress',
|
152
|
+
:'shipping_notes' => :'ShippingNotes',
|
153
|
+
:'base_currency' => :'BaseCurrency',
|
154
|
+
:'customer_currency' => :'CustomerCurrency',
|
155
|
+
:'tax_rule' => :'TaxRule',
|
156
|
+
:'tax_calculation' => :'TaxCalculation',
|
157
|
+
:'terms' => :'Terms',
|
158
|
+
:'price_tier' => :'PriceTier',
|
159
|
+
:'ship_by' => :'ShipBy',
|
160
|
+
:'location' => :'Location',
|
161
|
+
:'sale_order_date' => :'SaleOrderDate',
|
162
|
+
:'last_modified_on' => :'LastModifiedOn',
|
163
|
+
:'note' => :'Note',
|
164
|
+
:'customer_reference' => :'CustomerReference',
|
165
|
+
:'cogs_amount' => :'COGSAmount',
|
166
|
+
:'status' => :'Status',
|
167
|
+
:'combined_picking_status' => :'CombinedPickingStatus',
|
168
|
+
:'combined_packing_status' => :'CombinedPackingStatus',
|
169
|
+
:'combined_shipping_status' => :'CombinedShippingStatus',
|
170
|
+
:'ful_filment_status' => :'FulFilmentStatus',
|
171
|
+
:'combined_invoice_status' => :'CombinedInvoiceStatus',
|
172
|
+
:'combined_payment_status' => :'CombinedPaymentStatus',
|
173
|
+
:'combined_tracking_numbers' => :'CombinedTrackingNumbers',
|
174
|
+
:'carrier' => :'Carrier',
|
175
|
+
:'currency_rate' => :'CurrencyRate',
|
176
|
+
:'sales_representative' => :'SalesRepresentative',
|
177
|
+
:'type' => :'Type',
|
178
|
+
:'source_channel' => :'SourceChannel',
|
179
|
+
:'external_id' => :'ExternalID',
|
180
|
+
:'service_only' => :'ServiceOnly',
|
181
|
+
:'quote' => :'Quote',
|
182
|
+
:'order' => :'Order',
|
183
|
+
:'invoices' => :'Invoices'
|
184
|
+
}
|
185
|
+
end
|
186
|
+
|
187
|
+
# Attribute type mapping.
|
188
|
+
def self.openapi_types
|
189
|
+
{
|
190
|
+
:'id' => :'String',
|
191
|
+
:'customer' => :'String',
|
192
|
+
:'customer_id' => :'String',
|
193
|
+
:'contact' => :'String',
|
194
|
+
:'phone' => :'String',
|
195
|
+
:'email' => :'String',
|
196
|
+
:'default_account' => :'String',
|
197
|
+
:'skip_quote' => :'Boolean',
|
198
|
+
:'billing_address' => :'Address',
|
199
|
+
:'shipping_address' => :'ShippingAddress',
|
200
|
+
:'shipping_notes' => :'String',
|
201
|
+
:'base_currency' => :'String',
|
202
|
+
:'customer_currency' => :'String',
|
203
|
+
:'tax_rule' => :'String',
|
204
|
+
:'tax_calculation' => :'String',
|
205
|
+
:'terms' => :'String',
|
206
|
+
:'price_tier' => :'String',
|
207
|
+
:'ship_by' => :'Date',
|
208
|
+
:'location' => :'String',
|
209
|
+
:'sale_order_date' => :'Date',
|
210
|
+
:'last_modified_on' => :'Date',
|
211
|
+
:'note' => :'String',
|
212
|
+
:'customer_reference' => :'String',
|
213
|
+
:'cogs_amount' => :'Float',
|
214
|
+
:'status' => :'String',
|
215
|
+
:'combined_picking_status' => :'String',
|
216
|
+
:'combined_packing_status' => :'String',
|
217
|
+
:'combined_shipping_status' => :'String',
|
218
|
+
:'ful_filment_status' => :'String',
|
219
|
+
:'combined_invoice_status' => :'String',
|
220
|
+
:'combined_payment_status' => :'String',
|
221
|
+
:'combined_tracking_numbers' => :'String',
|
222
|
+
:'carrier' => :'String',
|
223
|
+
:'currency_rate' => :'Float',
|
224
|
+
:'sales_representative' => :'String',
|
225
|
+
:'type' => :'String',
|
226
|
+
:'source_channel' => :'String',
|
227
|
+
:'external_id' => :'String',
|
228
|
+
:'service_only' => :'String',
|
229
|
+
:'quote' => :'SaleQuote',
|
230
|
+
:'order' => :'SaleOrder',
|
231
|
+
:'invoices' => :'Array<SaleInvoice>'
|
232
|
+
}
|
233
|
+
end
|
234
|
+
|
235
|
+
# List of attributes with nullable: true
|
236
|
+
def self.openapi_nullable
|
237
|
+
Set.new([
|
238
|
+
])
|
239
|
+
end
|
240
|
+
|
241
|
+
# Initializes the object
|
242
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
243
|
+
def initialize(attributes = {})
|
244
|
+
if (!attributes.is_a?(Hash))
|
245
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `DearInventoryRuby::Sale` initialize method"
|
246
|
+
end
|
247
|
+
|
248
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
249
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
250
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
251
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `DearInventoryRuby::Sale`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
252
|
+
end
|
253
|
+
h[k.to_sym] = v
|
254
|
+
}
|
255
|
+
|
256
|
+
if attributes.key?(:'id')
|
257
|
+
self.id = attributes[:'id']
|
258
|
+
end
|
259
|
+
|
260
|
+
if attributes.key?(:'customer')
|
261
|
+
self.customer = attributes[:'customer']
|
262
|
+
end
|
263
|
+
|
264
|
+
if attributes.key?(:'customer_id')
|
265
|
+
self.customer_id = attributes[:'customer_id']
|
266
|
+
end
|
267
|
+
|
268
|
+
if attributes.key?(:'contact')
|
269
|
+
self.contact = attributes[:'contact']
|
270
|
+
end
|
271
|
+
|
272
|
+
if attributes.key?(:'phone')
|
273
|
+
self.phone = attributes[:'phone']
|
274
|
+
end
|
275
|
+
|
276
|
+
if attributes.key?(:'email')
|
277
|
+
self.email = attributes[:'email']
|
278
|
+
end
|
279
|
+
|
280
|
+
if attributes.key?(:'default_account')
|
281
|
+
self.default_account = attributes[:'default_account']
|
282
|
+
end
|
283
|
+
|
284
|
+
if attributes.key?(:'skip_quote')
|
285
|
+
self.skip_quote = attributes[:'skip_quote']
|
286
|
+
end
|
287
|
+
|
288
|
+
if attributes.key?(:'billing_address')
|
289
|
+
self.billing_address = attributes[:'billing_address']
|
290
|
+
end
|
291
|
+
|
292
|
+
if attributes.key?(:'shipping_address')
|
293
|
+
self.shipping_address = attributes[:'shipping_address']
|
294
|
+
end
|
295
|
+
|
296
|
+
if attributes.key?(:'shipping_notes')
|
297
|
+
self.shipping_notes = attributes[:'shipping_notes']
|
298
|
+
end
|
299
|
+
|
300
|
+
if attributes.key?(:'base_currency')
|
301
|
+
self.base_currency = attributes[:'base_currency']
|
302
|
+
end
|
303
|
+
|
304
|
+
if attributes.key?(:'customer_currency')
|
305
|
+
self.customer_currency = attributes[:'customer_currency']
|
306
|
+
end
|
307
|
+
|
308
|
+
if attributes.key?(:'tax_rule')
|
309
|
+
self.tax_rule = attributes[:'tax_rule']
|
310
|
+
end
|
311
|
+
|
312
|
+
if attributes.key?(:'tax_calculation')
|
313
|
+
self.tax_calculation = attributes[:'tax_calculation']
|
314
|
+
end
|
315
|
+
|
316
|
+
if attributes.key?(:'terms')
|
317
|
+
self.terms = attributes[:'terms']
|
318
|
+
end
|
319
|
+
|
320
|
+
if attributes.key?(:'price_tier')
|
321
|
+
self.price_tier = attributes[:'price_tier']
|
322
|
+
end
|
323
|
+
|
324
|
+
if attributes.key?(:'ship_by')
|
325
|
+
self.ship_by = attributes[:'ship_by']
|
326
|
+
end
|
327
|
+
|
328
|
+
if attributes.key?(:'location')
|
329
|
+
self.location = attributes[:'location']
|
330
|
+
end
|
331
|
+
|
332
|
+
if attributes.key?(:'sale_order_date')
|
333
|
+
self.sale_order_date = attributes[:'sale_order_date']
|
334
|
+
end
|
335
|
+
|
336
|
+
if attributes.key?(:'last_modified_on')
|
337
|
+
self.last_modified_on = attributes[:'last_modified_on']
|
338
|
+
end
|
339
|
+
|
340
|
+
if attributes.key?(:'note')
|
341
|
+
self.note = attributes[:'note']
|
342
|
+
end
|
343
|
+
|
344
|
+
if attributes.key?(:'customer_reference')
|
345
|
+
self.customer_reference = attributes[:'customer_reference']
|
346
|
+
end
|
347
|
+
|
348
|
+
if attributes.key?(:'cogs_amount')
|
349
|
+
self.cogs_amount = attributes[:'cogs_amount']
|
350
|
+
end
|
351
|
+
|
352
|
+
if attributes.key?(:'status')
|
353
|
+
self.status = attributes[:'status']
|
354
|
+
end
|
355
|
+
|
356
|
+
if attributes.key?(:'combined_picking_status')
|
357
|
+
self.combined_picking_status = attributes[:'combined_picking_status']
|
358
|
+
end
|
359
|
+
|
360
|
+
if attributes.key?(:'combined_packing_status')
|
361
|
+
self.combined_packing_status = attributes[:'combined_packing_status']
|
362
|
+
end
|
363
|
+
|
364
|
+
if attributes.key?(:'combined_shipping_status')
|
365
|
+
self.combined_shipping_status = attributes[:'combined_shipping_status']
|
366
|
+
end
|
367
|
+
|
368
|
+
if attributes.key?(:'ful_filment_status')
|
369
|
+
self.ful_filment_status = attributes[:'ful_filment_status']
|
370
|
+
end
|
371
|
+
|
372
|
+
if attributes.key?(:'combined_invoice_status')
|
373
|
+
self.combined_invoice_status = attributes[:'combined_invoice_status']
|
374
|
+
end
|
375
|
+
|
376
|
+
if attributes.key?(:'combined_payment_status')
|
377
|
+
self.combined_payment_status = attributes[:'combined_payment_status']
|
378
|
+
end
|
379
|
+
|
380
|
+
if attributes.key?(:'combined_tracking_numbers')
|
381
|
+
self.combined_tracking_numbers = attributes[:'combined_tracking_numbers']
|
382
|
+
end
|
383
|
+
|
384
|
+
if attributes.key?(:'carrier')
|
385
|
+
self.carrier = attributes[:'carrier']
|
386
|
+
end
|
387
|
+
|
388
|
+
if attributes.key?(:'currency_rate')
|
389
|
+
self.currency_rate = attributes[:'currency_rate']
|
390
|
+
end
|
391
|
+
|
392
|
+
if attributes.key?(:'sales_representative')
|
393
|
+
self.sales_representative = attributes[:'sales_representative']
|
394
|
+
end
|
395
|
+
|
396
|
+
if attributes.key?(:'type')
|
397
|
+
self.type = attributes[:'type']
|
398
|
+
end
|
399
|
+
|
400
|
+
if attributes.key?(:'source_channel')
|
401
|
+
self.source_channel = attributes[:'source_channel']
|
402
|
+
end
|
403
|
+
|
404
|
+
if attributes.key?(:'external_id')
|
405
|
+
self.external_id = attributes[:'external_id']
|
406
|
+
end
|
407
|
+
|
408
|
+
if attributes.key?(:'service_only')
|
409
|
+
self.service_only = attributes[:'service_only']
|
410
|
+
end
|
411
|
+
|
412
|
+
if attributes.key?(:'quote')
|
413
|
+
self.quote = attributes[:'quote']
|
414
|
+
end
|
415
|
+
|
416
|
+
if attributes.key?(:'order')
|
417
|
+
self.order = attributes[:'order']
|
418
|
+
end
|
419
|
+
|
420
|
+
if attributes.key?(:'invoices')
|
421
|
+
if (value = attributes[:'invoices']).is_a?(Array)
|
422
|
+
self.invoices = value
|
423
|
+
end
|
424
|
+
end
|
425
|
+
end
|
426
|
+
|
427
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
428
|
+
# @return Array for valid properties with the reasons
|
429
|
+
def list_invalid_properties
|
430
|
+
invalid_properties = Array.new
|
431
|
+
invalid_properties
|
432
|
+
end
|
433
|
+
|
434
|
+
# Check to see if the all the properties in the model are valid
|
435
|
+
# @return true if the model is valid
|
436
|
+
def valid?
|
437
|
+
true
|
438
|
+
end
|
439
|
+
|
440
|
+
# Checks equality by comparing each attribute.
|
441
|
+
# @param [Object] Object to be compared
|
442
|
+
def ==(o)
|
443
|
+
return true if self.equal?(o)
|
444
|
+
self.class == o.class &&
|
445
|
+
id == o.id &&
|
446
|
+
customer == o.customer &&
|
447
|
+
customer_id == o.customer_id &&
|
448
|
+
contact == o.contact &&
|
449
|
+
phone == o.phone &&
|
450
|
+
email == o.email &&
|
451
|
+
default_account == o.default_account &&
|
452
|
+
skip_quote == o.skip_quote &&
|
453
|
+
billing_address == o.billing_address &&
|
454
|
+
shipping_address == o.shipping_address &&
|
455
|
+
shipping_notes == o.shipping_notes &&
|
456
|
+
base_currency == o.base_currency &&
|
457
|
+
customer_currency == o.customer_currency &&
|
458
|
+
tax_rule == o.tax_rule &&
|
459
|
+
tax_calculation == o.tax_calculation &&
|
460
|
+
terms == o.terms &&
|
461
|
+
price_tier == o.price_tier &&
|
462
|
+
ship_by == o.ship_by &&
|
463
|
+
location == o.location &&
|
464
|
+
sale_order_date == o.sale_order_date &&
|
465
|
+
last_modified_on == o.last_modified_on &&
|
466
|
+
note == o.note &&
|
467
|
+
customer_reference == o.customer_reference &&
|
468
|
+
cogs_amount == o.cogs_amount &&
|
469
|
+
status == o.status &&
|
470
|
+
combined_picking_status == o.combined_picking_status &&
|
471
|
+
combined_packing_status == o.combined_packing_status &&
|
472
|
+
combined_shipping_status == o.combined_shipping_status &&
|
473
|
+
ful_filment_status == o.ful_filment_status &&
|
474
|
+
combined_invoice_status == o.combined_invoice_status &&
|
475
|
+
combined_payment_status == o.combined_payment_status &&
|
476
|
+
combined_tracking_numbers == o.combined_tracking_numbers &&
|
477
|
+
carrier == o.carrier &&
|
478
|
+
currency_rate == o.currency_rate &&
|
479
|
+
sales_representative == o.sales_representative &&
|
480
|
+
type == o.type &&
|
481
|
+
source_channel == o.source_channel &&
|
482
|
+
external_id == o.external_id &&
|
483
|
+
service_only == o.service_only &&
|
484
|
+
quote == o.quote &&
|
485
|
+
order == o.order &&
|
486
|
+
invoices == o.invoices
|
487
|
+
end
|
488
|
+
|
489
|
+
# @see the `==` method
|
490
|
+
# @param [Object] Object to be compared
|
491
|
+
def eql?(o)
|
492
|
+
self == o
|
493
|
+
end
|
494
|
+
|
495
|
+
# Calculates hash code according to all attributes.
|
496
|
+
# @return [Integer] Hash code
|
497
|
+
def hash
|
498
|
+
[id, customer, customer_id, contact, phone, email, default_account, skip_quote, billing_address, shipping_address, shipping_notes, base_currency, customer_currency, tax_rule, tax_calculation, terms, price_tier, ship_by, location, sale_order_date, last_modified_on, note, customer_reference, cogs_amount, status, combined_picking_status, combined_packing_status, combined_shipping_status, ful_filment_status, combined_invoice_status, combined_payment_status, combined_tracking_numbers, carrier, currency_rate, sales_representative, type, source_channel, external_id, service_only, quote, order, invoices].hash
|
499
|
+
end
|
500
|
+
|
501
|
+
# Builds the object from hash
|
502
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
503
|
+
# @return [Object] Returns the model itself
|
504
|
+
def self.build_from_hash(attributes)
|
505
|
+
new.build_from_hash(attributes)
|
506
|
+
end
|
507
|
+
|
508
|
+
# Builds the object from hash
|
509
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
510
|
+
# @return [Object] Returns the model itself
|
511
|
+
def build_from_hash(attributes)
|
512
|
+
return nil unless attributes.is_a?(Hash)
|
513
|
+
self.class.openapi_types.each_pair do |key, type|
|
514
|
+
if type =~ /\AArray<(.*)>/i
|
515
|
+
# check to ensure the input is an array given that the attribute
|
516
|
+
# is documented as an array but the input is not
|
517
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
518
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
519
|
+
end
|
520
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
521
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
522
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
523
|
+
end
|
524
|
+
|
525
|
+
self
|
526
|
+
end
|
527
|
+
|
528
|
+
# Deserializes the data based on type
|
529
|
+
# @param string type Data type
|
530
|
+
# @param string value Value to be deserialized
|
531
|
+
# @return [Object] Deserialized data
|
532
|
+
def _deserialize(type, value)
|
533
|
+
case type.to_sym
|
534
|
+
when :DateTime
|
535
|
+
DateTime.parse(value)
|
536
|
+
when :Date
|
537
|
+
Date.parse(value)
|
538
|
+
when :String
|
539
|
+
value.to_s
|
540
|
+
when :Integer
|
541
|
+
value.to_i
|
542
|
+
when :Float
|
543
|
+
value.to_f
|
544
|
+
when :Boolean
|
545
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
546
|
+
true
|
547
|
+
else
|
548
|
+
false
|
549
|
+
end
|
550
|
+
when :Object
|
551
|
+
# generic object (usually a Hash), return directly
|
552
|
+
value
|
553
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
554
|
+
inner_type = Regexp.last_match[:inner_type]
|
555
|
+
value.map { |v| _deserialize(inner_type, v) }
|
556
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
557
|
+
k_type = Regexp.last_match[:k_type]
|
558
|
+
v_type = Regexp.last_match[:v_type]
|
559
|
+
{}.tap do |hash|
|
560
|
+
value.each do |k, v|
|
561
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
562
|
+
end
|
563
|
+
end
|
564
|
+
else # model
|
565
|
+
DearInventoryRuby.const_get(type).build_from_hash(value)
|
566
|
+
end
|
567
|
+
end
|
568
|
+
|
569
|
+
# Returns the string representation of the object
|
570
|
+
# @return [String] String presentation of the object
|
571
|
+
def to_s
|
572
|
+
to_hash.to_s
|
573
|
+
end
|
574
|
+
|
575
|
+
# to_body is an alias to to_hash (backward compatibility)
|
576
|
+
# @return [Hash] Returns the object in the form of hash
|
577
|
+
def to_body
|
578
|
+
to_hash
|
579
|
+
end
|
580
|
+
|
581
|
+
# Returns the object in the form of hash
|
582
|
+
# @return [Hash] Returns the object in the form of hash
|
583
|
+
def to_hash
|
584
|
+
hash = {}
|
585
|
+
self.class.attribute_map.each_pair do |attr, param|
|
586
|
+
value = self.send(attr)
|
587
|
+
if value.nil?
|
588
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
589
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
590
|
+
end
|
591
|
+
|
592
|
+
hash[param] = _to_hash(value)
|
593
|
+
end
|
594
|
+
hash
|
595
|
+
end
|
596
|
+
|
597
|
+
# Outputs non-array value in the form of hash
|
598
|
+
# For object, use to_hash. Otherwise, just return the value
|
599
|
+
# @param [Object] value Any valid value
|
600
|
+
# @return [Hash] Returns the value in the form of hash
|
601
|
+
def _to_hash(value)
|
602
|
+
if value.is_a?(Array)
|
603
|
+
value.compact.map { |v| _to_hash(v) }
|
604
|
+
elsif value.is_a?(Hash)
|
605
|
+
{}.tap do |hash|
|
606
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
607
|
+
end
|
608
|
+
elsif value.respond_to? :to_hash
|
609
|
+
value.to_hash
|
610
|
+
else
|
611
|
+
value
|
612
|
+
end
|
613
|
+
end
|
614
|
+
end
|
615
|
+
end
|