dear-inventory-ruby 0.1.19.1 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -0
  3. data/README.md +34 -5
  4. data/docs/Address.md +10 -12
  5. data/docs/AuthorizationType.md +16 -0
  6. data/docs/Customer.md +1 -1
  7. data/docs/ExternalHeader.md +19 -0
  8. data/docs/InventoryApi.md +1021 -163
  9. data/docs/SaleAdditionalCharge.md +31 -0
  10. data/docs/SaleInvoice.md +1 -1
  11. data/docs/SaleInvoiceAdditionalCharge.md +3 -3
  12. data/docs/SaleInvoiceDelete.md +19 -0
  13. data/docs/SaleInvoiceLine.md +2 -2
  14. data/docs/SaleInvoicePost.md +41 -0
  15. data/docs/SaleOrder.md +35 -0
  16. data/docs/SaleOrderLine.md +41 -0
  17. data/docs/SalePayment.md +43 -0
  18. data/docs/SaleQuote.md +33 -0
  19. data/docs/SaleQuoteLine.md +37 -0
  20. data/docs/ShippingAddress.md +37 -0
  21. data/docs/SupplierCustomerAddress.md +33 -0
  22. data/docs/Webhook.md +35 -0
  23. data/docs/WebhookType.md +16 -0
  24. data/docs/Webhooks.md +17 -0
  25. data/lib/dear-inventory-ruby/api/inventory_api.rb +985 -119
  26. data/lib/dear-inventory-ruby/models/address.rb +28 -115
  27. data/lib/dear-inventory-ruby/models/authorization_type.rb +37 -0
  28. data/lib/dear-inventory-ruby/models/customer.rb +1 -1
  29. data/lib/dear-inventory-ruby/models/external_header.rb +217 -0
  30. data/lib/dear-inventory-ruby/models/sale_additional_charge.rb +302 -0
  31. data/lib/dear-inventory-ruby/models/sale_invoice.rb +1 -1
  32. data/lib/dear-inventory-ruby/models/sale_invoice_additional_charge.rb +3 -3
  33. data/lib/dear-inventory-ruby/models/sale_invoice_delete.rb +224 -0
  34. data/lib/dear-inventory-ruby/models/sale_invoice_line.rb +0 -10
  35. data/lib/dear-inventory-ruby/models/sale_invoice_post.rb +361 -0
  36. data/lib/dear-inventory-ruby/models/sale_order.rb +336 -0
  37. data/lib/dear-inventory-ruby/models/sale_order_line.rb +342 -0
  38. data/lib/dear-inventory-ruby/models/sale_payment.rb +337 -0
  39. data/lib/dear-inventory-ruby/models/sale_quote.rb +326 -0
  40. data/lib/dear-inventory-ruby/models/sale_quote_line.rb +322 -0
  41. data/lib/dear-inventory-ruby/models/shipping_address.rb +317 -0
  42. data/lib/dear-inventory-ruby/models/supplier_customer_address.rb +374 -0
  43. data/lib/dear-inventory-ruby/models/webhook.rb +319 -0
  44. data/lib/dear-inventory-ruby/models/webhook_type.rb +54 -0
  45. data/lib/dear-inventory-ruby/models/webhooks.rb +209 -0
  46. data/lib/dear-inventory-ruby/version.rb +1 -1
  47. data/lib/dear-inventory-ruby.rb +15 -0
  48. data/spec/api/inventory_api_spec.rb +165 -0
  49. data/spec/models/address_spec.rb +7 -13
  50. data/spec/models/authorization_type_spec.rb +35 -0
  51. data/spec/models/external_header_spec.rb +47 -0
  52. data/spec/models/sale_additional_charge_spec.rb +83 -0
  53. data/spec/models/sale_invoice_delete_spec.rb +47 -0
  54. data/spec/models/sale_invoice_post_spec.rb +113 -0
  55. data/spec/models/sale_order_line_spec.rb +113 -0
  56. data/spec/models/sale_order_spec.rb +95 -0
  57. data/spec/models/sale_payment_spec.rb +119 -0
  58. data/spec/models/sale_quote_line_spec.rb +101 -0
  59. data/spec/models/sale_quote_spec.rb +89 -0
  60. data/spec/models/shipping_address_spec.rb +101 -0
  61. data/spec/models/supplier_customer_address_spec.rb +89 -0
  62. data/spec/models/webhook_spec.rb +95 -0
  63. data/spec/models/webhook_type_spec.rb +35 -0
  64. data/spec/models/webhooks_spec.rb +41 -0
  65. metadata +63 -6
  66. data/lib/.DS_Store +0 -0
  67. data/lib/dear-inventory-ruby/.DS_Store +0 -0
  68. data/spec/.DS_Store +0 -0
@@ -0,0 +1,361 @@
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 SaleInvoicePost
17
+ # Unique DEAR Sale ID
18
+ attr_accessor :sale_id
19
+
20
+ # Identifier of sale Invoice task
21
+ attr_accessor :task_id
22
+
23
+ # If `true` then `additional charges` lines displayed in `Lines` array
24
+ attr_accessor :combine_additional_charges
25
+
26
+ # Additional information for Invoice.
27
+ attr_accessor :memo
28
+
29
+ # Invoice status. Possible Values are values. For POST available values are DRAFT, AUTHORISED
30
+ attr_accessor :status
31
+
32
+ # Invoice Date.
33
+ attr_accessor :invoice_date
34
+
35
+ # Invoice Due Date.
36
+ attr_accessor :invoice_due_date
37
+
38
+ # Decimal with up to 4 decimal places
39
+ attr_accessor :currency_conversion_rate
40
+
41
+ # Billing Address Line 1
42
+ attr_accessor :billing_address_line1
43
+
44
+ # Billing Address Line 2
45
+ attr_accessor :billing_address_line2
46
+
47
+ # Number of Fulfilment linked to this invoice
48
+ attr_accessor :linked_fulfillment_number
49
+
50
+ attr_accessor :lines
51
+
52
+ attr_accessor :additional_charges
53
+
54
+ # Attribute mapping from ruby-style variable name to JSON key.
55
+ def self.attribute_map
56
+ {
57
+ :'sale_id' => :'SaleID',
58
+ :'task_id' => :'TaskID',
59
+ :'combine_additional_charges' => :'CombineAdditionalCharges',
60
+ :'memo' => :'Memo',
61
+ :'status' => :'Status',
62
+ :'invoice_date' => :'InvoiceDate',
63
+ :'invoice_due_date' => :'InvoiceDueDate',
64
+ :'currency_conversion_rate' => :'CurrencyConversionRate',
65
+ :'billing_address_line1' => :'BillingAddressLine1',
66
+ :'billing_address_line2' => :'BillingAddressLine2',
67
+ :'linked_fulfillment_number' => :'LinkedFulfillmentNumber',
68
+ :'lines' => :'Lines',
69
+ :'additional_charges' => :'AdditionalCharges'
70
+ }
71
+ end
72
+
73
+ # Attribute type mapping.
74
+ def self.openapi_types
75
+ {
76
+ :'sale_id' => :'String',
77
+ :'task_id' => :'String',
78
+ :'combine_additional_charges' => :'Boolean',
79
+ :'memo' => :'String',
80
+ :'status' => :'String',
81
+ :'invoice_date' => :'String',
82
+ :'invoice_due_date' => :'String',
83
+ :'currency_conversion_rate' => :'Float',
84
+ :'billing_address_line1' => :'String',
85
+ :'billing_address_line2' => :'String',
86
+ :'linked_fulfillment_number' => :'Integer',
87
+ :'lines' => :'Array<SaleInvoiceLine>',
88
+ :'additional_charges' => :'Array<SaleInvoiceAdditionalCharge>'
89
+ }
90
+ end
91
+
92
+ # List of attributes with nullable: true
93
+ def self.openapi_nullable
94
+ Set.new([
95
+ ])
96
+ end
97
+
98
+ # Initializes the object
99
+ # @param [Hash] attributes Model attributes in the form of hash
100
+ def initialize(attributes = {})
101
+ if (!attributes.is_a?(Hash))
102
+ fail ArgumentError, "The input argument (attributes) must be a hash in `DearInventoryRuby::SaleInvoicePost` initialize method"
103
+ end
104
+
105
+ # check to see if the attribute exists and convert string to symbol for hash key
106
+ attributes = attributes.each_with_object({}) { |(k, v), h|
107
+ if (!self.class.attribute_map.key?(k.to_sym))
108
+ fail ArgumentError, "`#{k}` is not a valid attribute in `DearInventoryRuby::SaleInvoicePost`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
109
+ end
110
+ h[k.to_sym] = v
111
+ }
112
+
113
+ if attributes.key?(:'sale_id')
114
+ self.sale_id = attributes[:'sale_id']
115
+ end
116
+
117
+ if attributes.key?(:'task_id')
118
+ self.task_id = attributes[:'task_id']
119
+ end
120
+
121
+ if attributes.key?(:'combine_additional_charges')
122
+ self.combine_additional_charges = attributes[:'combine_additional_charges']
123
+ else
124
+ self.combine_additional_charges = false
125
+ end
126
+
127
+ if attributes.key?(:'memo')
128
+ self.memo = attributes[:'memo']
129
+ end
130
+
131
+ if attributes.key?(:'status')
132
+ self.status = attributes[:'status']
133
+ end
134
+
135
+ if attributes.key?(:'invoice_date')
136
+ self.invoice_date = attributes[:'invoice_date']
137
+ end
138
+
139
+ if attributes.key?(:'invoice_due_date')
140
+ self.invoice_due_date = attributes[:'invoice_due_date']
141
+ end
142
+
143
+ if attributes.key?(:'currency_conversion_rate')
144
+ self.currency_conversion_rate = attributes[:'currency_conversion_rate']
145
+ end
146
+
147
+ if attributes.key?(:'billing_address_line1')
148
+ self.billing_address_line1 = attributes[:'billing_address_line1']
149
+ end
150
+
151
+ if attributes.key?(:'billing_address_line2')
152
+ self.billing_address_line2 = attributes[:'billing_address_line2']
153
+ end
154
+
155
+ if attributes.key?(:'linked_fulfillment_number')
156
+ self.linked_fulfillment_number = attributes[:'linked_fulfillment_number']
157
+ end
158
+
159
+ if attributes.key?(:'lines')
160
+ if (value = attributes[:'lines']).is_a?(Array)
161
+ self.lines = value
162
+ end
163
+ end
164
+
165
+ if attributes.key?(:'additional_charges')
166
+ if (value = attributes[:'additional_charges']).is_a?(Array)
167
+ self.additional_charges = value
168
+ end
169
+ end
170
+ end
171
+
172
+ # Show invalid properties with the reasons. Usually used together with valid?
173
+ # @return Array for valid properties with the reasons
174
+ def list_invalid_properties
175
+ invalid_properties = Array.new
176
+ if @sale_id.nil?
177
+ invalid_properties.push('invalid value for "sale_id", sale_id cannot be nil.')
178
+ end
179
+
180
+ if @task_id.nil?
181
+ invalid_properties.push('invalid value for "task_id", task_id cannot be nil.')
182
+ end
183
+
184
+ if @combine_additional_charges.nil?
185
+ invalid_properties.push('invalid value for "combine_additional_charges", combine_additional_charges cannot be nil.')
186
+ end
187
+
188
+ if @status.nil?
189
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
190
+ end
191
+
192
+ if @invoice_date.nil?
193
+ invalid_properties.push('invalid value for "invoice_date", invoice_date cannot be nil.')
194
+ end
195
+
196
+ if @invoice_due_date.nil?
197
+ invalid_properties.push('invalid value for "invoice_due_date", invoice_due_date cannot be nil.')
198
+ end
199
+
200
+ invalid_properties
201
+ end
202
+
203
+ # Check to see if the all the properties in the model are valid
204
+ # @return true if the model is valid
205
+ def valid?
206
+ return false if @sale_id.nil?
207
+ return false if @task_id.nil?
208
+ return false if @combine_additional_charges.nil?
209
+ return false if @status.nil?
210
+ return false if @invoice_date.nil?
211
+ return false if @invoice_due_date.nil?
212
+ true
213
+ end
214
+
215
+ # Checks equality by comparing each attribute.
216
+ # @param [Object] Object to be compared
217
+ def ==(o)
218
+ return true if self.equal?(o)
219
+ self.class == o.class &&
220
+ sale_id == o.sale_id &&
221
+ task_id == o.task_id &&
222
+ combine_additional_charges == o.combine_additional_charges &&
223
+ memo == o.memo &&
224
+ status == o.status &&
225
+ invoice_date == o.invoice_date &&
226
+ invoice_due_date == o.invoice_due_date &&
227
+ currency_conversion_rate == o.currency_conversion_rate &&
228
+ billing_address_line1 == o.billing_address_line1 &&
229
+ billing_address_line2 == o.billing_address_line2 &&
230
+ linked_fulfillment_number == o.linked_fulfillment_number &&
231
+ lines == o.lines &&
232
+ additional_charges == o.additional_charges
233
+ end
234
+
235
+ # @see the `==` method
236
+ # @param [Object] Object to be compared
237
+ def eql?(o)
238
+ self == o
239
+ end
240
+
241
+ # Calculates hash code according to all attributes.
242
+ # @return [Integer] Hash code
243
+ def hash
244
+ [sale_id, task_id, combine_additional_charges, memo, status, invoice_date, invoice_due_date, currency_conversion_rate, billing_address_line1, billing_address_line2, linked_fulfillment_number, lines, additional_charges].hash
245
+ end
246
+
247
+ # Builds the object from hash
248
+ # @param [Hash] attributes Model attributes in the form of hash
249
+ # @return [Object] Returns the model itself
250
+ def self.build_from_hash(attributes)
251
+ new.build_from_hash(attributes)
252
+ end
253
+
254
+ # Builds the object from hash
255
+ # @param [Hash] attributes Model attributes in the form of hash
256
+ # @return [Object] Returns the model itself
257
+ def build_from_hash(attributes)
258
+ return nil unless attributes.is_a?(Hash)
259
+ self.class.openapi_types.each_pair do |key, type|
260
+ if type =~ /\AArray<(.*)>/i
261
+ # check to ensure the input is an array given that the attribute
262
+ # is documented as an array but the input is not
263
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
264
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
265
+ end
266
+ elsif !attributes[self.class.attribute_map[key]].nil?
267
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
268
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
269
+ end
270
+
271
+ self
272
+ end
273
+
274
+ # Deserializes the data based on type
275
+ # @param string type Data type
276
+ # @param string value Value to be deserialized
277
+ # @return [Object] Deserialized data
278
+ def _deserialize(type, value)
279
+ case type.to_sym
280
+ when :DateTime
281
+ DateTime.parse(value)
282
+ when :Date
283
+ Date.parse(value)
284
+ when :String
285
+ value.to_s
286
+ when :Integer
287
+ value.to_i
288
+ when :Float
289
+ value.to_f
290
+ when :Boolean
291
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
292
+ true
293
+ else
294
+ false
295
+ end
296
+ when :Object
297
+ # generic object (usually a Hash), return directly
298
+ value
299
+ when /\AArray<(?<inner_type>.+)>\z/
300
+ inner_type = Regexp.last_match[:inner_type]
301
+ value.map { |v| _deserialize(inner_type, v) }
302
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
303
+ k_type = Regexp.last_match[:k_type]
304
+ v_type = Regexp.last_match[:v_type]
305
+ {}.tap do |hash|
306
+ value.each do |k, v|
307
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
308
+ end
309
+ end
310
+ else # model
311
+ DearInventoryRuby.const_get(type).build_from_hash(value)
312
+ end
313
+ end
314
+
315
+ # Returns the string representation of the object
316
+ # @return [String] String presentation of the object
317
+ def to_s
318
+ to_hash.to_s
319
+ end
320
+
321
+ # to_body is an alias to to_hash (backward compatibility)
322
+ # @return [Hash] Returns the object in the form of hash
323
+ def to_body
324
+ to_hash
325
+ end
326
+
327
+ # Returns the object in the form of hash
328
+ # @return [Hash] Returns the object in the form of hash
329
+ def to_hash
330
+ hash = {}
331
+ self.class.attribute_map.each_pair do |attr, param|
332
+ value = self.send(attr)
333
+ if value.nil?
334
+ is_nullable = self.class.openapi_nullable.include?(attr)
335
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
336
+ end
337
+
338
+ hash[param] = _to_hash(value)
339
+ end
340
+ hash
341
+ end
342
+
343
+ # Outputs non-array value in the form of hash
344
+ # For object, use to_hash. Otherwise, just return the value
345
+ # @param [Object] value Any valid value
346
+ # @return [Hash] Returns the value in the form of hash
347
+ def _to_hash(value)
348
+ if value.is_a?(Array)
349
+ value.compact.map { |v| _to_hash(v) }
350
+ elsif value.is_a?(Hash)
351
+ {}.tap do |hash|
352
+ value.each { |k, v| hash[k] = _to_hash(v) }
353
+ end
354
+ elsif value.respond_to? :to_hash
355
+ value.to_hash
356
+ else
357
+ value
358
+ end
359
+ end
360
+ end
361
+ end
@@ -0,0 +1,336 @@
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 SaleOrder
17
+ # Unique DEAR Sale ID
18
+ attr_accessor :sale_id
19
+
20
+ # Sale Order Number (auto-generated)
21
+ attr_accessor :sale_order_number
22
+
23
+ # If `true` then `additional charges` lines displayed in `Lines` array
24
+ attr_accessor :combine_additional_charges
25
+
26
+ # Additional information for Order.
27
+ attr_accessor :memo
28
+
29
+ # Order Status. Possible Values are values. For POST only `DRAFT` and `AUTHORISED` values accepted
30
+ attr_accessor :status
31
+
32
+ attr_accessor :lines
33
+
34
+ attr_accessor :additional_charges
35
+
36
+ # Decimal with up to 4 decimal places. Sum of order lines and additional charges without taxes. Not required for POST.
37
+ attr_accessor :total_before_tax
38
+
39
+ # Decimal with up to 4 decimal places. Sum of order lines and additional charges taxes. Not required for POST.
40
+ attr_accessor :tax
41
+
42
+ # Decimal with up to 4 decimal places. Sum of order lines and additional charges with taxes. Not required for POST.
43
+ attr_accessor :total
44
+
45
+ # Attribute mapping from ruby-style variable name to JSON key.
46
+ def self.attribute_map
47
+ {
48
+ :'sale_id' => :'SaleID',
49
+ :'sale_order_number' => :'SaleOrderNumber',
50
+ :'combine_additional_charges' => :'CombineAdditionalCharges',
51
+ :'memo' => :'Memo',
52
+ :'status' => :'Status',
53
+ :'lines' => :'Lines',
54
+ :'additional_charges' => :'AdditionalCharges',
55
+ :'total_before_tax' => :'TotalBeforeTax',
56
+ :'tax' => :'Tax',
57
+ :'total' => :'Total'
58
+ }
59
+ end
60
+
61
+ # Attribute type mapping.
62
+ def self.openapi_types
63
+ {
64
+ :'sale_id' => :'String',
65
+ :'sale_order_number' => :'String',
66
+ :'combine_additional_charges' => :'Boolean',
67
+ :'memo' => :'String',
68
+ :'status' => :'String',
69
+ :'lines' => :'Array<SaleOrderLine>',
70
+ :'additional_charges' => :'Array<SaleAdditionalCharge>',
71
+ :'total_before_tax' => :'Float',
72
+ :'tax' => :'Float',
73
+ :'total' => :'Float'
74
+ }
75
+ end
76
+
77
+ # List of attributes with nullable: true
78
+ def self.openapi_nullable
79
+ Set.new([
80
+ ])
81
+ end
82
+
83
+ # Initializes the object
84
+ # @param [Hash] attributes Model attributes in the form of hash
85
+ def initialize(attributes = {})
86
+ if (!attributes.is_a?(Hash))
87
+ fail ArgumentError, "The input argument (attributes) must be a hash in `DearInventoryRuby::SaleOrder` initialize method"
88
+ end
89
+
90
+ # check to see if the attribute exists and convert string to symbol for hash key
91
+ attributes = attributes.each_with_object({}) { |(k, v), h|
92
+ if (!self.class.attribute_map.key?(k.to_sym))
93
+ fail ArgumentError, "`#{k}` is not a valid attribute in `DearInventoryRuby::SaleOrder`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
94
+ end
95
+ h[k.to_sym] = v
96
+ }
97
+
98
+ if attributes.key?(:'sale_id')
99
+ self.sale_id = attributes[:'sale_id']
100
+ end
101
+
102
+ if attributes.key?(:'sale_order_number')
103
+ self.sale_order_number = attributes[:'sale_order_number']
104
+ end
105
+
106
+ if attributes.key?(:'combine_additional_charges')
107
+ self.combine_additional_charges = attributes[:'combine_additional_charges']
108
+ else
109
+ self.combine_additional_charges = false
110
+ end
111
+
112
+ if attributes.key?(:'memo')
113
+ self.memo = attributes[:'memo']
114
+ end
115
+
116
+ if attributes.key?(:'status')
117
+ self.status = attributes[:'status']
118
+ end
119
+
120
+ if attributes.key?(:'lines')
121
+ if (value = attributes[:'lines']).is_a?(Array)
122
+ self.lines = value
123
+ end
124
+ end
125
+
126
+ if attributes.key?(:'additional_charges')
127
+ if (value = attributes[:'additional_charges']).is_a?(Array)
128
+ self.additional_charges = value
129
+ end
130
+ end
131
+
132
+ if attributes.key?(:'total_before_tax')
133
+ self.total_before_tax = attributes[:'total_before_tax']
134
+ end
135
+
136
+ if attributes.key?(:'tax')
137
+ self.tax = attributes[:'tax']
138
+ end
139
+
140
+ if attributes.key?(:'total')
141
+ self.total = attributes[:'total']
142
+ end
143
+ end
144
+
145
+ # Show invalid properties with the reasons. Usually used together with valid?
146
+ # @return Array for valid properties with the reasons
147
+ def list_invalid_properties
148
+ invalid_properties = Array.new
149
+ if @sale_id.nil?
150
+ invalid_properties.push('invalid value for "sale_id", sale_id cannot be nil.')
151
+ end
152
+
153
+ if @combine_additional_charges.nil?
154
+ invalid_properties.push('invalid value for "combine_additional_charges", combine_additional_charges cannot be nil.')
155
+ end
156
+
157
+ if @memo.nil?
158
+ invalid_properties.push('invalid value for "memo", memo cannot be nil.')
159
+ end
160
+
161
+ if @status.nil?
162
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
163
+ end
164
+
165
+ if @total_before_tax.nil?
166
+ invalid_properties.push('invalid value for "total_before_tax", total_before_tax cannot be nil.')
167
+ end
168
+
169
+ if @tax.nil?
170
+ invalid_properties.push('invalid value for "tax", tax cannot be nil.')
171
+ end
172
+
173
+ if @total.nil?
174
+ invalid_properties.push('invalid value for "total", total cannot be nil.')
175
+ end
176
+
177
+ invalid_properties
178
+ end
179
+
180
+ # Check to see if the all the properties in the model are valid
181
+ # @return true if the model is valid
182
+ def valid?
183
+ return false if @sale_id.nil?
184
+ return false if @combine_additional_charges.nil?
185
+ return false if @memo.nil?
186
+ return false if @status.nil?
187
+ return false if @total_before_tax.nil?
188
+ return false if @tax.nil?
189
+ return false if @total.nil?
190
+ true
191
+ end
192
+
193
+ # Checks equality by comparing each attribute.
194
+ # @param [Object] Object to be compared
195
+ def ==(o)
196
+ return true if self.equal?(o)
197
+ self.class == o.class &&
198
+ sale_id == o.sale_id &&
199
+ sale_order_number == o.sale_order_number &&
200
+ combine_additional_charges == o.combine_additional_charges &&
201
+ memo == o.memo &&
202
+ status == o.status &&
203
+ lines == o.lines &&
204
+ additional_charges == o.additional_charges &&
205
+ total_before_tax == o.total_before_tax &&
206
+ tax == o.tax &&
207
+ total == o.total
208
+ end
209
+
210
+ # @see the `==` method
211
+ # @param [Object] Object to be compared
212
+ def eql?(o)
213
+ self == o
214
+ end
215
+
216
+ # Calculates hash code according to all attributes.
217
+ # @return [Integer] Hash code
218
+ def hash
219
+ [sale_id, sale_order_number, combine_additional_charges, memo, status, lines, additional_charges, total_before_tax, tax, total].hash
220
+ end
221
+
222
+ # Builds the object from hash
223
+ # @param [Hash] attributes Model attributes in the form of hash
224
+ # @return [Object] Returns the model itself
225
+ def self.build_from_hash(attributes)
226
+ new.build_from_hash(attributes)
227
+ end
228
+
229
+ # Builds the object from hash
230
+ # @param [Hash] attributes Model attributes in the form of hash
231
+ # @return [Object] Returns the model itself
232
+ def build_from_hash(attributes)
233
+ return nil unless attributes.is_a?(Hash)
234
+ self.class.openapi_types.each_pair do |key, type|
235
+ if type =~ /\AArray<(.*)>/i
236
+ # check to ensure the input is an array given that the attribute
237
+ # is documented as an array but the input is not
238
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
239
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
240
+ end
241
+ elsif !attributes[self.class.attribute_map[key]].nil?
242
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
243
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
244
+ end
245
+
246
+ self
247
+ end
248
+
249
+ # Deserializes the data based on type
250
+ # @param string type Data type
251
+ # @param string value Value to be deserialized
252
+ # @return [Object] Deserialized data
253
+ def _deserialize(type, value)
254
+ case type.to_sym
255
+ when :DateTime
256
+ DateTime.parse(value)
257
+ when :Date
258
+ Date.parse(value)
259
+ when :String
260
+ value.to_s
261
+ when :Integer
262
+ value.to_i
263
+ when :Float
264
+ value.to_f
265
+ when :Boolean
266
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
267
+ true
268
+ else
269
+ false
270
+ end
271
+ when :Object
272
+ # generic object (usually a Hash), return directly
273
+ value
274
+ when /\AArray<(?<inner_type>.+)>\z/
275
+ inner_type = Regexp.last_match[:inner_type]
276
+ value.map { |v| _deserialize(inner_type, v) }
277
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
278
+ k_type = Regexp.last_match[:k_type]
279
+ v_type = Regexp.last_match[:v_type]
280
+ {}.tap do |hash|
281
+ value.each do |k, v|
282
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
283
+ end
284
+ end
285
+ else # model
286
+ DearInventoryRuby.const_get(type).build_from_hash(value)
287
+ end
288
+ end
289
+
290
+ # Returns the string representation of the object
291
+ # @return [String] String presentation of the object
292
+ def to_s
293
+ to_hash.to_s
294
+ end
295
+
296
+ # to_body is an alias to to_hash (backward compatibility)
297
+ # @return [Hash] Returns the object in the form of hash
298
+ def to_body
299
+ to_hash
300
+ end
301
+
302
+ # Returns the object in the form of hash
303
+ # @return [Hash] Returns the object in the form of hash
304
+ def to_hash
305
+ hash = {}
306
+ self.class.attribute_map.each_pair do |attr, param|
307
+ value = self.send(attr)
308
+ if value.nil?
309
+ is_nullable = self.class.openapi_nullable.include?(attr)
310
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
311
+ end
312
+
313
+ hash[param] = _to_hash(value)
314
+ end
315
+ hash
316
+ end
317
+
318
+ # Outputs non-array value in the form of hash
319
+ # For object, use to_hash. Otherwise, just return the value
320
+ # @param [Object] value Any valid value
321
+ # @return [Hash] Returns the value in the form of hash
322
+ def _to_hash(value)
323
+ if value.is_a?(Array)
324
+ value.compact.map { |v| _to_hash(v) }
325
+ elsif value.is_a?(Hash)
326
+ {}.tap do |hash|
327
+ value.each { |k, v| hash[k] = _to_hash(v) }
328
+ end
329
+ elsif value.respond_to? :to_hash
330
+ value.to_hash
331
+ else
332
+ value
333
+ end
334
+ end
335
+ end
336
+ end