dear-inventory-ruby 0.2.4 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,507 @@
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 SaleItem
17
+ # Unique DEAR Sale identifier
18
+ attr_accessor :sale_id
19
+
20
+ # Sale Order number generated by DEAR
21
+ attr_accessor :order_number
22
+
23
+ # Current sale status. Possible values are values
24
+ attr_accessor :status
25
+
26
+ # Date when Sale Order was created
27
+ attr_accessor :order_date
28
+
29
+ # Date when Invoice was issued
30
+ attr_accessor :invoice_date
31
+
32
+ # Name of the customer
33
+ attr_accessor :customer
34
+
35
+ # Customer Identifier
36
+ attr_accessor :customer_id
37
+
38
+ # Invoice number generated by DEAR
39
+ attr_accessor :invoice_number
40
+
41
+ # Optional Customer Reference (typically customer Purchase order number) supplied by the customer for the sale
42
+ attr_accessor :customer_reference
43
+
44
+ # Total Invoice amount minus total Credit note amount in customer currency
45
+ attr_accessor :invoice_amount
46
+
47
+ # Total Paid amount minus Refunded amount in customer currency
48
+ attr_accessor :paid_amount
49
+
50
+ # Date when invoice is due according to selected payment terms
51
+ attr_accessor :invoice_due_date
52
+
53
+ # Date when shipment is due
54
+ attr_accessor :ship_by
55
+
56
+ # 3 digit Base currency code (as configured in General Settings)
57
+ attr_accessor :base_currency
58
+
59
+ # 3 digit Customer currency code
60
+ attr_accessor :customer_currency
61
+
62
+ # Credit note number generated by DEAR. Is empty unless credit note is created
63
+ attr_accessor :credit_note_number
64
+
65
+ # Date when the sale was last created/updated last time
66
+ attr_accessor :updated
67
+
68
+ # Sale Quote status. Possible Values are values
69
+ attr_accessor :quote_status
70
+
71
+ # Sale Order status. Possible Values are values
72
+ attr_accessor :order_status
73
+
74
+ # Pick status. Possible Values are VOIDED, NOT AVAILABLE, PICKED, PICKING , NOT PICKED , PARTIALLY PICKED
75
+ attr_accessor :combined_picking_status
76
+
77
+ # Pack status. Possible Values are VOIDED, NOT AVAILABLE, PACKED, PACKING, NOT PACKED, PARTIALLY PACKED
78
+ attr_accessor :combined_packing_status
79
+
80
+ # Ship status. Possible Values are VOIDED, NOT AVAILABLE, SHIPPED, SHIPPING , NOT SHIPPED , PARTIALLY SHIPPED
81
+ attr_accessor :combined_shipping_status
82
+
83
+ # Fulfilment status. Possible Values are FULFILLED, PARTIALLY FULFILLED, NOT AVAILABLE, NOT FULFILLED, VOIDED
84
+ attr_accessor :ful_filment_status
85
+
86
+ # Invoice status. Possible Values are VOIDED, DRAFT, AUTHORISED, NOT AVAILABLE, PAID
87
+ attr_accessor :combined_invoice_status
88
+
89
+ # Credit Note status. Possible Values are VOIDED, DRAFT, AUTHORISED, NOT AVAILABLE
90
+ attr_accessor :credit_note_status
91
+
92
+ # Payment status. Possible Values are NOT REFUNDED, PREPAID, PARTIALLY PAID, UNPAID, PAID, VOIDED
93
+ attr_accessor :combined_payment_status
94
+
95
+ # Type of Sale. Possible Values are Simple Sale, Advanced Sale , Service Sale
96
+ attr_accessor :type
97
+
98
+ # Tracking Numbers
99
+ attr_accessor :combined_tracking_numbers
100
+
101
+ # Source of the sale. read-only field
102
+ attr_accessor :source_channel
103
+
104
+ # Custom field that is only available in API and allows to set arbitrary value for the sale for later search and any custom logic
105
+ attr_accessor :external_id
106
+
107
+ # Sale Order Location ID
108
+ attr_accessor :order_location_id
109
+
110
+ # Attribute mapping from ruby-style variable name to JSON key.
111
+ def self.attribute_map
112
+ {
113
+ :'sale_id' => :'SaleID',
114
+ :'order_number' => :'OrderNumber',
115
+ :'status' => :'Status',
116
+ :'order_date' => :'OrderDate',
117
+ :'invoice_date' => :'InvoiceDate',
118
+ :'customer' => :'Customer',
119
+ :'customer_id' => :'CustomerID',
120
+ :'invoice_number' => :'InvoiceNumber',
121
+ :'customer_reference' => :'CustomerReference',
122
+ :'invoice_amount' => :'InvoiceAmount',
123
+ :'paid_amount' => :'PaidAmount',
124
+ :'invoice_due_date' => :'InvoiceDueDate',
125
+ :'ship_by' => :'ShipBy',
126
+ :'base_currency' => :'BaseCurrency',
127
+ :'customer_currency' => :'CustomerCurrency',
128
+ :'credit_note_number' => :'CreditNoteNumber',
129
+ :'updated' => :'Updated',
130
+ :'quote_status' => :'QuoteStatus',
131
+ :'order_status' => :'OrderStatus',
132
+ :'combined_picking_status' => :'CombinedPickingStatus',
133
+ :'combined_packing_status' => :'CombinedPackingStatus',
134
+ :'combined_shipping_status' => :'CombinedShippingStatus',
135
+ :'ful_filment_status' => :'FulFilmentStatus',
136
+ :'combined_invoice_status' => :'CombinedInvoiceStatus',
137
+ :'credit_note_status' => :'CreditNoteStatus',
138
+ :'combined_payment_status' => :'CombinedPaymentStatus',
139
+ :'type' => :'Type',
140
+ :'combined_tracking_numbers' => :'CombinedTrackingNumbers',
141
+ :'source_channel' => :'SourceChannel',
142
+ :'external_id' => :'ExternalID',
143
+ :'order_location_id' => :'OrderLocationID'
144
+ }
145
+ end
146
+
147
+ # Attribute type mapping.
148
+ def self.openapi_types
149
+ {
150
+ :'sale_id' => :'String',
151
+ :'order_number' => :'String',
152
+ :'status' => :'String',
153
+ :'order_date' => :'Date',
154
+ :'invoice_date' => :'Date',
155
+ :'customer' => :'String',
156
+ :'customer_id' => :'String',
157
+ :'invoice_number' => :'String',
158
+ :'customer_reference' => :'String',
159
+ :'invoice_amount' => :'Float',
160
+ :'paid_amount' => :'Float',
161
+ :'invoice_due_date' => :'Date',
162
+ :'ship_by' => :'Date',
163
+ :'base_currency' => :'String',
164
+ :'customer_currency' => :'String',
165
+ :'credit_note_number' => :'String',
166
+ :'updated' => :'Date',
167
+ :'quote_status' => :'String',
168
+ :'order_status' => :'String',
169
+ :'combined_picking_status' => :'String',
170
+ :'combined_packing_status' => :'String',
171
+ :'combined_shipping_status' => :'String',
172
+ :'ful_filment_status' => :'String',
173
+ :'combined_invoice_status' => :'String',
174
+ :'credit_note_status' => :'String',
175
+ :'combined_payment_status' => :'String',
176
+ :'type' => :'String',
177
+ :'combined_tracking_numbers' => :'String',
178
+ :'source_channel' => :'String',
179
+ :'external_id' => :'String',
180
+ :'order_location_id' => :'String'
181
+ }
182
+ end
183
+
184
+ # List of attributes with nullable: true
185
+ def self.openapi_nullable
186
+ Set.new([
187
+ ])
188
+ end
189
+
190
+ # Initializes the object
191
+ # @param [Hash] attributes Model attributes in the form of hash
192
+ def initialize(attributes = {})
193
+ if (!attributes.is_a?(Hash))
194
+ fail ArgumentError, "The input argument (attributes) must be a hash in `DearInventoryRuby::SaleItem` initialize method"
195
+ end
196
+
197
+ # check to see if the attribute exists and convert string to symbol for hash key
198
+ attributes = attributes.each_with_object({}) { |(k, v), h|
199
+ if (!self.class.attribute_map.key?(k.to_sym))
200
+ fail ArgumentError, "`#{k}` is not a valid attribute in `DearInventoryRuby::SaleItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
201
+ end
202
+ h[k.to_sym] = v
203
+ }
204
+
205
+ if attributes.key?(:'sale_id')
206
+ self.sale_id = attributes[:'sale_id']
207
+ end
208
+
209
+ if attributes.key?(:'order_number')
210
+ self.order_number = attributes[:'order_number']
211
+ end
212
+
213
+ if attributes.key?(:'status')
214
+ self.status = attributes[:'status']
215
+ end
216
+
217
+ if attributes.key?(:'order_date')
218
+ self.order_date = attributes[:'order_date']
219
+ end
220
+
221
+ if attributes.key?(:'invoice_date')
222
+ self.invoice_date = attributes[:'invoice_date']
223
+ end
224
+
225
+ if attributes.key?(:'customer')
226
+ self.customer = attributes[:'customer']
227
+ end
228
+
229
+ if attributes.key?(:'customer_id')
230
+ self.customer_id = attributes[:'customer_id']
231
+ end
232
+
233
+ if attributes.key?(:'invoice_number')
234
+ self.invoice_number = attributes[:'invoice_number']
235
+ end
236
+
237
+ if attributes.key?(:'customer_reference')
238
+ self.customer_reference = attributes[:'customer_reference']
239
+ end
240
+
241
+ if attributes.key?(:'invoice_amount')
242
+ self.invoice_amount = attributes[:'invoice_amount']
243
+ end
244
+
245
+ if attributes.key?(:'paid_amount')
246
+ self.paid_amount = attributes[:'paid_amount']
247
+ end
248
+
249
+ if attributes.key?(:'invoice_due_date')
250
+ self.invoice_due_date = attributes[:'invoice_due_date']
251
+ end
252
+
253
+ if attributes.key?(:'ship_by')
254
+ self.ship_by = attributes[:'ship_by']
255
+ end
256
+
257
+ if attributes.key?(:'base_currency')
258
+ self.base_currency = attributes[:'base_currency']
259
+ end
260
+
261
+ if attributes.key?(:'customer_currency')
262
+ self.customer_currency = attributes[:'customer_currency']
263
+ end
264
+
265
+ if attributes.key?(:'credit_note_number')
266
+ self.credit_note_number = attributes[:'credit_note_number']
267
+ end
268
+
269
+ if attributes.key?(:'updated')
270
+ self.updated = attributes[:'updated']
271
+ end
272
+
273
+ if attributes.key?(:'quote_status')
274
+ self.quote_status = attributes[:'quote_status']
275
+ end
276
+
277
+ if attributes.key?(:'order_status')
278
+ self.order_status = attributes[:'order_status']
279
+ end
280
+
281
+ if attributes.key?(:'combined_picking_status')
282
+ self.combined_picking_status = attributes[:'combined_picking_status']
283
+ end
284
+
285
+ if attributes.key?(:'combined_packing_status')
286
+ self.combined_packing_status = attributes[:'combined_packing_status']
287
+ end
288
+
289
+ if attributes.key?(:'combined_shipping_status')
290
+ self.combined_shipping_status = attributes[:'combined_shipping_status']
291
+ end
292
+
293
+ if attributes.key?(:'ful_filment_status')
294
+ self.ful_filment_status = attributes[:'ful_filment_status']
295
+ end
296
+
297
+ if attributes.key?(:'combined_invoice_status')
298
+ self.combined_invoice_status = attributes[:'combined_invoice_status']
299
+ end
300
+
301
+ if attributes.key?(:'credit_note_status')
302
+ self.credit_note_status = attributes[:'credit_note_status']
303
+ end
304
+
305
+ if attributes.key?(:'combined_payment_status')
306
+ self.combined_payment_status = attributes[:'combined_payment_status']
307
+ end
308
+
309
+ if attributes.key?(:'type')
310
+ self.type = attributes[:'type']
311
+ end
312
+
313
+ if attributes.key?(:'combined_tracking_numbers')
314
+ self.combined_tracking_numbers = attributes[:'combined_tracking_numbers']
315
+ end
316
+
317
+ if attributes.key?(:'source_channel')
318
+ self.source_channel = attributes[:'source_channel']
319
+ end
320
+
321
+ if attributes.key?(:'external_id')
322
+ self.external_id = attributes[:'external_id']
323
+ end
324
+
325
+ if attributes.key?(:'order_location_id')
326
+ self.order_location_id = attributes[:'order_location_id']
327
+ end
328
+ end
329
+
330
+ # Show invalid properties with the reasons. Usually used together with valid?
331
+ # @return Array for valid properties with the reasons
332
+ def list_invalid_properties
333
+ invalid_properties = Array.new
334
+ invalid_properties
335
+ end
336
+
337
+ # Check to see if the all the properties in the model are valid
338
+ # @return true if the model is valid
339
+ def valid?
340
+ true
341
+ end
342
+
343
+ # Checks equality by comparing each attribute.
344
+ # @param [Object] Object to be compared
345
+ def ==(o)
346
+ return true if self.equal?(o)
347
+ self.class == o.class &&
348
+ sale_id == o.sale_id &&
349
+ order_number == o.order_number &&
350
+ status == o.status &&
351
+ order_date == o.order_date &&
352
+ invoice_date == o.invoice_date &&
353
+ customer == o.customer &&
354
+ customer_id == o.customer_id &&
355
+ invoice_number == o.invoice_number &&
356
+ customer_reference == o.customer_reference &&
357
+ invoice_amount == o.invoice_amount &&
358
+ paid_amount == o.paid_amount &&
359
+ invoice_due_date == o.invoice_due_date &&
360
+ ship_by == o.ship_by &&
361
+ base_currency == o.base_currency &&
362
+ customer_currency == o.customer_currency &&
363
+ credit_note_number == o.credit_note_number &&
364
+ updated == o.updated &&
365
+ quote_status == o.quote_status &&
366
+ order_status == o.order_status &&
367
+ combined_picking_status == o.combined_picking_status &&
368
+ combined_packing_status == o.combined_packing_status &&
369
+ combined_shipping_status == o.combined_shipping_status &&
370
+ ful_filment_status == o.ful_filment_status &&
371
+ combined_invoice_status == o.combined_invoice_status &&
372
+ credit_note_status == o.credit_note_status &&
373
+ combined_payment_status == o.combined_payment_status &&
374
+ type == o.type &&
375
+ combined_tracking_numbers == o.combined_tracking_numbers &&
376
+ source_channel == o.source_channel &&
377
+ external_id == o.external_id &&
378
+ order_location_id == o.order_location_id
379
+ end
380
+
381
+ # @see the `==` method
382
+ # @param [Object] Object to be compared
383
+ def eql?(o)
384
+ self == o
385
+ end
386
+
387
+ # Calculates hash code according to all attributes.
388
+ # @return [Integer] Hash code
389
+ def hash
390
+ [sale_id, order_number, status, order_date, invoice_date, customer, customer_id, invoice_number, customer_reference, invoice_amount, paid_amount, invoice_due_date, ship_by, base_currency, customer_currency, credit_note_number, updated, quote_status, order_status, combined_picking_status, combined_packing_status, combined_shipping_status, ful_filment_status, combined_invoice_status, credit_note_status, combined_payment_status, type, combined_tracking_numbers, source_channel, external_id, order_location_id].hash
391
+ end
392
+
393
+ # Builds the object from hash
394
+ # @param [Hash] attributes Model attributes in the form of hash
395
+ # @return [Object] Returns the model itself
396
+ def self.build_from_hash(attributes)
397
+ new.build_from_hash(attributes)
398
+ end
399
+
400
+ # Builds the object from hash
401
+ # @param [Hash] attributes Model attributes in the form of hash
402
+ # @return [Object] Returns the model itself
403
+ def build_from_hash(attributes)
404
+ return nil unless attributes.is_a?(Hash)
405
+ self.class.openapi_types.each_pair do |key, type|
406
+ if type =~ /\AArray<(.*)>/i
407
+ # check to ensure the input is an array given that the attribute
408
+ # is documented as an array but the input is not
409
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
410
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
411
+ end
412
+ elsif !attributes[self.class.attribute_map[key]].nil?
413
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
414
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
415
+ end
416
+
417
+ self
418
+ end
419
+
420
+ # Deserializes the data based on type
421
+ # @param string type Data type
422
+ # @param string value Value to be deserialized
423
+ # @return [Object] Deserialized data
424
+ def _deserialize(type, value)
425
+ case type.to_sym
426
+ when :DateTime
427
+ DateTime.parse(value)
428
+ when :Date
429
+ Date.parse(value)
430
+ when :String
431
+ value.to_s
432
+ when :Integer
433
+ value.to_i
434
+ when :Float
435
+ value.to_f
436
+ when :Boolean
437
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
438
+ true
439
+ else
440
+ false
441
+ end
442
+ when :Object
443
+ # generic object (usually a Hash), return directly
444
+ value
445
+ when /\AArray<(?<inner_type>.+)>\z/
446
+ inner_type = Regexp.last_match[:inner_type]
447
+ value.map { |v| _deserialize(inner_type, v) }
448
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
449
+ k_type = Regexp.last_match[:k_type]
450
+ v_type = Regexp.last_match[:v_type]
451
+ {}.tap do |hash|
452
+ value.each do |k, v|
453
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
454
+ end
455
+ end
456
+ else # model
457
+ DearInventoryRuby.const_get(type).build_from_hash(value)
458
+ end
459
+ end
460
+
461
+ # Returns the string representation of the object
462
+ # @return [String] String presentation of the object
463
+ def to_s
464
+ to_hash.to_s
465
+ end
466
+
467
+ # to_body is an alias to to_hash (backward compatibility)
468
+ # @return [Hash] Returns the object in the form of hash
469
+ def to_body
470
+ to_hash
471
+ end
472
+
473
+ # Returns the object in the form of hash
474
+ # @return [Hash] Returns the object in the form of hash
475
+ def to_hash
476
+ hash = {}
477
+ self.class.attribute_map.each_pair do |attr, param|
478
+ value = self.send(attr)
479
+ if value.nil?
480
+ is_nullable = self.class.openapi_nullable.include?(attr)
481
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
482
+ end
483
+
484
+ hash[param] = _to_hash(value)
485
+ end
486
+ hash
487
+ end
488
+
489
+ # Outputs non-array value in the form of hash
490
+ # For object, use to_hash. Otherwise, just return the value
491
+ # @param [Object] value Any valid value
492
+ # @return [Hash] Returns the value in the form of hash
493
+ def _to_hash(value)
494
+ if value.is_a?(Array)
495
+ value.compact.map { |v| _to_hash(v) }
496
+ elsif value.is_a?(Hash)
497
+ {}.tap do |hash|
498
+ value.each { |k, v| hash[k] = _to_hash(v) }
499
+ end
500
+ elsif value.respond_to? :to_hash
501
+ value.to_hash
502
+ else
503
+ value
504
+ end
505
+ end
506
+ end
507
+ end