dear-inventory-ruby 0.1.5 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +31 -0
  3. data/Gemfile +1 -1
  4. data/README.md +32 -9
  5. data/dear-inventory-ruby.gemspec +1 -1
  6. data/docs/Account.md +45 -0
  7. data/docs/Accounts.md +21 -0
  8. data/docs/Address.md +11 -11
  9. data/docs/Contact.md +14 -10
  10. data/docs/Customer.md +40 -38
  11. data/docs/Customers.md +3 -3
  12. data/docs/DimensionsUnit.md +16 -0
  13. data/docs/Error.md +2 -2
  14. data/docs/InventoryApi.md +788 -26
  15. data/docs/Me.md +29 -0
  16. data/docs/PaymentTerm.md +27 -0
  17. data/docs/PaymentTerms.md +21 -0
  18. data/docs/Success.md +17 -0
  19. data/docs/Tax.md +33 -0
  20. data/docs/TaxComponent.md +23 -0
  21. data/docs/Taxes.md +21 -0
  22. data/docs/WeightUnit.md +16 -0
  23. data/lib/dear-inventory-ruby.rb +12 -1
  24. data/lib/dear-inventory-ruby/api/inventory_api.rb +827 -44
  25. data/lib/dear-inventory-ruby/api_client.rb +8 -6
  26. data/lib/dear-inventory-ruby/api_error.rb +1 -1
  27. data/lib/dear-inventory-ruby/configuration.rb +1 -1
  28. data/lib/dear-inventory-ruby/models/account.rb +477 -0
  29. data/lib/dear-inventory-ruby/models/accounts.rb +229 -0
  30. data/lib/dear-inventory-ruby/models/address.rb +11 -1
  31. data/lib/dear-inventory-ruby/models/contact.rb +34 -5
  32. data/lib/dear-inventory-ruby/models/currency_code.rb +1 -1
  33. data/lib/dear-inventory-ruby/models/customer.rb +56 -5
  34. data/lib/dear-inventory-ruby/models/customers.rb +1 -1
  35. data/lib/dear-inventory-ruby/models/dimensions_unit.rb +42 -0
  36. data/lib/dear-inventory-ruby/models/error.rb +1 -1
  37. data/lib/dear-inventory-ruby/models/me.rb +264 -0
  38. data/lib/dear-inventory-ruby/models/payment_term.rb +319 -0
  39. data/lib/dear-inventory-ruby/models/payment_terms.rb +229 -0
  40. data/lib/dear-inventory-ruby/models/success.rb +207 -0
  41. data/lib/dear-inventory-ruby/models/tax.rb +360 -0
  42. data/lib/dear-inventory-ruby/models/tax_component.rb +306 -0
  43. data/lib/dear-inventory-ruby/models/taxes.rb +229 -0
  44. data/lib/dear-inventory-ruby/models/weight_unit.rb +39 -0
  45. data/lib/dear-inventory-ruby/version.rb +2 -2
  46. data/spec/api/inventory_api_spec.rb +160 -5
  47. data/spec/api_client_spec.rb +2 -2
  48. data/spec/configuration_spec.rb +1 -1
  49. data/spec/models/account_spec.rb +129 -0
  50. data/spec/models/accounts_spec.rb +53 -0
  51. data/spec/models/address_spec.rb +1 -1
  52. data/spec/models/contact_spec.rb +13 -1
  53. data/spec/models/currency_code_spec.rb +1 -1
  54. data/spec/models/customer_spec.rb +7 -1
  55. data/spec/models/customers_spec.rb +1 -1
  56. data/spec/models/dimensions_unit_spec.rb +35 -0
  57. data/spec/models/error_spec.rb +1 -1
  58. data/spec/models/me_spec.rb +77 -0
  59. data/spec/models/payment_term_spec.rb +75 -0
  60. data/spec/models/payment_terms_spec.rb +53 -0
  61. data/spec/models/success_spec.rb +41 -0
  62. data/spec/models/tax_component_spec.rb +59 -0
  63. data/spec/models/tax_spec.rb +89 -0
  64. data/spec/models/taxes_spec.rb +53 -0
  65. data/spec/models/weight_unit_spec.rb +35 -0
  66. data/spec/spec_helper.rb +1 -1
  67. metadata +59 -15
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 2.0.0
7
7
  Contact: nnhansg@gmail.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.2.3
9
+ OpenAPI Generator version: 4.3.1
10
10
 
11
11
  =end
12
12
 
@@ -287,11 +287,13 @@ module DearInventoryRuby
287
287
  tempfile.write(chunk)
288
288
  end
289
289
  request.on_complete do |response|
290
- tempfile.close if tempfile
291
- @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
292
- "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
293
- "will be deleted automatically with GC. It's also recommended to delete the temp file "\
294
- "explicitly with `tempfile.delete`"
290
+ if tempfile
291
+ tempfile.close
292
+ @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
293
+ "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
294
+ "will be deleted automatically with GC. It's also recommended to delete the temp file "\
295
+ "explicitly with `tempfile.delete`"
296
+ end
295
297
  end
296
298
  end
297
299
 
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 2.0.0
7
7
  Contact: nnhansg@gmail.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.2.3
9
+ OpenAPI Generator version: 4.3.1
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 2.0.0
7
7
  Contact: nnhansg@gmail.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.2.3
9
+ OpenAPI Generator version: 4.3.1
10
10
 
11
11
  =end
12
12
 
@@ -0,0 +1,477 @@
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 Account
17
+ # Unique code of Account
18
+ attr_accessor :code
19
+
20
+ # Account Name
21
+ attr_accessor :name
22
+
23
+ # Type
24
+ attr_accessor :type
25
+
26
+ # Account status
27
+ attr_accessor :status
28
+
29
+ # Account description
30
+ attr_accessor :description
31
+
32
+ # Should be one of the following values: `ASSET`, `LIABILITY`, `EXPENSE`, `EQUITY`, `REVENUE`
33
+ attr_accessor :_class
34
+
35
+ # SystemAccount
36
+ attr_accessor :system_account
37
+
38
+ # SystemAccountCode
39
+ attr_accessor :system_account_code
40
+
41
+ # Account status
42
+ attr_accessor :for_payments
43
+
44
+ # Account display name. Read-only.
45
+ attr_accessor :display_name
46
+
47
+ # Read-only.
48
+ attr_accessor :old_code
49
+
50
+ # Name of the Bank. Only for PUT and POST. Required if Account Type is BANK.
51
+ attr_accessor :bank
52
+
53
+ # Bank Account Number. Only for PUT and POST. Required if Account Type is BANK.
54
+ attr_accessor :bank_account_number
55
+
56
+ # Bank Account ID to which the Account is linked. Read-only.
57
+ attr_accessor :bank_account_id
58
+
59
+ # Currency. Read-only.
60
+ attr_accessor :currency
61
+
62
+ class EnumAttributeValidator
63
+ attr_reader :datatype
64
+ attr_reader :allowable_values
65
+
66
+ def initialize(datatype, allowable_values)
67
+ @allowable_values = allowable_values.map do |value|
68
+ case datatype.to_s
69
+ when /Integer/i
70
+ value.to_i
71
+ when /Float/i
72
+ value.to_f
73
+ else
74
+ value
75
+ end
76
+ end
77
+ end
78
+
79
+ def valid?(value)
80
+ !value || allowable_values.include?(value)
81
+ end
82
+ end
83
+
84
+ # Attribute mapping from ruby-style variable name to JSON key.
85
+ def self.attribute_map
86
+ {
87
+ :'code' => :'Code',
88
+ :'name' => :'Name',
89
+ :'type' => :'Type',
90
+ :'status' => :'Status',
91
+ :'description' => :'Description',
92
+ :'_class' => :'Class',
93
+ :'system_account' => :'SystemAccount',
94
+ :'system_account_code' => :'SystemAccountCode',
95
+ :'for_payments' => :'ForPayments',
96
+ :'display_name' => :'DisplayName',
97
+ :'old_code' => :'OldCode',
98
+ :'bank' => :'Bank',
99
+ :'bank_account_number' => :'BankAccountNumber',
100
+ :'bank_account_id' => :'BankAccountId',
101
+ :'currency' => :'Currency'
102
+ }
103
+ end
104
+
105
+ # Attribute type mapping.
106
+ def self.openapi_types
107
+ {
108
+ :'code' => :'String',
109
+ :'name' => :'String',
110
+ :'type' => :'String',
111
+ :'status' => :'String',
112
+ :'description' => :'String',
113
+ :'_class' => :'String',
114
+ :'system_account' => :'String',
115
+ :'system_account_code' => :'String',
116
+ :'for_payments' => :'String',
117
+ :'display_name' => :'String',
118
+ :'old_code' => :'String',
119
+ :'bank' => :'String',
120
+ :'bank_account_number' => :'String',
121
+ :'bank_account_id' => :'String',
122
+ :'currency' => :'String'
123
+ }
124
+ end
125
+
126
+ # List of attributes with nullable: true
127
+ def self.openapi_nullable
128
+ Set.new([
129
+ ])
130
+ end
131
+
132
+ # Initializes the object
133
+ # @param [Hash] attributes Model attributes in the form of hash
134
+ def initialize(attributes = {})
135
+ if (!attributes.is_a?(Hash))
136
+ fail ArgumentError, "The input argument (attributes) must be a hash in `DearInventoryRuby::Account` initialize method"
137
+ end
138
+
139
+ # check to see if the attribute exists and convert string to symbol for hash key
140
+ attributes = attributes.each_with_object({}) { |(k, v), h|
141
+ if (!self.class.attribute_map.key?(k.to_sym))
142
+ fail ArgumentError, "`#{k}` is not a valid attribute in `DearInventoryRuby::Account`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
143
+ end
144
+ h[k.to_sym] = v
145
+ }
146
+
147
+ if attributes.key?(:'code')
148
+ self.code = attributes[:'code']
149
+ end
150
+
151
+ if attributes.key?(:'name')
152
+ self.name = attributes[:'name']
153
+ end
154
+
155
+ if attributes.key?(:'type')
156
+ self.type = attributes[:'type']
157
+ end
158
+
159
+ if attributes.key?(:'status')
160
+ self.status = attributes[:'status']
161
+ end
162
+
163
+ if attributes.key?(:'description')
164
+ self.description = attributes[:'description']
165
+ end
166
+
167
+ if attributes.key?(:'_class')
168
+ self._class = attributes[:'_class']
169
+ end
170
+
171
+ if attributes.key?(:'system_account')
172
+ self.system_account = attributes[:'system_account']
173
+ end
174
+
175
+ if attributes.key?(:'system_account_code')
176
+ self.system_account_code = attributes[:'system_account_code']
177
+ end
178
+
179
+ if attributes.key?(:'for_payments')
180
+ self.for_payments = attributes[:'for_payments']
181
+ end
182
+
183
+ if attributes.key?(:'display_name')
184
+ self.display_name = attributes[:'display_name']
185
+ end
186
+
187
+ if attributes.key?(:'old_code')
188
+ self.old_code = attributes[:'old_code']
189
+ end
190
+
191
+ if attributes.key?(:'bank')
192
+ self.bank = attributes[:'bank']
193
+ end
194
+
195
+ if attributes.key?(:'bank_account_number')
196
+ self.bank_account_number = attributes[:'bank_account_number']
197
+ end
198
+
199
+ if attributes.key?(:'bank_account_id')
200
+ self.bank_account_id = attributes[:'bank_account_id']
201
+ end
202
+
203
+ if attributes.key?(:'currency')
204
+ self.currency = attributes[:'currency']
205
+ end
206
+ end
207
+
208
+ # Show invalid properties with the reasons. Usually used together with valid?
209
+ # @return Array for valid properties with the reasons
210
+ def list_invalid_properties
211
+ invalid_properties = Array.new
212
+ if @code.nil?
213
+ invalid_properties.push('invalid value for "code", code cannot be nil.')
214
+ end
215
+
216
+ if @code.to_s.length > 50
217
+ invalid_properties.push('invalid value for "code", the character length must be smaller than or equal to 50.')
218
+ end
219
+
220
+ if @name.nil?
221
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
222
+ end
223
+
224
+ if @name.to_s.length > 256
225
+ invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 256.')
226
+ end
227
+
228
+ if @type.nil?
229
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
230
+ end
231
+
232
+ if @type.to_s.length > 50
233
+ invalid_properties.push('invalid value for "type", the character length must be smaller than or equal to 50.')
234
+ end
235
+
236
+ if @status.nil?
237
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
238
+ end
239
+
240
+ if @status.to_s.length > 50
241
+ invalid_properties.push('invalid value for "status", the character length must be smaller than or equal to 50.')
242
+ end
243
+
244
+ invalid_properties
245
+ end
246
+
247
+ # Check to see if the all the properties in the model are valid
248
+ # @return true if the model is valid
249
+ def valid?
250
+ return false if @code.nil?
251
+ return false if @code.to_s.length > 50
252
+ return false if @name.nil?
253
+ return false if @name.to_s.length > 256
254
+ return false if @type.nil?
255
+ return false if @type.to_s.length > 50
256
+ return false if @status.nil?
257
+ return false if @status.to_s.length > 50
258
+ _class_validator = EnumAttributeValidator.new('String', ["ASSET", "LIABILITY", "EXPENSE", "EQUITY", "REVENUE"])
259
+ return false unless _class_validator.valid?(@_class)
260
+ true
261
+ end
262
+
263
+ # Custom attribute writer method with validation
264
+ # @param [Object] code Value to be assigned
265
+ def code=(code)
266
+ if code.nil?
267
+ fail ArgumentError, 'code cannot be nil'
268
+ end
269
+
270
+ if code.to_s.length > 50
271
+ fail ArgumentError, 'invalid value for "code", the character length must be smaller than or equal to 50.'
272
+ end
273
+
274
+ @code = code
275
+ end
276
+
277
+ # Custom attribute writer method with validation
278
+ # @param [Object] name Value to be assigned
279
+ def name=(name)
280
+ if name.nil?
281
+ fail ArgumentError, 'name cannot be nil'
282
+ end
283
+
284
+ if name.to_s.length > 256
285
+ fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 256.'
286
+ end
287
+
288
+ @name = name
289
+ end
290
+
291
+ # Custom attribute writer method with validation
292
+ # @param [Object] type Value to be assigned
293
+ def type=(type)
294
+ if type.nil?
295
+ fail ArgumentError, 'type cannot be nil'
296
+ end
297
+
298
+ if type.to_s.length > 50
299
+ fail ArgumentError, 'invalid value for "type", the character length must be smaller than or equal to 50.'
300
+ end
301
+
302
+ @type = type
303
+ end
304
+
305
+ # Custom attribute writer method with validation
306
+ # @param [Object] status Value to be assigned
307
+ def status=(status)
308
+ if status.nil?
309
+ fail ArgumentError, 'status cannot be nil'
310
+ end
311
+
312
+ if status.to_s.length > 50
313
+ fail ArgumentError, 'invalid value for "status", the character length must be smaller than or equal to 50.'
314
+ end
315
+
316
+ @status = status
317
+ end
318
+
319
+ # Custom attribute writer method checking allowed values (enum).
320
+ # @param [Object] _class Object to be assigned
321
+ def _class=(_class)
322
+ validator = EnumAttributeValidator.new('String', ["ASSET", "LIABILITY", "EXPENSE", "EQUITY", "REVENUE"])
323
+ unless validator.valid?(_class)
324
+ fail ArgumentError, "invalid value for \"_class\", must be one of #{validator.allowable_values}."
325
+ end
326
+ @_class = _class
327
+ end
328
+
329
+ # Checks equality by comparing each attribute.
330
+ # @param [Object] Object to be compared
331
+ def ==(o)
332
+ return true if self.equal?(o)
333
+ self.class == o.class &&
334
+ code == o.code &&
335
+ name == o.name &&
336
+ type == o.type &&
337
+ status == o.status &&
338
+ description == o.description &&
339
+ _class == o._class &&
340
+ system_account == o.system_account &&
341
+ system_account_code == o.system_account_code &&
342
+ for_payments == o.for_payments &&
343
+ display_name == o.display_name &&
344
+ old_code == o.old_code &&
345
+ bank == o.bank &&
346
+ bank_account_number == o.bank_account_number &&
347
+ bank_account_id == o.bank_account_id &&
348
+ currency == o.currency
349
+ end
350
+
351
+ # @see the `==` method
352
+ # @param [Object] Object to be compared
353
+ def eql?(o)
354
+ self == o
355
+ end
356
+
357
+ # Calculates hash code according to all attributes.
358
+ # @return [Integer] Hash code
359
+ def hash
360
+ [code, name, type, status, description, _class, system_account, system_account_code, for_payments, display_name, old_code, bank, bank_account_number, bank_account_id, currency].hash
361
+ end
362
+
363
+ # Builds the object from hash
364
+ # @param [Hash] attributes Model attributes in the form of hash
365
+ # @return [Object] Returns the model itself
366
+ def self.build_from_hash(attributes)
367
+ new.build_from_hash(attributes)
368
+ end
369
+
370
+ # Builds the object from hash
371
+ # @param [Hash] attributes Model attributes in the form of hash
372
+ # @return [Object] Returns the model itself
373
+ def build_from_hash(attributes)
374
+ return nil unless attributes.is_a?(Hash)
375
+ self.class.openapi_types.each_pair do |key, type|
376
+ if type =~ /\AArray<(.*)>/i
377
+ # check to ensure the input is an array given that the attribute
378
+ # is documented as an array but the input is not
379
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
380
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
381
+ end
382
+ elsif !attributes[self.class.attribute_map[key]].nil?
383
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
384
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
385
+ end
386
+
387
+ self
388
+ end
389
+
390
+ # Deserializes the data based on type
391
+ # @param string type Data type
392
+ # @param string value Value to be deserialized
393
+ # @return [Object] Deserialized data
394
+ def _deserialize(type, value)
395
+ case type.to_sym
396
+ when :DateTime
397
+ DateTime.parse(value)
398
+ when :Date
399
+ Date.parse(value)
400
+ when :String
401
+ value.to_s
402
+ when :Integer
403
+ value.to_i
404
+ when :Float
405
+ value.to_f
406
+ when :Boolean
407
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
408
+ true
409
+ else
410
+ false
411
+ end
412
+ when :Object
413
+ # generic object (usually a Hash), return directly
414
+ value
415
+ when /\AArray<(?<inner_type>.+)>\z/
416
+ inner_type = Regexp.last_match[:inner_type]
417
+ value.map { |v| _deserialize(inner_type, v) }
418
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
419
+ k_type = Regexp.last_match[:k_type]
420
+ v_type = Regexp.last_match[:v_type]
421
+ {}.tap do |hash|
422
+ value.each do |k, v|
423
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
424
+ end
425
+ end
426
+ else # model
427
+ DearInventoryRuby.const_get(type).build_from_hash(value)
428
+ end
429
+ end
430
+
431
+ # Returns the string representation of the object
432
+ # @return [String] String presentation of the object
433
+ def to_s
434
+ to_hash.to_s
435
+ end
436
+
437
+ # to_body is an alias to to_hash (backward compatibility)
438
+ # @return [Hash] Returns the object in the form of hash
439
+ def to_body
440
+ to_hash
441
+ end
442
+
443
+ # Returns the object in the form of hash
444
+ # @return [Hash] Returns the object in the form of hash
445
+ def to_hash
446
+ hash = {}
447
+ self.class.attribute_map.each_pair do |attr, param|
448
+ value = self.send(attr)
449
+ if value.nil?
450
+ is_nullable = self.class.openapi_nullable.include?(attr)
451
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
452
+ end
453
+
454
+ hash[param] = _to_hash(value)
455
+ end
456
+ hash
457
+ end
458
+
459
+ # Outputs non-array value in the form of hash
460
+ # For object, use to_hash. Otherwise, just return the value
461
+ # @param [Object] value Any valid value
462
+ # @return [Hash] Returns the value in the form of hash
463
+ def _to_hash(value)
464
+ if value.is_a?(Array)
465
+ value.compact.map { |v| _to_hash(v) }
466
+ elsif value.is_a?(Hash)
467
+ {}.tap do |hash|
468
+ value.each { |k, v| hash[k] = _to_hash(v) }
469
+ end
470
+ elsif value.respond_to? :to_hash
471
+ value.to_hash
472
+ else
473
+ value
474
+ end
475
+ end
476
+ end
477
+ end