dear-inventory-ruby 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +28 -9
- data/docs/Account.md +43 -0
- data/docs/Accounts.md +21 -0
- data/docs/Address.md +2 -2
- data/docs/Contact.md +1 -1
- data/docs/Customer.md +7 -7
- data/docs/InventoryApi.md +731 -25
- data/docs/PaymentTerm.md +27 -0
- data/docs/PaymentTerms.md +21 -0
- data/docs/Success.md +17 -0
- data/docs/Tax.md +33 -0
- data/docs/TaxComponent.md +23 -0
- data/docs/Taxes.md +21 -0
- data/lib/dear-inventory-ruby.rb +8 -0
- data/lib/dear-inventory-ruby/api/inventory_api.rb +740 -14
- data/lib/dear-inventory-ruby/models/account.rb +477 -0
- data/lib/dear-inventory-ruby/models/accounts.rb +229 -0
- data/lib/dear-inventory-ruby/models/address.rb +10 -0
- data/lib/dear-inventory-ruby/models/contact.rb +12 -3
- data/lib/dear-inventory-ruby/models/customer.rb +42 -3
- data/lib/dear-inventory-ruby/models/payment_term.rb +319 -0
- data/lib/dear-inventory-ruby/models/payment_terms.rb +229 -0
- data/lib/dear-inventory-ruby/models/success.rb +207 -0
- data/lib/dear-inventory-ruby/models/tax.rb +360 -0
- data/lib/dear-inventory-ruby/models/tax_component.rb +306 -0
- data/lib/dear-inventory-ruby/models/taxes.rb +229 -0
- data/lib/dear-inventory-ruby/version.rb +1 -1
- data/spec/api/inventory_api_spec.rb +148 -4
- data/spec/models/account_spec.rb +131 -0
- data/spec/models/accounts_spec.rb +53 -0
- data/spec/models/payment_term_spec.rb +75 -0
- data/spec/models/payment_terms_spec.rb +53 -0
- data/spec/models/success_spec.rb +41 -0
- data/spec/models/tax_component_spec.rb +59 -0
- data/spec/models/tax_spec.rb +89 -0
- data/spec/models/taxes_spec.rb +53 -0
- metadata +34 -2
@@ -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.2.3
|
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
|
+
# Should be one of the following values: `BANK`, `CURRLIAB`, `LIABILITY`, `TERMLIA`, `PAYGLIABILITY`, `SUPERANNUATIONLIABILITY`, `WAGESPAYABLELIABILITY`
|
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
|
+
# Read-only for PUT. Should be one of the following values: BANKCURRENCYGAIN, CREDITORS, DEBTORS, GST, GSTONIMPORTS, HISTORICAL, REALISEDCURRENCYGAIN, RETAINEDEARNINGS, ROUNDING, TRACKINGTRANSFERS, UNPAIDEXPCLM, UNREALISEDCURRENCYGAIN, WAGEPAYABLES
|
36
|
+
attr_accessor :system_account
|
37
|
+
|
38
|
+
# Account status
|
39
|
+
attr_accessor :for_payments
|
40
|
+
|
41
|
+
# Account display name. Read-only.
|
42
|
+
attr_accessor :display_name
|
43
|
+
|
44
|
+
# Read-only.
|
45
|
+
attr_accessor :old_code
|
46
|
+
|
47
|
+
# Name of the Bank. Only for PUT and POST. Required if Account Type is BANK.
|
48
|
+
attr_accessor :bank
|
49
|
+
|
50
|
+
# Bank Account Number. Only for PUT and POST. Required if Account Type is BANK.
|
51
|
+
attr_accessor :bank_account_number
|
52
|
+
|
53
|
+
# Bank Account ID to which the Account is linked. Read-only.
|
54
|
+
attr_accessor :bank_account_id
|
55
|
+
|
56
|
+
# Currency. Read-only.
|
57
|
+
attr_accessor :currency
|
58
|
+
|
59
|
+
class EnumAttributeValidator
|
60
|
+
attr_reader :datatype
|
61
|
+
attr_reader :allowable_values
|
62
|
+
|
63
|
+
def initialize(datatype, allowable_values)
|
64
|
+
@allowable_values = allowable_values.map do |value|
|
65
|
+
case datatype.to_s
|
66
|
+
when /Integer/i
|
67
|
+
value.to_i
|
68
|
+
when /Float/i
|
69
|
+
value.to_f
|
70
|
+
else
|
71
|
+
value
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def valid?(value)
|
77
|
+
!value || allowable_values.include?(value)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
82
|
+
def self.attribute_map
|
83
|
+
{
|
84
|
+
:'code' => :'Code',
|
85
|
+
:'name' => :'Name',
|
86
|
+
:'type' => :'Type',
|
87
|
+
:'status' => :'Status',
|
88
|
+
:'description' => :'Description',
|
89
|
+
:'_class' => :'Class',
|
90
|
+
:'system_account' => :'SystemAccount',
|
91
|
+
:'for_payments' => :'ForPayments',
|
92
|
+
:'display_name' => :'DisplayName',
|
93
|
+
:'old_code' => :'OldCode',
|
94
|
+
:'bank' => :'Bank',
|
95
|
+
:'bank_account_number' => :'BankAccountNumber',
|
96
|
+
:'bank_account_id' => :'BankAccountId',
|
97
|
+
:'currency' => :'Currency'
|
98
|
+
}
|
99
|
+
end
|
100
|
+
|
101
|
+
# Attribute type mapping.
|
102
|
+
def self.openapi_types
|
103
|
+
{
|
104
|
+
:'code' => :'String',
|
105
|
+
:'name' => :'String',
|
106
|
+
:'type' => :'String',
|
107
|
+
:'status' => :'String',
|
108
|
+
:'description' => :'String',
|
109
|
+
:'_class' => :'String',
|
110
|
+
:'system_account' => :'String',
|
111
|
+
:'for_payments' => :'String',
|
112
|
+
:'display_name' => :'String',
|
113
|
+
:'old_code' => :'String',
|
114
|
+
:'bank' => :'String',
|
115
|
+
:'bank_account_number' => :'String',
|
116
|
+
:'bank_account_id' => :'String',
|
117
|
+
:'currency' => :'String'
|
118
|
+
}
|
119
|
+
end
|
120
|
+
|
121
|
+
# List of attributes with nullable: true
|
122
|
+
def self.openapi_nullable
|
123
|
+
Set.new([
|
124
|
+
])
|
125
|
+
end
|
126
|
+
|
127
|
+
# Initializes the object
|
128
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
129
|
+
def initialize(attributes = {})
|
130
|
+
if (!attributes.is_a?(Hash))
|
131
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `DearInventoryRuby::Account` initialize method"
|
132
|
+
end
|
133
|
+
|
134
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
135
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
136
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
137
|
+
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
|
138
|
+
end
|
139
|
+
h[k.to_sym] = v
|
140
|
+
}
|
141
|
+
|
142
|
+
if attributes.key?(:'code')
|
143
|
+
self.code = attributes[:'code']
|
144
|
+
end
|
145
|
+
|
146
|
+
if attributes.key?(:'name')
|
147
|
+
self.name = attributes[:'name']
|
148
|
+
end
|
149
|
+
|
150
|
+
if attributes.key?(:'type')
|
151
|
+
self.type = attributes[:'type']
|
152
|
+
end
|
153
|
+
|
154
|
+
if attributes.key?(:'status')
|
155
|
+
self.status = attributes[:'status']
|
156
|
+
end
|
157
|
+
|
158
|
+
if attributes.key?(:'description')
|
159
|
+
self.description = attributes[:'description']
|
160
|
+
end
|
161
|
+
|
162
|
+
if attributes.key?(:'_class')
|
163
|
+
self._class = attributes[:'_class']
|
164
|
+
end
|
165
|
+
|
166
|
+
if attributes.key?(:'system_account')
|
167
|
+
self.system_account = attributes[:'system_account']
|
168
|
+
end
|
169
|
+
|
170
|
+
if attributes.key?(:'for_payments')
|
171
|
+
self.for_payments = attributes[:'for_payments']
|
172
|
+
end
|
173
|
+
|
174
|
+
if attributes.key?(:'display_name')
|
175
|
+
self.display_name = attributes[:'display_name']
|
176
|
+
end
|
177
|
+
|
178
|
+
if attributes.key?(:'old_code')
|
179
|
+
self.old_code = attributes[:'old_code']
|
180
|
+
end
|
181
|
+
|
182
|
+
if attributes.key?(:'bank')
|
183
|
+
self.bank = attributes[:'bank']
|
184
|
+
end
|
185
|
+
|
186
|
+
if attributes.key?(:'bank_account_number')
|
187
|
+
self.bank_account_number = attributes[:'bank_account_number']
|
188
|
+
end
|
189
|
+
|
190
|
+
if attributes.key?(:'bank_account_id')
|
191
|
+
self.bank_account_id = attributes[:'bank_account_id']
|
192
|
+
end
|
193
|
+
|
194
|
+
if attributes.key?(:'currency')
|
195
|
+
self.currency = attributes[:'currency']
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
200
|
+
# @return Array for valid properties with the reasons
|
201
|
+
def list_invalid_properties
|
202
|
+
invalid_properties = Array.new
|
203
|
+
if @code.nil?
|
204
|
+
invalid_properties.push('invalid value for "code", code cannot be nil.')
|
205
|
+
end
|
206
|
+
|
207
|
+
if @code.to_s.length > 50
|
208
|
+
invalid_properties.push('invalid value for "code", the character length must be smaller than or equal to 50.')
|
209
|
+
end
|
210
|
+
|
211
|
+
if @name.nil?
|
212
|
+
invalid_properties.push('invalid value for "name", name cannot be nil.')
|
213
|
+
end
|
214
|
+
|
215
|
+
if @name.to_s.length > 256
|
216
|
+
invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 256.')
|
217
|
+
end
|
218
|
+
|
219
|
+
if @type.nil?
|
220
|
+
invalid_properties.push('invalid value for "type", type cannot be nil.')
|
221
|
+
end
|
222
|
+
|
223
|
+
if @type.to_s.length > 50
|
224
|
+
invalid_properties.push('invalid value for "type", the character length must be smaller than or equal to 50.')
|
225
|
+
end
|
226
|
+
|
227
|
+
if @status.nil?
|
228
|
+
invalid_properties.push('invalid value for "status", status cannot be nil.')
|
229
|
+
end
|
230
|
+
|
231
|
+
if @status.to_s.length > 50
|
232
|
+
invalid_properties.push('invalid value for "status", the character length must be smaller than or equal to 50.')
|
233
|
+
end
|
234
|
+
|
235
|
+
invalid_properties
|
236
|
+
end
|
237
|
+
|
238
|
+
# Check to see if the all the properties in the model are valid
|
239
|
+
# @return true if the model is valid
|
240
|
+
def valid?
|
241
|
+
return false if @code.nil?
|
242
|
+
return false if @code.to_s.length > 50
|
243
|
+
return false if @name.nil?
|
244
|
+
return false if @name.to_s.length > 256
|
245
|
+
return false if @type.nil?
|
246
|
+
type_validator = EnumAttributeValidator.new('String', ["BANK", "CURRLIAB", "LIABILITY", "TERMLIA", "PAYGLIABILITY", "SUPERANNUATIONLIABILITY", "WAGESPAYABLELIABILITY"])
|
247
|
+
return false unless type_validator.valid?(@type)
|
248
|
+
return false if @type.to_s.length > 50
|
249
|
+
return false if @status.nil?
|
250
|
+
return false if @status.to_s.length > 50
|
251
|
+
_class_validator = EnumAttributeValidator.new('String', ["ASSET", "LIABILITY", "EXPENSE", "EQUITY", "REVENUE"])
|
252
|
+
return false unless _class_validator.valid?(@_class)
|
253
|
+
system_account_validator = EnumAttributeValidator.new('String', ["BANKCURRENCYGAIN", "CREDITORS", "DEBTORS", "GST", "GSTONIMPORTS", "HISTORICAL", "REALISEDCURRENCYGAIN", "RETAINEDEARNINGS", "ROUNDING", "TRACKINGTRANSFERS", "UNPAIDEXPCLM", "UNREALISEDCURRENCYGAIN", "WAGEPAYABLES"])
|
254
|
+
return false unless system_account_validator.valid?(@system_account)
|
255
|
+
true
|
256
|
+
end
|
257
|
+
|
258
|
+
# Custom attribute writer method with validation
|
259
|
+
# @param [Object] code Value to be assigned
|
260
|
+
def code=(code)
|
261
|
+
if code.nil?
|
262
|
+
fail ArgumentError, 'code cannot be nil'
|
263
|
+
end
|
264
|
+
|
265
|
+
if code.to_s.length > 50
|
266
|
+
fail ArgumentError, 'invalid value for "code", the character length must be smaller than or equal to 50.'
|
267
|
+
end
|
268
|
+
|
269
|
+
@code = code
|
270
|
+
end
|
271
|
+
|
272
|
+
# Custom attribute writer method with validation
|
273
|
+
# @param [Object] name Value to be assigned
|
274
|
+
def name=(name)
|
275
|
+
if name.nil?
|
276
|
+
fail ArgumentError, 'name cannot be nil'
|
277
|
+
end
|
278
|
+
|
279
|
+
if name.to_s.length > 256
|
280
|
+
fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 256.'
|
281
|
+
end
|
282
|
+
|
283
|
+
@name = name
|
284
|
+
end
|
285
|
+
|
286
|
+
# Custom attribute writer method checking allowed values (enum).
|
287
|
+
# @param [Object] type Object to be assigned
|
288
|
+
def type=(type)
|
289
|
+
validator = EnumAttributeValidator.new('String', ["BANK", "CURRLIAB", "LIABILITY", "TERMLIA", "PAYGLIABILITY", "SUPERANNUATIONLIABILITY", "WAGESPAYABLELIABILITY"])
|
290
|
+
unless validator.valid?(type)
|
291
|
+
fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
|
292
|
+
end
|
293
|
+
@type = type
|
294
|
+
end
|
295
|
+
|
296
|
+
# Custom attribute writer method with validation
|
297
|
+
# @param [Object] status Value to be assigned
|
298
|
+
def status=(status)
|
299
|
+
if status.nil?
|
300
|
+
fail ArgumentError, 'status cannot be nil'
|
301
|
+
end
|
302
|
+
|
303
|
+
if status.to_s.length > 50
|
304
|
+
fail ArgumentError, 'invalid value for "status", the character length must be smaller than or equal to 50.'
|
305
|
+
end
|
306
|
+
|
307
|
+
@status = status
|
308
|
+
end
|
309
|
+
|
310
|
+
# Custom attribute writer method checking allowed values (enum).
|
311
|
+
# @param [Object] _class Object to be assigned
|
312
|
+
def _class=(_class)
|
313
|
+
validator = EnumAttributeValidator.new('String', ["ASSET", "LIABILITY", "EXPENSE", "EQUITY", "REVENUE"])
|
314
|
+
unless validator.valid?(_class)
|
315
|
+
fail ArgumentError, "invalid value for \"_class\", must be one of #{validator.allowable_values}."
|
316
|
+
end
|
317
|
+
@_class = _class
|
318
|
+
end
|
319
|
+
|
320
|
+
# Custom attribute writer method checking allowed values (enum).
|
321
|
+
# @param [Object] system_account Object to be assigned
|
322
|
+
def system_account=(system_account)
|
323
|
+
validator = EnumAttributeValidator.new('String', ["BANKCURRENCYGAIN", "CREDITORS", "DEBTORS", "GST", "GSTONIMPORTS", "HISTORICAL", "REALISEDCURRENCYGAIN", "RETAINEDEARNINGS", "ROUNDING", "TRACKINGTRANSFERS", "UNPAIDEXPCLM", "UNREALISEDCURRENCYGAIN", "WAGEPAYABLES"])
|
324
|
+
unless validator.valid?(system_account)
|
325
|
+
fail ArgumentError, "invalid value for \"system_account\", must be one of #{validator.allowable_values}."
|
326
|
+
end
|
327
|
+
@system_account = system_account
|
328
|
+
end
|
329
|
+
|
330
|
+
# Checks equality by comparing each attribute.
|
331
|
+
# @param [Object] Object to be compared
|
332
|
+
def ==(o)
|
333
|
+
return true if self.equal?(o)
|
334
|
+
self.class == o.class &&
|
335
|
+
code == o.code &&
|
336
|
+
name == o.name &&
|
337
|
+
type == o.type &&
|
338
|
+
status == o.status &&
|
339
|
+
description == o.description &&
|
340
|
+
_class == o._class &&
|
341
|
+
system_account == o.system_account &&
|
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, 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
|