dear-inventory-ruby 0.1.13 → 0.1.18

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 (42) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -1
  3. data/README.md +9 -7
  4. data/dear-inventory-ruby.gemspec +1 -1
  5. data/docs/Customer.md +1 -1
  6. data/docs/InventoryApi.md +64 -0
  7. data/docs/Me.md +3 -3
  8. data/docs/SaleInvoice.md +41 -0
  9. data/docs/SaleInvoiceAdditionalCharge.md +33 -0
  10. data/docs/SaleInvoiceLine.md +39 -0
  11. data/docs/SaleInvoices.md +19 -0
  12. data/lib/dear-inventory-ruby.rb +4 -3
  13. data/lib/dear-inventory-ruby/api/inventory_api.rb +63 -0
  14. data/lib/dear-inventory-ruby/models/account.rb +0 -34
  15. data/lib/dear-inventory-ruby/models/customer.rb +2 -35
  16. data/lib/dear-inventory-ruby/models/me.rb +6 -3
  17. data/lib/dear-inventory-ruby/models/payment_term.rb +0 -34
  18. data/lib/dear-inventory-ruby/models/sale_invoice.rb +356 -0
  19. data/lib/dear-inventory-ruby/models/sale_invoice_additional_charge.rb +317 -0
  20. data/lib/dear-inventory-ruby/models/sale_invoice_line.rb +342 -0
  21. data/lib/dear-inventory-ruby/models/sale_invoices.rb +224 -0
  22. data/lib/dear-inventory-ruby/version.rb +1 -1
  23. data/spec/.DS_Store +0 -0
  24. data/spec/api/inventory_api_spec.rb +13 -0
  25. data/spec/models/account_spec.rb +0 -4
  26. data/spec/models/customer_spec.rb +0 -4
  27. data/spec/models/payment_term_spec.rb +0 -4
  28. data/spec/models/sale_invoice_additional_charge_spec.rb +89 -0
  29. data/spec/models/sale_invoice_line_spec.rb +107 -0
  30. data/spec/models/sale_invoice_spec.rb +113 -0
  31. data/spec/models/sale_invoices_spec.rb +47 -0
  32. metadata +31 -21
  33. data/docs/CurrencyCode.md +0 -16
  34. data/docs/DimensionsUnit.md +0 -16
  35. data/docs/WeightUnit.md +0 -16
  36. data/lib/dear-inventory-ruby/models/currency_code.rb +0 -196
  37. data/lib/dear-inventory-ruby/models/dimensions_unit.rb +0 -42
  38. data/lib/dear-inventory-ruby/models/weight_unit.rb +0 -39
  39. data/pkg/dear-inventory-ruby-0.1.13.gem +0 -0
  40. data/spec/models/currency_code_spec.rb +0 -35
  41. data/spec/models/dimensions_unit_spec.rb +0 -35
  42. data/spec/models/weight_unit_spec.rb +0 -35
@@ -0,0 +1,317 @@
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 SaleInvoiceAdditionalCharge
17
+ # Name of Service Product referenced by this Line
18
+ attr_accessor :description
19
+
20
+ # Product or service quantity. Minimal value is 1.
21
+ attr_accessor :quantity
22
+
23
+ # Price per unit in Customer currency
24
+ attr_accessor :price
25
+
26
+ # Discount. Value between 0 and 100. For free items discount is 100. Default value is 0
27
+ attr_accessor :discount
28
+
29
+ # Tax
30
+ attr_accessor :tax
31
+
32
+ # Line Total.For validation
33
+ attr_accessor :total
34
+
35
+ # Line Tax Rule name.
36
+ attr_accessor :tax_rule
37
+
38
+ # Revenue account
39
+ attr_accessor :account
40
+
41
+ # Comment
42
+ attr_accessor :comment
43
+
44
+ # Attribute mapping from ruby-style variable name to JSON key.
45
+ def self.attribute_map
46
+ {
47
+ :'description' => :'Description',
48
+ :'quantity' => :'Quantity',
49
+ :'price' => :'Price',
50
+ :'discount' => :'Discount',
51
+ :'tax' => :'Tax',
52
+ :'total' => :'Total',
53
+ :'tax_rule' => :'TaxRule',
54
+ :'account' => :'Account',
55
+ :'comment' => :'Comment'
56
+ }
57
+ end
58
+
59
+ # Attribute type mapping.
60
+ def self.openapi_types
61
+ {
62
+ :'description' => :'String',
63
+ :'quantity' => :'Float',
64
+ :'price' => :'Float',
65
+ :'discount' => :'Float',
66
+ :'tax' => :'Float',
67
+ :'total' => :'Float',
68
+ :'tax_rule' => :'Float',
69
+ :'account' => :'Float',
70
+ :'comment' => :'Float'
71
+ }
72
+ end
73
+
74
+ # List of attributes with nullable: true
75
+ def self.openapi_nullable
76
+ Set.new([
77
+ ])
78
+ end
79
+
80
+ # Initializes the object
81
+ # @param [Hash] attributes Model attributes in the form of hash
82
+ def initialize(attributes = {})
83
+ if (!attributes.is_a?(Hash))
84
+ fail ArgumentError, "The input argument (attributes) must be a hash in `DearInventoryRuby::SaleInvoiceAdditionalCharge` initialize method"
85
+ end
86
+
87
+ # check to see if the attribute exists and convert string to symbol for hash key
88
+ attributes = attributes.each_with_object({}) { |(k, v), h|
89
+ if (!self.class.attribute_map.key?(k.to_sym))
90
+ fail ArgumentError, "`#{k}` is not a valid attribute in `DearInventoryRuby::SaleInvoiceAdditionalCharge`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
91
+ end
92
+ h[k.to_sym] = v
93
+ }
94
+
95
+ if attributes.key?(:'description')
96
+ self.description = attributes[:'description']
97
+ end
98
+
99
+ if attributes.key?(:'quantity')
100
+ self.quantity = attributes[:'quantity']
101
+ end
102
+
103
+ if attributes.key?(:'price')
104
+ self.price = attributes[:'price']
105
+ end
106
+
107
+ if attributes.key?(:'discount')
108
+ self.discount = attributes[:'discount']
109
+ end
110
+
111
+ if attributes.key?(:'tax')
112
+ self.tax = attributes[:'tax']
113
+ end
114
+
115
+ if attributes.key?(:'total')
116
+ self.total = attributes[:'total']
117
+ end
118
+
119
+ if attributes.key?(:'tax_rule')
120
+ self.tax_rule = attributes[:'tax_rule']
121
+ end
122
+
123
+ if attributes.key?(:'account')
124
+ self.account = attributes[:'account']
125
+ end
126
+
127
+ if attributes.key?(:'comment')
128
+ self.comment = attributes[:'comment']
129
+ end
130
+ end
131
+
132
+ # Show invalid properties with the reasons. Usually used together with valid?
133
+ # @return Array for valid properties with the reasons
134
+ def list_invalid_properties
135
+ invalid_properties = Array.new
136
+ if @description.nil?
137
+ invalid_properties.push('invalid value for "description", description cannot be nil.')
138
+ end
139
+
140
+ if @quantity.nil?
141
+ invalid_properties.push('invalid value for "quantity", quantity cannot be nil.')
142
+ end
143
+
144
+ if @price.nil?
145
+ invalid_properties.push('invalid value for "price", price cannot be nil.')
146
+ end
147
+
148
+ if @tax.nil?
149
+ invalid_properties.push('invalid value for "tax", tax cannot be nil.')
150
+ end
151
+
152
+ if @tax_rule.nil?
153
+ invalid_properties.push('invalid value for "tax_rule", tax_rule cannot be nil.')
154
+ end
155
+
156
+ if @account.nil?
157
+ invalid_properties.push('invalid value for "account", account cannot be nil.')
158
+ end
159
+
160
+ invalid_properties
161
+ end
162
+
163
+ # Check to see if the all the properties in the model are valid
164
+ # @return true if the model is valid
165
+ def valid?
166
+ return false if @description.nil?
167
+ return false if @quantity.nil?
168
+ return false if @price.nil?
169
+ return false if @tax.nil?
170
+ return false if @tax_rule.nil?
171
+ return false if @account.nil?
172
+ true
173
+ end
174
+
175
+ # Checks equality by comparing each attribute.
176
+ # @param [Object] Object to be compared
177
+ def ==(o)
178
+ return true if self.equal?(o)
179
+ self.class == o.class &&
180
+ description == o.description &&
181
+ quantity == o.quantity &&
182
+ price == o.price &&
183
+ discount == o.discount &&
184
+ tax == o.tax &&
185
+ total == o.total &&
186
+ tax_rule == o.tax_rule &&
187
+ account == o.account &&
188
+ comment == o.comment
189
+ end
190
+
191
+ # @see the `==` method
192
+ # @param [Object] Object to be compared
193
+ def eql?(o)
194
+ self == o
195
+ end
196
+
197
+ # Calculates hash code according to all attributes.
198
+ # @return [Integer] Hash code
199
+ def hash
200
+ [description, quantity, price, discount, tax, total, tax_rule, account, comment].hash
201
+ end
202
+
203
+ # Builds the object from hash
204
+ # @param [Hash] attributes Model attributes in the form of hash
205
+ # @return [Object] Returns the model itself
206
+ def self.build_from_hash(attributes)
207
+ new.build_from_hash(attributes)
208
+ end
209
+
210
+ # Builds the object from hash
211
+ # @param [Hash] attributes Model attributes in the form of hash
212
+ # @return [Object] Returns the model itself
213
+ def build_from_hash(attributes)
214
+ return nil unless attributes.is_a?(Hash)
215
+ self.class.openapi_types.each_pair do |key, type|
216
+ if type =~ /\AArray<(.*)>/i
217
+ # check to ensure the input is an array given that the attribute
218
+ # is documented as an array but the input is not
219
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
220
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
221
+ end
222
+ elsif !attributes[self.class.attribute_map[key]].nil?
223
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
224
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
225
+ end
226
+
227
+ self
228
+ end
229
+
230
+ # Deserializes the data based on type
231
+ # @param string type Data type
232
+ # @param string value Value to be deserialized
233
+ # @return [Object] Deserialized data
234
+ def _deserialize(type, value)
235
+ case type.to_sym
236
+ when :DateTime
237
+ DateTime.parse(value)
238
+ when :Date
239
+ Date.parse(value)
240
+ when :String
241
+ value.to_s
242
+ when :Integer
243
+ value.to_i
244
+ when :Float
245
+ value.to_f
246
+ when :Boolean
247
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
248
+ true
249
+ else
250
+ false
251
+ end
252
+ when :Object
253
+ # generic object (usually a Hash), return directly
254
+ value
255
+ when /\AArray<(?<inner_type>.+)>\z/
256
+ inner_type = Regexp.last_match[:inner_type]
257
+ value.map { |v| _deserialize(inner_type, v) }
258
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
259
+ k_type = Regexp.last_match[:k_type]
260
+ v_type = Regexp.last_match[:v_type]
261
+ {}.tap do |hash|
262
+ value.each do |k, v|
263
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
264
+ end
265
+ end
266
+ else # model
267
+ DearInventoryRuby.const_get(type).build_from_hash(value)
268
+ end
269
+ end
270
+
271
+ # Returns the string representation of the object
272
+ # @return [String] String presentation of the object
273
+ def to_s
274
+ to_hash.to_s
275
+ end
276
+
277
+ # to_body is an alias to to_hash (backward compatibility)
278
+ # @return [Hash] Returns the object in the form of hash
279
+ def to_body
280
+ to_hash
281
+ end
282
+
283
+ # Returns the object in the form of hash
284
+ # @return [Hash] Returns the object in the form of hash
285
+ def to_hash
286
+ hash = {}
287
+ self.class.attribute_map.each_pair do |attr, param|
288
+ value = self.send(attr)
289
+ if value.nil?
290
+ is_nullable = self.class.openapi_nullable.include?(attr)
291
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
292
+ end
293
+
294
+ hash[param] = _to_hash(value)
295
+ end
296
+ hash
297
+ end
298
+
299
+ # Outputs non-array value in the form of hash
300
+ # For object, use to_hash. Otherwise, just return the value
301
+ # @param [Object] value Any valid value
302
+ # @return [Hash] Returns the value in the form of hash
303
+ def _to_hash(value)
304
+ if value.is_a?(Array)
305
+ value.compact.map { |v| _to_hash(v) }
306
+ elsif value.is_a?(Hash)
307
+ {}.tap do |hash|
308
+ value.each { |k, v| hash[k] = _to_hash(v) }
309
+ end
310
+ elsif value.respond_to? :to_hash
311
+ value.to_hash
312
+ else
313
+ value
314
+ end
315
+ end
316
+ end
317
+ end
@@ -0,0 +1,342 @@
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 SaleInvoiceLine
17
+ # Product identifier referenced by this Line. Required If CombineAdditionalCharges param exist for this endpoint and it have values = false
18
+ attr_accessor :product_id
19
+
20
+ # Product SKU referenced by this Line. Required If CombineAdditionalCharges param exist for this endpoint and it have values = false
21
+ attr_accessor :sku
22
+
23
+ # Product Name referenced by this Line
24
+ attr_accessor :name
25
+
26
+ # Product or service quantity. Minimal value is 1.
27
+ attr_accessor :quantity
28
+
29
+ # Price per unit in Customer currency
30
+ attr_accessor :price
31
+
32
+ # Discount. Value between 0 and 100. For free items discount is 100. Default value is 0
33
+ attr_accessor :discount
34
+
35
+ # Tax
36
+ attr_accessor :tax
37
+
38
+ # Line Total. For validation
39
+ attr_accessor :total
40
+
41
+ # Average product cost
42
+ attr_accessor :average_cost
43
+
44
+ # Line Tax Rule name.
45
+ attr_accessor :tax_rule
46
+
47
+ # Revenue account
48
+ attr_accessor :account
49
+
50
+ # Comment for this line
51
+ attr_accessor :comment
52
+
53
+ # Attribute mapping from ruby-style variable name to JSON key.
54
+ def self.attribute_map
55
+ {
56
+ :'product_id' => :'ProductID',
57
+ :'sku' => :'SKU',
58
+ :'name' => :'Name',
59
+ :'quantity' => :'Quantity',
60
+ :'price' => :'Price',
61
+ :'discount' => :'Discount',
62
+ :'tax' => :'Tax',
63
+ :'total' => :'Total',
64
+ :'average_cost' => :'AverageCost',
65
+ :'tax_rule' => :'TaxRule',
66
+ :'account' => :'Account',
67
+ :'comment' => :'Comment'
68
+ }
69
+ end
70
+
71
+ # Attribute type mapping.
72
+ def self.openapi_types
73
+ {
74
+ :'product_id' => :'String',
75
+ :'sku' => :'String',
76
+ :'name' => :'String',
77
+ :'quantity' => :'Float',
78
+ :'price' => :'Float',
79
+ :'discount' => :'Float',
80
+ :'tax' => :'Float',
81
+ :'total' => :'Float',
82
+ :'average_cost' => :'Float',
83
+ :'tax_rule' => :'String',
84
+ :'account' => :'String',
85
+ :'comment' => :'String'
86
+ }
87
+ end
88
+
89
+ # List of attributes with nullable: true
90
+ def self.openapi_nullable
91
+ Set.new([
92
+ ])
93
+ end
94
+
95
+ # Initializes the object
96
+ # @param [Hash] attributes Model attributes in the form of hash
97
+ def initialize(attributes = {})
98
+ if (!attributes.is_a?(Hash))
99
+ fail ArgumentError, "The input argument (attributes) must be a hash in `DearInventoryRuby::SaleInvoiceLine` initialize method"
100
+ end
101
+
102
+ # check to see if the attribute exists and convert string to symbol for hash key
103
+ attributes = attributes.each_with_object({}) { |(k, v), h|
104
+ if (!self.class.attribute_map.key?(k.to_sym))
105
+ fail ArgumentError, "`#{k}` is not a valid attribute in `DearInventoryRuby::SaleInvoiceLine`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
106
+ end
107
+ h[k.to_sym] = v
108
+ }
109
+
110
+ if attributes.key?(:'product_id')
111
+ self.product_id = attributes[:'product_id']
112
+ end
113
+
114
+ if attributes.key?(:'sku')
115
+ self.sku = attributes[:'sku']
116
+ end
117
+
118
+ if attributes.key?(:'name')
119
+ self.name = attributes[:'name']
120
+ end
121
+
122
+ if attributes.key?(:'quantity')
123
+ self.quantity = attributes[:'quantity']
124
+ end
125
+
126
+ if attributes.key?(:'price')
127
+ self.price = attributes[:'price']
128
+ end
129
+
130
+ if attributes.key?(:'discount')
131
+ self.discount = attributes[:'discount']
132
+ end
133
+
134
+ if attributes.key?(:'tax')
135
+ self.tax = attributes[:'tax']
136
+ end
137
+
138
+ if attributes.key?(:'total')
139
+ self.total = attributes[:'total']
140
+ end
141
+
142
+ if attributes.key?(:'average_cost')
143
+ self.average_cost = attributes[:'average_cost']
144
+ end
145
+
146
+ if attributes.key?(:'tax_rule')
147
+ self.tax_rule = attributes[:'tax_rule']
148
+ end
149
+
150
+ if attributes.key?(:'account')
151
+ self.account = attributes[:'account']
152
+ end
153
+
154
+ if attributes.key?(:'comment')
155
+ self.comment = attributes[:'comment']
156
+ end
157
+ end
158
+
159
+ # Show invalid properties with the reasons. Usually used together with valid?
160
+ # @return Array for valid properties with the reasons
161
+ def list_invalid_properties
162
+ invalid_properties = Array.new
163
+ if @product_id.nil?
164
+ invalid_properties.push('invalid value for "product_id", product_id cannot be nil.')
165
+ end
166
+
167
+ if @sku.nil?
168
+ invalid_properties.push('invalid value for "sku", sku cannot be nil.')
169
+ end
170
+
171
+ if @name.nil?
172
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
173
+ end
174
+
175
+ if @quantity.nil?
176
+ invalid_properties.push('invalid value for "quantity", quantity cannot be nil.')
177
+ end
178
+
179
+ if @price.nil?
180
+ invalid_properties.push('invalid value for "price", price cannot be nil.')
181
+ end
182
+
183
+ invalid_properties
184
+ end
185
+
186
+ # Check to see if the all the properties in the model are valid
187
+ # @return true if the model is valid
188
+ def valid?
189
+ return false if @product_id.nil?
190
+ return false if @sku.nil?
191
+ return false if @name.nil?
192
+ return false if @quantity.nil?
193
+ return false if @price.nil?
194
+ true
195
+ end
196
+
197
+ # Checks equality by comparing each attribute.
198
+ # @param [Object] Object to be compared
199
+ def ==(o)
200
+ return true if self.equal?(o)
201
+ self.class == o.class &&
202
+ product_id == o.product_id &&
203
+ sku == o.sku &&
204
+ name == o.name &&
205
+ quantity == o.quantity &&
206
+ price == o.price &&
207
+ discount == o.discount &&
208
+ tax == o.tax &&
209
+ total == o.total &&
210
+ average_cost == o.average_cost &&
211
+ tax_rule == o.tax_rule &&
212
+ account == o.account &&
213
+ comment == o.comment
214
+ end
215
+
216
+ # @see the `==` method
217
+ # @param [Object] Object to be compared
218
+ def eql?(o)
219
+ self == o
220
+ end
221
+
222
+ # Calculates hash code according to all attributes.
223
+ # @return [Integer] Hash code
224
+ def hash
225
+ [product_id, sku, name, quantity, price, discount, tax, total, average_cost, tax_rule, account, comment].hash
226
+ end
227
+
228
+ # Builds the object from hash
229
+ # @param [Hash] attributes Model attributes in the form of hash
230
+ # @return [Object] Returns the model itself
231
+ def self.build_from_hash(attributes)
232
+ new.build_from_hash(attributes)
233
+ end
234
+
235
+ # Builds the object from hash
236
+ # @param [Hash] attributes Model attributes in the form of hash
237
+ # @return [Object] Returns the model itself
238
+ def build_from_hash(attributes)
239
+ return nil unless attributes.is_a?(Hash)
240
+ self.class.openapi_types.each_pair do |key, type|
241
+ if type =~ /\AArray<(.*)>/i
242
+ # check to ensure the input is an array given that the attribute
243
+ # is documented as an array but the input is not
244
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
245
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
246
+ end
247
+ elsif !attributes[self.class.attribute_map[key]].nil?
248
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
249
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
250
+ end
251
+
252
+ self
253
+ end
254
+
255
+ # Deserializes the data based on type
256
+ # @param string type Data type
257
+ # @param string value Value to be deserialized
258
+ # @return [Object] Deserialized data
259
+ def _deserialize(type, value)
260
+ case type.to_sym
261
+ when :DateTime
262
+ DateTime.parse(value)
263
+ when :Date
264
+ Date.parse(value)
265
+ when :String
266
+ value.to_s
267
+ when :Integer
268
+ value.to_i
269
+ when :Float
270
+ value.to_f
271
+ when :Boolean
272
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
273
+ true
274
+ else
275
+ false
276
+ end
277
+ when :Object
278
+ # generic object (usually a Hash), return directly
279
+ value
280
+ when /\AArray<(?<inner_type>.+)>\z/
281
+ inner_type = Regexp.last_match[:inner_type]
282
+ value.map { |v| _deserialize(inner_type, v) }
283
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
284
+ k_type = Regexp.last_match[:k_type]
285
+ v_type = Regexp.last_match[:v_type]
286
+ {}.tap do |hash|
287
+ value.each do |k, v|
288
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
289
+ end
290
+ end
291
+ else # model
292
+ DearInventoryRuby.const_get(type).build_from_hash(value)
293
+ end
294
+ end
295
+
296
+ # Returns the string representation of the object
297
+ # @return [String] String presentation of the object
298
+ def to_s
299
+ to_hash.to_s
300
+ end
301
+
302
+ # to_body is an alias to to_hash (backward compatibility)
303
+ # @return [Hash] Returns the object in the form of hash
304
+ def to_body
305
+ to_hash
306
+ end
307
+
308
+ # Returns the object in the form of hash
309
+ # @return [Hash] Returns the object in the form of hash
310
+ def to_hash
311
+ hash = {}
312
+ self.class.attribute_map.each_pair do |attr, param|
313
+ value = self.send(attr)
314
+ if value.nil?
315
+ is_nullable = self.class.openapi_nullable.include?(attr)
316
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
317
+ end
318
+
319
+ hash[param] = _to_hash(value)
320
+ end
321
+ hash
322
+ end
323
+
324
+ # Outputs non-array value in the form of hash
325
+ # For object, use to_hash. Otherwise, just return the value
326
+ # @param [Object] value Any valid value
327
+ # @return [Hash] Returns the value in the form of hash
328
+ def _to_hash(value)
329
+ if value.is_a?(Array)
330
+ value.compact.map { |v| _to_hash(v) }
331
+ elsif value.is_a?(Hash)
332
+ {}.tap do |hash|
333
+ value.each { |k, v| hash[k] = _to_hash(v) }
334
+ end
335
+ elsif value.respond_to? :to_hash
336
+ value.to_hash
337
+ else
338
+ value
339
+ end
340
+ end
341
+ end
342
+ end