dear-inventory-ruby 0.1.7 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -0
  3. data/Gemfile +1 -1
  4. data/README.md +11 -4
  5. data/dear-inventory-ruby.gemspec +1 -1
  6. data/docs/Account.md +18 -16
  7. data/docs/Accounts.md +3 -3
  8. data/docs/Address.md +9 -9
  9. data/docs/Contact.md +13 -9
  10. data/docs/Customer.md +33 -31
  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 +108 -0
  15. data/docs/Me.md +29 -0
  16. data/docs/PaymentTerm.md +6 -6
  17. data/docs/PaymentTerms.md +3 -3
  18. data/docs/PriceTier.md +19 -0
  19. data/docs/PriceTiers.md +17 -0
  20. data/docs/Success.md +1 -1
  21. data/docs/Tax.md +9 -9
  22. data/docs/TaxComponent.md +4 -4
  23. data/docs/Taxes.md +3 -3
  24. data/docs/WeightUnit.md +16 -0
  25. data/lib/dear-inventory-ruby.rb +6 -1
  26. data/lib/dear-inventory-ruby/api/inventory_api.rb +109 -1
  27. data/lib/dear-inventory-ruby/api_client.rb +8 -6
  28. data/lib/dear-inventory-ruby/api_error.rb +1 -1
  29. data/lib/dear-inventory-ruby/configuration.rb +1 -1
  30. data/lib/dear-inventory-ruby/models/account.rb +23 -23
  31. data/lib/dear-inventory-ruby/models/accounts.rb +1 -1
  32. data/lib/dear-inventory-ruby/models/address.rb +1 -35
  33. data/lib/dear-inventory-ruby/models/contact.rb +22 -2
  34. data/lib/dear-inventory-ruby/models/currency_code.rb +1 -1
  35. data/lib/dear-inventory-ruby/models/customer.rb +19 -7
  36. data/lib/dear-inventory-ruby/models/customers.rb +1 -1
  37. data/lib/dear-inventory-ruby/models/dimensions_unit.rb +42 -0
  38. data/lib/dear-inventory-ruby/models/error.rb +1 -1
  39. data/lib/dear-inventory-ruby/models/me.rb +264 -0
  40. data/lib/dear-inventory-ruby/models/payment_term.rb +1 -1
  41. data/lib/dear-inventory-ruby/models/payment_terms.rb +1 -1
  42. data/lib/dear-inventory-ruby/models/price_tier.rb +217 -0
  43. data/lib/dear-inventory-ruby/models/price_tiers.rb +209 -0
  44. data/lib/dear-inventory-ruby/models/success.rb +1 -1
  45. data/lib/dear-inventory-ruby/models/tax.rb +1 -1
  46. data/lib/dear-inventory-ruby/models/tax_component.rb +1 -1
  47. data/lib/dear-inventory-ruby/models/taxes.rb +1 -1
  48. data/lib/dear-inventory-ruby/models/weight_unit.rb +39 -0
  49. data/lib/dear-inventory-ruby/version.rb +2 -2
  50. data/spec/api/inventory_api_spec.rb +21 -1
  51. data/spec/api_client_spec.rb +2 -2
  52. data/spec/configuration_spec.rb +1 -1
  53. data/spec/models/account_spec.rb +7 -9
  54. data/spec/models/accounts_spec.rb +1 -1
  55. data/spec/models/address_spec.rb +1 -5
  56. data/spec/models/contact_spec.rb +13 -1
  57. data/spec/models/currency_code_spec.rb +1 -1
  58. data/spec/models/customer_spec.rb +7 -1
  59. data/spec/models/customers_spec.rb +1 -1
  60. data/spec/models/dimensions_unit_spec.rb +35 -0
  61. data/spec/models/error_spec.rb +1 -1
  62. data/spec/models/me_spec.rb +77 -0
  63. data/spec/models/payment_term_spec.rb +1 -1
  64. data/spec/models/payment_terms_spec.rb +1 -1
  65. data/spec/models/price_tier_spec.rb +47 -0
  66. data/spec/models/price_tiers_spec.rb +41 -0
  67. data/spec/models/success_spec.rb +1 -1
  68. data/spec/models/tax_component_spec.rb +1 -1
  69. data/spec/models/tax_spec.rb +1 -1
  70. data/spec/models/taxes_spec.rb +1 -1
  71. data/spec/models/weight_unit_spec.rb +35 -0
  72. data/spec/spec_helper.rb +1 -1
  73. metadata +35 -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
 
@@ -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
 
@@ -41,28 +41,6 @@ module DearInventoryRuby
41
41
  # Points that Address is used as default for chosen Type. `false` as default.
42
42
  attr_accessor :default_for_type
43
43
 
44
- class EnumAttributeValidator
45
- attr_reader :datatype
46
- attr_reader :allowable_values
47
-
48
- def initialize(datatype, allowable_values)
49
- @allowable_values = allowable_values.map do |value|
50
- case datatype.to_s
51
- when /Integer/i
52
- value.to_i
53
- when /Float/i
54
- value.to_f
55
- else
56
- value
57
- end
58
- end
59
- end
60
-
61
- def valid?(value)
62
- !value || allowable_values.include?(value)
63
- end
64
- end
65
-
66
44
  # Attribute mapping from ruby-style variable name to JSON key.
67
45
  def self.attribute_map
68
46
  {
@@ -198,8 +176,6 @@ module DearInventoryRuby
198
176
  return false if !@post_code.nil? && @post_code.to_s.length > 20
199
177
  return false if @country.nil?
200
178
  return false if @type.nil?
201
- type_validator = EnumAttributeValidator.new('String', ["Billing", "Business", "Shipping"])
202
- return false unless type_validator.valid?(@type)
203
179
  true
204
180
  end
205
181
 
@@ -253,16 +229,6 @@ module DearInventoryRuby
253
229
  @post_code = post_code
254
230
  end
255
231
 
256
- # Custom attribute writer method checking allowed values (enum).
257
- # @param [Object] type Object to be assigned
258
- def type=(type)
259
- validator = EnumAttributeValidator.new('String', ["Billing", "Business", "Shipping"])
260
- unless validator.valid?(type)
261
- fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
262
- end
263
- @type = type
264
- end
265
-
266
232
  # Checks equality by comparing each attribute.
267
233
  # @param [Object] Object to be compared
268
234
  def ==(o)
@@ -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
 
@@ -20,9 +20,15 @@ module DearInventoryRuby
20
20
  # Name of Contact
21
21
  attr_accessor :name
22
22
 
23
+ # Job Title
24
+ attr_accessor :job_title
25
+
23
26
  # Phone
24
27
  attr_accessor :phone
25
28
 
29
+ # Mobile Phone
30
+ attr_accessor :mobile_phone
31
+
26
32
  # Fax
27
33
  attr_accessor :fax
28
34
 
@@ -46,7 +52,9 @@ module DearInventoryRuby
46
52
  {
47
53
  :'id' => :'ID',
48
54
  :'name' => :'Name',
55
+ :'job_title' => :'JobTitle',
49
56
  :'phone' => :'Phone',
57
+ :'mobile_phone' => :'MobilePhone',
50
58
  :'fax' => :'Fax',
51
59
  :'email' => :'Email',
52
60
  :'website' => :'Website',
@@ -61,7 +69,9 @@ module DearInventoryRuby
61
69
  {
62
70
  :'id' => :'String',
63
71
  :'name' => :'String',
72
+ :'job_title' => :'String',
64
73
  :'phone' => :'String',
74
+ :'mobile_phone' => :'String',
65
75
  :'fax' => :'String',
66
76
  :'email' => :'String',
67
77
  :'website' => :'String',
@@ -100,10 +110,18 @@ module DearInventoryRuby
100
110
  self.name = attributes[:'name']
101
111
  end
102
112
 
113
+ if attributes.key?(:'job_title')
114
+ self.job_title = attributes[:'job_title']
115
+ end
116
+
103
117
  if attributes.key?(:'phone')
104
118
  self.phone = attributes[:'phone']
105
119
  end
106
120
 
121
+ if attributes.key?(:'mobile_phone')
122
+ self.mobile_phone = attributes[:'mobile_phone']
123
+ end
124
+
107
125
  if attributes.key?(:'fax')
108
126
  self.fax = attributes[:'fax']
109
127
  end
@@ -252,7 +270,9 @@ module DearInventoryRuby
252
270
  self.class == o.class &&
253
271
  id == o.id &&
254
272
  name == o.name &&
273
+ job_title == o.job_title &&
255
274
  phone == o.phone &&
275
+ mobile_phone == o.mobile_phone &&
256
276
  fax == o.fax &&
257
277
  email == o.email &&
258
278
  website == o.website &&
@@ -270,7 +290,7 @@ module DearInventoryRuby
270
290
  # Calculates hash code according to all attributes.
271
291
  # @return [Integer] Hash code
272
292
  def hash
273
- [id, name, phone, fax, email, website, comment, default, include_in_email].hash
293
+ [id, name, job_title, phone, mobile_phone, fax, email, website, comment, default, include_in_email].hash
274
294
  end
275
295
 
276
296
  # Builds the object from hash
@@ -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
 
@@ -61,6 +61,9 @@ module DearInventoryRuby
61
61
  # Credit limit
62
62
  attr_accessor :credit_limit
63
63
 
64
+ # boolean to indicate if a customer is on credit hold
65
+ attr_accessor :is_on_credit_hold
66
+
64
67
  # Tags string
65
68
  attr_accessor :tags
66
69
 
@@ -147,6 +150,7 @@ module DearInventoryRuby
147
150
  :'comments' => :'Comments',
148
151
  :'tax_number' => :'TaxNumber',
149
152
  :'credit_limit' => :'CreditLimit',
153
+ :'is_on_credit_hold' => :'IsOnCreditHold',
150
154
  :'tags' => :'Tags',
151
155
  :'attribute_set' => :'AttributeSet',
152
156
  :'additional_attribute1' => :'AdditionalAttribute1',
@@ -184,6 +188,7 @@ module DearInventoryRuby
184
188
  :'comments' => :'String',
185
189
  :'tax_number' => :'String',
186
190
  :'credit_limit' => :'Float',
191
+ :'is_on_credit_hold' => :'Boolean',
187
192
  :'tags' => :'String',
188
193
  :'attribute_set' => :'String',
189
194
  :'additional_attribute1' => :'String',
@@ -287,6 +292,12 @@ module DearInventoryRuby
287
292
  self.credit_limit = attributes[:'credit_limit']
288
293
  end
289
294
 
295
+ if attributes.key?(:'is_on_credit_hold')
296
+ self.is_on_credit_hold = attributes[:'is_on_credit_hold']
297
+ else
298
+ self.is_on_credit_hold = false
299
+ end
300
+
290
301
  if attributes.key?(:'tags')
291
302
  self.tags = attributes[:'tags']
292
303
  end
@@ -388,8 +399,8 @@ module DearInventoryRuby
388
399
  invalid_properties.push('invalid value for "tax_rule", tax_rule cannot be nil.')
389
400
  end
390
401
 
391
- if !@comments.nil? && @comments.to_s.length > 256
392
- invalid_properties.push('invalid value for "comments", the character length must be smaller than or equal to 256.')
402
+ if !@comments.nil? && @comments.to_s.length > 2000
403
+ invalid_properties.push('invalid value for "comments", the character length must be smaller than or equal to 2000.')
393
404
  end
394
405
 
395
406
  invalid_properties
@@ -408,7 +419,7 @@ module DearInventoryRuby
408
419
  return false if @account_receivable.nil?
409
420
  return false if @revenue_account.nil?
410
421
  return false if @tax_rule.nil?
411
- return false if !@comments.nil? && @comments.to_s.length > 256
422
+ return false if !@comments.nil? && @comments.to_s.length > 2000
412
423
  true
413
424
  end
414
425
 
@@ -439,8 +450,8 @@ module DearInventoryRuby
439
450
  # Custom attribute writer method with validation
440
451
  # @param [Object] comments Value to be assigned
441
452
  def comments=(comments)
442
- if !comments.nil? && comments.to_s.length > 256
443
- fail ArgumentError, 'invalid value for "comments", the character length must be smaller than or equal to 256.'
453
+ if !comments.nil? && comments.to_s.length > 2000
454
+ fail ArgumentError, 'invalid value for "comments", the character length must be smaller than or equal to 2000.'
444
455
  end
445
456
 
446
457
  @comments = comments
@@ -467,6 +478,7 @@ module DearInventoryRuby
467
478
  comments == o.comments &&
468
479
  tax_number == o.tax_number &&
469
480
  credit_limit == o.credit_limit &&
481
+ is_on_credit_hold == o.is_on_credit_hold &&
470
482
  tags == o.tags &&
471
483
  attribute_set == o.attribute_set &&
472
484
  additional_attribute1 == o.additional_attribute1 &&
@@ -493,7 +505,7 @@ module DearInventoryRuby
493
505
  # Calculates hash code according to all attributes.
494
506
  # @return [Integer] Hash code
495
507
  def hash
496
- [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
508
+ [id, name, status, currency, payment_term, account_receivable, revenue_account, tax_rule, price_tier, carrier, sales_representative, location, discount, comments, tax_number, credit_limit, is_on_credit_hold, 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
497
509
  end
498
510
 
499
511
  # Builds the object from hash
@@ -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,42 @@
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 DimensionsUnit
17
+ M = "m".freeze
18
+ CM = "cm".freeze
19
+ MI = "mi".freeze
20
+ MM = "mm".freeze
21
+ IN = "in".freeze
22
+ FT = "ft".freeze
23
+ YD = "yd".freeze
24
+ KM = "km".freeze
25
+
26
+ # Builds the enum from string
27
+ # @param [String] The enum value in the form of the string
28
+ # @return [String] The enum value
29
+ def self.build_from_hash(value)
30
+ new.build_from_hash(value)
31
+ end
32
+
33
+ # Builds the enum from string
34
+ # @param [String] The enum value in the form of the string
35
+ # @return [String] The enum value
36
+ def build_from_hash(value)
37
+ constantValues = DimensionsUnit.constants.select { |c| DimensionsUnit::const_get(c) == value }
38
+ raise "Invalid ENUM value #{value} for class #DimensionsUnit" if constantValues.empty?
39
+ value
40
+ end
41
+ end
42
+ end
@@ -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,264 @@
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 Me
17
+ # Your company name
18
+ attr_accessor :company
19
+
20
+ attr_accessor :currency
21
+
22
+ # Time Zone where your company located
23
+ attr_accessor :time_zone
24
+
25
+ attr_accessor :default_weight_units
26
+
27
+ attr_accessor :default_dimensions_units
28
+
29
+ # Financial settings option. Indicates date period start from what you can change transactional data. Formatted in Tenant date format
30
+ attr_accessor :lock_date
31
+
32
+ # Date of opening balances in the system. Formatted in Tenant date format
33
+ attr_accessor :opening_balance_date
34
+
35
+ # Attribute mapping from ruby-style variable name to JSON key.
36
+ def self.attribute_map
37
+ {
38
+ :'company' => :'Company',
39
+ :'currency' => :'Currency',
40
+ :'time_zone' => :'TimeZone',
41
+ :'default_weight_units' => :'DefaultWeightUnits',
42
+ :'default_dimensions_units' => :'DefaultDimensionsUnits',
43
+ :'lock_date' => :'LockDate',
44
+ :'opening_balance_date' => :'OpeningBalanceDate'
45
+ }
46
+ end
47
+
48
+ # Attribute type mapping.
49
+ def self.openapi_types
50
+ {
51
+ :'company' => :'String',
52
+ :'currency' => :'CurrencyCode',
53
+ :'time_zone' => :'String',
54
+ :'default_weight_units' => :'WeightUnit',
55
+ :'default_dimensions_units' => :'DimensionsUnit',
56
+ :'lock_date' => :'Date',
57
+ :'opening_balance_date' => :'Date'
58
+ }
59
+ end
60
+
61
+ # List of attributes with nullable: true
62
+ def self.openapi_nullable
63
+ Set.new([
64
+ ])
65
+ end
66
+
67
+ # Initializes the object
68
+ # @param [Hash] attributes Model attributes in the form of hash
69
+ def initialize(attributes = {})
70
+ if (!attributes.is_a?(Hash))
71
+ fail ArgumentError, "The input argument (attributes) must be a hash in `DearInventoryRuby::Me` initialize method"
72
+ end
73
+
74
+ # check to see if the attribute exists and convert string to symbol for hash key
75
+ attributes = attributes.each_with_object({}) { |(k, v), h|
76
+ if (!self.class.attribute_map.key?(k.to_sym))
77
+ fail ArgumentError, "`#{k}` is not a valid attribute in `DearInventoryRuby::Me`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
78
+ end
79
+ h[k.to_sym] = v
80
+ }
81
+
82
+ if attributes.key?(:'company')
83
+ self.company = attributes[:'company']
84
+ end
85
+
86
+ if attributes.key?(:'currency')
87
+ self.currency = attributes[:'currency']
88
+ end
89
+
90
+ if attributes.key?(:'time_zone')
91
+ self.time_zone = attributes[:'time_zone']
92
+ end
93
+
94
+ if attributes.key?(:'default_weight_units')
95
+ self.default_weight_units = attributes[:'default_weight_units']
96
+ end
97
+
98
+ if attributes.key?(:'default_dimensions_units')
99
+ self.default_dimensions_units = attributes[:'default_dimensions_units']
100
+ end
101
+
102
+ if attributes.key?(:'lock_date')
103
+ self.lock_date = attributes[:'lock_date']
104
+ end
105
+
106
+ if attributes.key?(:'opening_balance_date')
107
+ self.opening_balance_date = attributes[:'opening_balance_date']
108
+ end
109
+ end
110
+
111
+ # Show invalid properties with the reasons. Usually used together with valid?
112
+ # @return Array for valid properties with the reasons
113
+ def list_invalid_properties
114
+ invalid_properties = Array.new
115
+ invalid_properties
116
+ end
117
+
118
+ # Check to see if the all the properties in the model are valid
119
+ # @return true if the model is valid
120
+ def valid?
121
+ true
122
+ end
123
+
124
+ # Checks equality by comparing each attribute.
125
+ # @param [Object] Object to be compared
126
+ def ==(o)
127
+ return true if self.equal?(o)
128
+ self.class == o.class &&
129
+ company == o.company &&
130
+ currency == o.currency &&
131
+ time_zone == o.time_zone &&
132
+ default_weight_units == o.default_weight_units &&
133
+ default_dimensions_units == o.default_dimensions_units &&
134
+ lock_date == o.lock_date &&
135
+ opening_balance_date == o.opening_balance_date
136
+ end
137
+
138
+ # @see the `==` method
139
+ # @param [Object] Object to be compared
140
+ def eql?(o)
141
+ self == o
142
+ end
143
+
144
+ # Calculates hash code according to all attributes.
145
+ # @return [Integer] Hash code
146
+ def hash
147
+ [company, currency, time_zone, default_weight_units, default_dimensions_units, lock_date, opening_balance_date].hash
148
+ end
149
+
150
+ # Builds the object from hash
151
+ # @param [Hash] attributes Model attributes in the form of hash
152
+ # @return [Object] Returns the model itself
153
+ def self.build_from_hash(attributes)
154
+ new.build_from_hash(attributes)
155
+ end
156
+
157
+ # Builds the object from hash
158
+ # @param [Hash] attributes Model attributes in the form of hash
159
+ # @return [Object] Returns the model itself
160
+ def build_from_hash(attributes)
161
+ return nil unless attributes.is_a?(Hash)
162
+ self.class.openapi_types.each_pair do |key, type|
163
+ if type =~ /\AArray<(.*)>/i
164
+ # check to ensure the input is an array given that the attribute
165
+ # is documented as an array but the input is not
166
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
167
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
168
+ end
169
+ elsif !attributes[self.class.attribute_map[key]].nil?
170
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
171
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
172
+ end
173
+
174
+ self
175
+ end
176
+
177
+ # Deserializes the data based on type
178
+ # @param string type Data type
179
+ # @param string value Value to be deserialized
180
+ # @return [Object] Deserialized data
181
+ def _deserialize(type, value)
182
+ case type.to_sym
183
+ when :DateTime
184
+ DateTime.parse(value)
185
+ when :Date
186
+ Date.parse(value)
187
+ when :String
188
+ value.to_s
189
+ when :Integer
190
+ value.to_i
191
+ when :Float
192
+ value.to_f
193
+ when :Boolean
194
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
195
+ true
196
+ else
197
+ false
198
+ end
199
+ when :Object
200
+ # generic object (usually a Hash), return directly
201
+ value
202
+ when /\AArray<(?<inner_type>.+)>\z/
203
+ inner_type = Regexp.last_match[:inner_type]
204
+ value.map { |v| _deserialize(inner_type, v) }
205
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
206
+ k_type = Regexp.last_match[:k_type]
207
+ v_type = Regexp.last_match[:v_type]
208
+ {}.tap do |hash|
209
+ value.each do |k, v|
210
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
211
+ end
212
+ end
213
+ else # model
214
+ DearInventoryRuby.const_get(type).build_from_hash(value)
215
+ end
216
+ end
217
+
218
+ # Returns the string representation of the object
219
+ # @return [String] String presentation of the object
220
+ def to_s
221
+ to_hash.to_s
222
+ end
223
+
224
+ # to_body is an alias to to_hash (backward compatibility)
225
+ # @return [Hash] Returns the object in the form of hash
226
+ def to_body
227
+ to_hash
228
+ end
229
+
230
+ # Returns the object in the form of hash
231
+ # @return [Hash] Returns the object in the form of hash
232
+ def to_hash
233
+ hash = {}
234
+ self.class.attribute_map.each_pair do |attr, param|
235
+ value = self.send(attr)
236
+ if value.nil?
237
+ is_nullable = self.class.openapi_nullable.include?(attr)
238
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
239
+ end
240
+
241
+ hash[param] = _to_hash(value)
242
+ end
243
+ hash
244
+ end
245
+
246
+ # Outputs non-array value in the form of hash
247
+ # For object, use to_hash. Otherwise, just return the value
248
+ # @param [Object] value Any valid value
249
+ # @return [Hash] Returns the value in the form of hash
250
+ def _to_hash(value)
251
+ if value.is_a?(Array)
252
+ value.compact.map { |v| _to_hash(v) }
253
+ elsif value.is_a?(Hash)
254
+ {}.tap do |hash|
255
+ value.each { |k, v| hash[k] = _to_hash(v) }
256
+ end
257
+ elsif value.respond_to? :to_hash
258
+ value.to_hash
259
+ else
260
+ value
261
+ end
262
+ end
263
+ end
264
+ end