dear-inventory-ruby 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,574 @@
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.2.3
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module DearInventoryRuby
16
+ class Customer
17
+ # Unique Customer ID
18
+ attr_accessor :id
19
+
20
+ # Name of Customer
21
+ attr_accessor :name
22
+
23
+ # Points that Customer is Active. Available values are Active and Deprecated. Required for POST
24
+ attr_accessor :status
25
+
26
+ attr_accessor :currency
27
+
28
+ # Payment term
29
+ attr_accessor :payment_term
30
+
31
+ # Account receivable code of Customer
32
+ attr_accessor :account_receivable
33
+
34
+ # Sale account code of Customer
35
+ attr_accessor :revenue_account
36
+
37
+ # Tax rule name
38
+ attr_accessor :tax_rule
39
+
40
+ # Price tier
41
+ attr_accessor :price_tier
42
+
43
+ # Carrier name
44
+ attr_accessor :carrier
45
+
46
+ # Sales representative
47
+ attr_accessor :sales_representative
48
+
49
+ # Location
50
+ attr_accessor :location
51
+
52
+ # Discount must be between 0% and 100%
53
+ attr_accessor :discount
54
+
55
+ # Comments
56
+ attr_accessor :comments
57
+
58
+ # Tax number
59
+ attr_accessor :tax_number
60
+
61
+ # Credit limit
62
+ attr_accessor :credit_limit
63
+
64
+ # Tags string
65
+ attr_accessor :tags
66
+
67
+ # AttributeSet name
68
+ attr_accessor :attribute_set
69
+
70
+ # Additional attribute 1 value
71
+ attr_accessor :additional_attribute1
72
+
73
+ # Additional attribute 2 value
74
+ attr_accessor :additional_attribute2
75
+
76
+ # Additional attribute 3 value
77
+ attr_accessor :additional_attribute3
78
+
79
+ # Additional attribute 4 value
80
+ attr_accessor :additional_attribute4
81
+
82
+ # Additional attribute 5 value
83
+ attr_accessor :additional_attribute5
84
+
85
+ # Additional attribute 6 value
86
+ attr_accessor :additional_attribute6
87
+
88
+ # Additional attribute 7 value
89
+ attr_accessor :additional_attribute7
90
+
91
+ # Additional attribute 8 value
92
+ attr_accessor :additional_attribute8
93
+
94
+ # Additional attribute 9 value
95
+ attr_accessor :additional_attribute9
96
+
97
+ # Additional attribute 10 value
98
+ attr_accessor :additional_attribute10
99
+
100
+ # Date of last modification
101
+ attr_accessor :last_modified_on
102
+
103
+ # List of addresses
104
+ attr_accessor :addresses
105
+
106
+ # List of contacts
107
+ attr_accessor :contacts
108
+
109
+ class EnumAttributeValidator
110
+ attr_reader :datatype
111
+ attr_reader :allowable_values
112
+
113
+ def initialize(datatype, allowable_values)
114
+ @allowable_values = allowable_values.map do |value|
115
+ case datatype.to_s
116
+ when /Integer/i
117
+ value.to_i
118
+ when /Float/i
119
+ value.to_f
120
+ else
121
+ value
122
+ end
123
+ end
124
+ end
125
+
126
+ def valid?(value)
127
+ !value || allowable_values.include?(value)
128
+ end
129
+ end
130
+
131
+ # Attribute mapping from ruby-style variable name to JSON key.
132
+ def self.attribute_map
133
+ {
134
+ :'id' => :'ID',
135
+ :'name' => :'Name',
136
+ :'status' => :'Status',
137
+ :'currency' => :'Currency',
138
+ :'payment_term' => :'PaymentTerm',
139
+ :'account_receivable' => :'AccountReceivable',
140
+ :'revenue_account' => :'RevenueAccount',
141
+ :'tax_rule' => :'TaxRule',
142
+ :'price_tier' => :'PriceTier',
143
+ :'carrier' => :'Carrier',
144
+ :'sales_representative' => :'SalesRepresentative',
145
+ :'location' => :'Location',
146
+ :'discount' => :'Discount',
147
+ :'comments' => :'Comments',
148
+ :'tax_number' => :'TaxNumber',
149
+ :'credit_limit' => :'CreditLimit',
150
+ :'tags' => :'Tags',
151
+ :'attribute_set' => :'AttributeSet',
152
+ :'additional_attribute1' => :'AdditionalAttribute1',
153
+ :'additional_attribute2' => :'AdditionalAttribute2',
154
+ :'additional_attribute3' => :'AdditionalAttribute3',
155
+ :'additional_attribute4' => :'AdditionalAttribute4',
156
+ :'additional_attribute5' => :'AdditionalAttribute5',
157
+ :'additional_attribute6' => :'AdditionalAttribute6',
158
+ :'additional_attribute7' => :'AdditionalAttribute7',
159
+ :'additional_attribute8' => :'AdditionalAttribute8',
160
+ :'additional_attribute9' => :'AdditionalAttribute9',
161
+ :'additional_attribute10' => :'AdditionalAttribute10',
162
+ :'last_modified_on' => :'LastModifiedOn',
163
+ :'addresses' => :'Addresses',
164
+ :'contacts' => :'Contacts'
165
+ }
166
+ end
167
+
168
+ # Attribute type mapping.
169
+ def self.openapi_types
170
+ {
171
+ :'id' => :'String',
172
+ :'name' => :'String',
173
+ :'status' => :'String',
174
+ :'currency' => :'CurrencyCode',
175
+ :'payment_term' => :'String',
176
+ :'account_receivable' => :'String',
177
+ :'revenue_account' => :'String',
178
+ :'tax_rule' => :'String',
179
+ :'price_tier' => :'String',
180
+ :'carrier' => :'String',
181
+ :'sales_representative' => :'String',
182
+ :'location' => :'String',
183
+ :'discount' => :'Float',
184
+ :'comments' => :'String',
185
+ :'tax_number' => :'String',
186
+ :'credit_limit' => :'Float',
187
+ :'tags' => :'String',
188
+ :'attribute_set' => :'String',
189
+ :'additional_attribute1' => :'String',
190
+ :'additional_attribute2' => :'String',
191
+ :'additional_attribute3' => :'String',
192
+ :'additional_attribute4' => :'String',
193
+ :'additional_attribute5' => :'String',
194
+ :'additional_attribute6' => :'String',
195
+ :'additional_attribute7' => :'String',
196
+ :'additional_attribute8' => :'String',
197
+ :'additional_attribute9' => :'String',
198
+ :'additional_attribute10' => :'String',
199
+ :'last_modified_on' => :'String',
200
+ :'addresses' => :'Array<Address>',
201
+ :'contacts' => :'Array<Contact>'
202
+ }
203
+ end
204
+
205
+ # List of attributes with nullable: true
206
+ def self.openapi_nullable
207
+ Set.new([
208
+ ])
209
+ end
210
+
211
+ # Initializes the object
212
+ # @param [Hash] attributes Model attributes in the form of hash
213
+ def initialize(attributes = {})
214
+ if (!attributes.is_a?(Hash))
215
+ fail ArgumentError, "The input argument (attributes) must be a hash in `DearInventoryRuby::Customer` initialize method"
216
+ end
217
+
218
+ # check to see if the attribute exists and convert string to symbol for hash key
219
+ attributes = attributes.each_with_object({}) { |(k, v), h|
220
+ if (!self.class.attribute_map.key?(k.to_sym))
221
+ fail ArgumentError, "`#{k}` is not a valid attribute in `DearInventoryRuby::Customer`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
222
+ end
223
+ h[k.to_sym] = v
224
+ }
225
+
226
+ if attributes.key?(:'id')
227
+ self.id = attributes[:'id']
228
+ end
229
+
230
+ if attributes.key?(:'name')
231
+ self.name = attributes[:'name']
232
+ end
233
+
234
+ if attributes.key?(:'status')
235
+ self.status = attributes[:'status']
236
+ end
237
+
238
+ if attributes.key?(:'currency')
239
+ self.currency = attributes[:'currency']
240
+ end
241
+
242
+ if attributes.key?(:'payment_term')
243
+ self.payment_term = attributes[:'payment_term']
244
+ end
245
+
246
+ if attributes.key?(:'account_receivable')
247
+ self.account_receivable = attributes[:'account_receivable']
248
+ end
249
+
250
+ if attributes.key?(:'revenue_account')
251
+ self.revenue_account = attributes[:'revenue_account']
252
+ end
253
+
254
+ if attributes.key?(:'tax_rule')
255
+ self.tax_rule = attributes[:'tax_rule']
256
+ end
257
+
258
+ if attributes.key?(:'price_tier')
259
+ self.price_tier = attributes[:'price_tier']
260
+ end
261
+
262
+ if attributes.key?(:'carrier')
263
+ self.carrier = attributes[:'carrier']
264
+ end
265
+
266
+ if attributes.key?(:'sales_representative')
267
+ self.sales_representative = attributes[:'sales_representative']
268
+ end
269
+
270
+ if attributes.key?(:'location')
271
+ self.location = attributes[:'location']
272
+ end
273
+
274
+ if attributes.key?(:'discount')
275
+ self.discount = attributes[:'discount']
276
+ end
277
+
278
+ if attributes.key?(:'comments')
279
+ self.comments = attributes[:'comments']
280
+ end
281
+
282
+ if attributes.key?(:'tax_number')
283
+ self.tax_number = attributes[:'tax_number']
284
+ end
285
+
286
+ if attributes.key?(:'credit_limit')
287
+ self.credit_limit = attributes[:'credit_limit']
288
+ end
289
+
290
+ if attributes.key?(:'tags')
291
+ self.tags = attributes[:'tags']
292
+ end
293
+
294
+ if attributes.key?(:'attribute_set')
295
+ self.attribute_set = attributes[:'attribute_set']
296
+ end
297
+
298
+ if attributes.key?(:'additional_attribute1')
299
+ self.additional_attribute1 = attributes[:'additional_attribute1']
300
+ end
301
+
302
+ if attributes.key?(:'additional_attribute2')
303
+ self.additional_attribute2 = attributes[:'additional_attribute2']
304
+ end
305
+
306
+ if attributes.key?(:'additional_attribute3')
307
+ self.additional_attribute3 = attributes[:'additional_attribute3']
308
+ end
309
+
310
+ if attributes.key?(:'additional_attribute4')
311
+ self.additional_attribute4 = attributes[:'additional_attribute4']
312
+ end
313
+
314
+ if attributes.key?(:'additional_attribute5')
315
+ self.additional_attribute5 = attributes[:'additional_attribute5']
316
+ end
317
+
318
+ if attributes.key?(:'additional_attribute6')
319
+ self.additional_attribute6 = attributes[:'additional_attribute6']
320
+ end
321
+
322
+ if attributes.key?(:'additional_attribute7')
323
+ self.additional_attribute7 = attributes[:'additional_attribute7']
324
+ end
325
+
326
+ if attributes.key?(:'additional_attribute8')
327
+ self.additional_attribute8 = attributes[:'additional_attribute8']
328
+ end
329
+
330
+ if attributes.key?(:'additional_attribute9')
331
+ self.additional_attribute9 = attributes[:'additional_attribute9']
332
+ end
333
+
334
+ if attributes.key?(:'additional_attribute10')
335
+ self.additional_attribute10 = attributes[:'additional_attribute10']
336
+ end
337
+
338
+ if attributes.key?(:'last_modified_on')
339
+ self.last_modified_on = attributes[:'last_modified_on']
340
+ end
341
+
342
+ if attributes.key?(:'addresses')
343
+ if (value = attributes[:'addresses']).is_a?(Array)
344
+ self.addresses = value
345
+ end
346
+ end
347
+
348
+ if attributes.key?(:'contacts')
349
+ if (value = attributes[:'contacts']).is_a?(Array)
350
+ self.contacts = value
351
+ end
352
+ end
353
+ end
354
+
355
+ # Show invalid properties with the reasons. Usually used together with valid?
356
+ # @return Array for valid properties with the reasons
357
+ def list_invalid_properties
358
+ invalid_properties = Array.new
359
+ if !@name.nil? && @name.to_s.length > 256
360
+ invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 256.')
361
+ end
362
+
363
+ if !@comments.nil? && @comments.to_s.length > 256
364
+ invalid_properties.push('invalid value for "comments", the character length must be smaller than or equal to 256.')
365
+ end
366
+
367
+ invalid_properties
368
+ end
369
+
370
+ # Check to see if the all the properties in the model are valid
371
+ # @return true if the model is valid
372
+ def valid?
373
+ return false if !@name.nil? && @name.to_s.length > 256
374
+ status_validator = EnumAttributeValidator.new('String', ["Active", "Deprecated"])
375
+ return false unless status_validator.valid?(@status)
376
+ return false if !@comments.nil? && @comments.to_s.length > 256
377
+ true
378
+ end
379
+
380
+ # Custom attribute writer method with validation
381
+ # @param [Object] name Value to be assigned
382
+ def name=(name)
383
+ if !name.nil? && name.to_s.length > 256
384
+ fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 256.'
385
+ end
386
+
387
+ @name = name
388
+ end
389
+
390
+ # Custom attribute writer method checking allowed values (enum).
391
+ # @param [Object] status Object to be assigned
392
+ def status=(status)
393
+ validator = EnumAttributeValidator.new('String', ["Active", "Deprecated"])
394
+ unless validator.valid?(status)
395
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
396
+ end
397
+ @status = status
398
+ end
399
+
400
+ # Custom attribute writer method with validation
401
+ # @param [Object] comments Value to be assigned
402
+ def comments=(comments)
403
+ if !comments.nil? && comments.to_s.length > 256
404
+ fail ArgumentError, 'invalid value for "comments", the character length must be smaller than or equal to 256.'
405
+ end
406
+
407
+ @comments = comments
408
+ end
409
+
410
+ # Checks equality by comparing each attribute.
411
+ # @param [Object] Object to be compared
412
+ def ==(o)
413
+ return true if self.equal?(o)
414
+ self.class == o.class &&
415
+ id == o.id &&
416
+ name == o.name &&
417
+ status == o.status &&
418
+ currency == o.currency &&
419
+ payment_term == o.payment_term &&
420
+ account_receivable == o.account_receivable &&
421
+ revenue_account == o.revenue_account &&
422
+ tax_rule == o.tax_rule &&
423
+ price_tier == o.price_tier &&
424
+ carrier == o.carrier &&
425
+ sales_representative == o.sales_representative &&
426
+ location == o.location &&
427
+ discount == o.discount &&
428
+ comments == o.comments &&
429
+ tax_number == o.tax_number &&
430
+ credit_limit == o.credit_limit &&
431
+ tags == o.tags &&
432
+ attribute_set == o.attribute_set &&
433
+ additional_attribute1 == o.additional_attribute1 &&
434
+ additional_attribute2 == o.additional_attribute2 &&
435
+ additional_attribute3 == o.additional_attribute3 &&
436
+ additional_attribute4 == o.additional_attribute4 &&
437
+ additional_attribute5 == o.additional_attribute5 &&
438
+ additional_attribute6 == o.additional_attribute6 &&
439
+ additional_attribute7 == o.additional_attribute7 &&
440
+ additional_attribute8 == o.additional_attribute8 &&
441
+ additional_attribute9 == o.additional_attribute9 &&
442
+ additional_attribute10 == o.additional_attribute10 &&
443
+ last_modified_on == o.last_modified_on &&
444
+ addresses == o.addresses &&
445
+ contacts == o.contacts
446
+ end
447
+
448
+ # @see the `==` method
449
+ # @param [Object] Object to be compared
450
+ def eql?(o)
451
+ self == o
452
+ end
453
+
454
+ # Calculates hash code according to all attributes.
455
+ # @return [Integer] Hash code
456
+ def hash
457
+ [id, name, status, currency, payment_term, account_receivable, revenue_account, tax_rule, price_tier, carrier, sales_representative, location, discount, comments, tax_number, credit_limit, tags, attribute_set, additional_attribute1, additional_attribute2, additional_attribute3, additional_attribute4, additional_attribute5, additional_attribute6, additional_attribute7, additional_attribute8, additional_attribute9, additional_attribute10, last_modified_on, addresses, contacts].hash
458
+ end
459
+
460
+ # Builds the object from hash
461
+ # @param [Hash] attributes Model attributes in the form of hash
462
+ # @return [Object] Returns the model itself
463
+ def self.build_from_hash(attributes)
464
+ new.build_from_hash(attributes)
465
+ end
466
+
467
+ # Builds the object from hash
468
+ # @param [Hash] attributes Model attributes in the form of hash
469
+ # @return [Object] Returns the model itself
470
+ def build_from_hash(attributes)
471
+ return nil unless attributes.is_a?(Hash)
472
+ self.class.openapi_types.each_pair do |key, type|
473
+ if type =~ /\AArray<(.*)>/i
474
+ # check to ensure the input is an array given that the attribute
475
+ # is documented as an array but the input is not
476
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
477
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
478
+ end
479
+ elsif !attributes[self.class.attribute_map[key]].nil?
480
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
481
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
482
+ end
483
+
484
+ self
485
+ end
486
+
487
+ # Deserializes the data based on type
488
+ # @param string type Data type
489
+ # @param string value Value to be deserialized
490
+ # @return [Object] Deserialized data
491
+ def _deserialize(type, value)
492
+ case type.to_sym
493
+ when :DateTime
494
+ DateTime.parse(value)
495
+ when :Date
496
+ Date.parse(value)
497
+ when :String
498
+ value.to_s
499
+ when :Integer
500
+ value.to_i
501
+ when :Float
502
+ value.to_f
503
+ when :Boolean
504
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
505
+ true
506
+ else
507
+ false
508
+ end
509
+ when :Object
510
+ # generic object (usually a Hash), return directly
511
+ value
512
+ when /\AArray<(?<inner_type>.+)>\z/
513
+ inner_type = Regexp.last_match[:inner_type]
514
+ value.map { |v| _deserialize(inner_type, v) }
515
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
516
+ k_type = Regexp.last_match[:k_type]
517
+ v_type = Regexp.last_match[:v_type]
518
+ {}.tap do |hash|
519
+ value.each do |k, v|
520
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
521
+ end
522
+ end
523
+ else # model
524
+ DearInventoryRuby.const_get(type).build_from_hash(value)
525
+ end
526
+ end
527
+
528
+ # Returns the string representation of the object
529
+ # @return [String] String presentation of the object
530
+ def to_s
531
+ to_hash.to_s
532
+ end
533
+
534
+ # to_body is an alias to to_hash (backward compatibility)
535
+ # @return [Hash] Returns the object in the form of hash
536
+ def to_body
537
+ to_hash
538
+ end
539
+
540
+ # Returns the object in the form of hash
541
+ # @return [Hash] Returns the object in the form of hash
542
+ def to_hash
543
+ hash = {}
544
+ self.class.attribute_map.each_pair do |attr, param|
545
+ value = self.send(attr)
546
+ if value.nil?
547
+ is_nullable = self.class.openapi_nullable.include?(attr)
548
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
549
+ end
550
+
551
+ hash[param] = _to_hash(value)
552
+ end
553
+ hash
554
+ end
555
+
556
+ # Outputs non-array value in the form of hash
557
+ # For object, use to_hash. Otherwise, just return the value
558
+ # @param [Object] value Any valid value
559
+ # @return [Hash] Returns the value in the form of hash
560
+ def _to_hash(value)
561
+ if value.is_a?(Array)
562
+ value.compact.map { |v| _to_hash(v) }
563
+ elsif value.is_a?(Hash)
564
+ {}.tap do |hash|
565
+ value.each { |k, v| hash[k] = _to_hash(v) }
566
+ end
567
+ elsif value.respond_to? :to_hash
568
+ value.to_hash
569
+ else
570
+ value
571
+ end
572
+ end
573
+ end
574
+ end