masspay_ruby_sdk 1.0.0

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 (119) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +8 -0
  3. data/CONTRIBUTING.md +13 -0
  4. data/Gemfile +9 -0
  5. data/README.md +197 -0
  6. data/Rakefile +10 -0
  7. data/docs/AccountApi.md +150 -0
  8. data/docs/ApiResponse.md +22 -0
  9. data/docs/AttrTxn.md +20 -0
  10. data/docs/AttrValue.md +20 -0
  11. data/docs/AttrVelocityRequestInner.md +20 -0
  12. data/docs/AttributeApi.md +168 -0
  13. data/docs/AttrsRequirement.md +36 -0
  14. data/docs/AutopayResp.md +22 -0
  15. data/docs/AutopayRule.md +20 -0
  16. data/docs/AvailableBalanceTxnResp.md +22 -0
  17. data/docs/CardApi.md +160 -0
  18. data/docs/CatalogApi.md +469 -0
  19. data/docs/CompaniesResp.md +18 -0
  20. data/docs/Company.md +26 -0
  21. data/docs/Country.md +22 -0
  22. data/docs/Exception.md +20 -0
  23. data/docs/FoundUser.md +24 -0
  24. data/docs/GetAccountStatement200Response.md +18 -0
  25. data/docs/GetTransactionConfirmationDetails200Response.md +18 -0
  26. data/docs/GetUserAgreement200Response.md +26 -0
  27. data/docs/GetUserAgreementsNames200ResponseInner.md +24 -0
  28. data/docs/GetUserUserTokenKycAu10tix200Response.md +18 -0
  29. data/docs/GetUserUserTokenKycVeriff200Response.md +18 -0
  30. data/docs/GetWalletCardInfo200Response.md +30 -0
  31. data/docs/IDUpload.md +20 -0
  32. data/docs/KYCApi.md +305 -0
  33. data/docs/LoadApi.md +621 -0
  34. data/docs/LoadTxn.md +32 -0
  35. data/docs/LoadTxnResp.md +20 -0
  36. data/docs/Loads.md +36 -0
  37. data/docs/PayoutApi.md +403 -0
  38. data/docs/PayoutTxn.md +36 -0
  39. data/docs/PayoutTxnCommitResp.md +24 -0
  40. data/docs/PayoutTxnResp.md +60 -0
  41. data/docs/ResendBalanceNotification200Response.md +18 -0
  42. data/docs/Service.md +22 -0
  43. data/docs/ServicePayersInner.md +38 -0
  44. data/docs/ServicePayersInnerExchangeRateInner.md +20 -0
  45. data/docs/SpendBackApi.md +161 -0
  46. data/docs/SpendBackTxn.md +28 -0
  47. data/docs/SpendBackTxnResp.md +22 -0
  48. data/docs/SpendBacks.md +34 -0
  49. data/docs/StoredUser.md +56 -0
  50. data/docs/TaxApi.md +81 -0
  51. data/docs/TaxYearUserResp.md +48 -0
  52. data/docs/TxnHistoryResp.md +52 -0
  53. data/docs/UpdateUser.md +52 -0
  54. data/docs/User.md +50 -0
  55. data/docs/UserApi.md +403 -0
  56. data/docs/WalletApi.md +463 -0
  57. data/docs/WalletTxnResp.md +34 -0
  58. data/docs/logo.webp +0 -0
  59. data/lib/masspay_ruby_sdk/api/account_api.rb +149 -0
  60. data/lib/masspay_ruby_sdk/api/attribute_api.rb +214 -0
  61. data/lib/masspay_ruby_sdk/api/card_api.rb +174 -0
  62. data/lib/masspay_ruby_sdk/api/catalog_api.rb +443 -0
  63. data/lib/masspay_ruby_sdk/api/kyc_api.rb +290 -0
  64. data/lib/masspay_ruby_sdk/api/load_api.rb +598 -0
  65. data/lib/masspay_ruby_sdk/api/payout_api.rb +397 -0
  66. data/lib/masspay_ruby_sdk/api/spend_back_api.rb +160 -0
  67. data/lib/masspay_ruby_sdk/api/tax_api.rb +82 -0
  68. data/lib/masspay_ruby_sdk/api/user_api.rb +418 -0
  69. data/lib/masspay_ruby_sdk/api/wallet_api.rb +461 -0
  70. data/lib/masspay_ruby_sdk/api_client.rb +391 -0
  71. data/lib/masspay_ruby_sdk/api_error.rb +57 -0
  72. data/lib/masspay_ruby_sdk/configuration.rb +315 -0
  73. data/lib/masspay_ruby_sdk/models/api_response.rb +236 -0
  74. data/lib/masspay_ruby_sdk/models/attr_txn.rb +235 -0
  75. data/lib/masspay_ruby_sdk/models/attr_value.rb +239 -0
  76. data/lib/masspay_ruby_sdk/models/attr_velocity_request_inner.rb +273 -0
  77. data/lib/masspay_ruby_sdk/models/attrs_requirement.rb +372 -0
  78. data/lib/masspay_ruby_sdk/models/autopay_resp.rb +256 -0
  79. data/lib/masspay_ruby_sdk/models/autopay_rule.rb +241 -0
  80. data/lib/masspay_ruby_sdk/models/available_balance_txn_resp.rb +254 -0
  81. data/lib/masspay_ruby_sdk/models/companies_resp.rb +225 -0
  82. data/lib/masspay_ruby_sdk/models/company.rb +285 -0
  83. data/lib/masspay_ruby_sdk/models/country.rb +296 -0
  84. data/lib/masspay_ruby_sdk/models/exception.rb +241 -0
  85. data/lib/masspay_ruby_sdk/models/found_user.rb +270 -0
  86. data/lib/masspay_ruby_sdk/models/get_account_statement200_response.rb +225 -0
  87. data/lib/masspay_ruby_sdk/models/get_transaction_confirmation_details200_response.rb +218 -0
  88. data/lib/masspay_ruby_sdk/models/get_user_agreement200_response.rb +280 -0
  89. data/lib/masspay_ruby_sdk/models/get_user_agreements_names200_response_inner.rb +270 -0
  90. data/lib/masspay_ruby_sdk/models/get_user_user_token_kyc_au10tix200_response.rb +224 -0
  91. data/lib/masspay_ruby_sdk/models/get_user_user_token_kyc_veriff200_response.rb +224 -0
  92. data/lib/masspay_ruby_sdk/models/get_wallet_card_info200_response.rb +460 -0
  93. data/lib/masspay_ruby_sdk/models/id_upload.rb +273 -0
  94. data/lib/masspay_ruby_sdk/models/load_txn.rb +321 -0
  95. data/lib/masspay_ruby_sdk/models/load_txn_resp.rb +273 -0
  96. data/lib/masspay_ruby_sdk/models/loads.rb +388 -0
  97. data/lib/masspay_ruby_sdk/models/payout_txn.rb +328 -0
  98. data/lib/masspay_ruby_sdk/models/payout_txn_commit_resp.rb +293 -0
  99. data/lib/masspay_ruby_sdk/models/payout_txn_resp.rb +613 -0
  100. data/lib/masspay_ruby_sdk/models/resend_balance_notification200_response.rb +225 -0
  101. data/lib/masspay_ruby_sdk/models/service.rb +318 -0
  102. data/lib/masspay_ruby_sdk/models/service_payers_inner.rb +373 -0
  103. data/lib/masspay_ruby_sdk/models/service_payers_inner_exchange_rate_inner.rb +239 -0
  104. data/lib/masspay_ruby_sdk/models/spend_back_txn.rb +325 -0
  105. data/lib/masspay_ruby_sdk/models/spend_back_txn_resp.rb +307 -0
  106. data/lib/masspay_ruby_sdk/models/spend_backs.rb +340 -0
  107. data/lib/masspay_ruby_sdk/models/stored_user.rb +500 -0
  108. data/lib/masspay_ruby_sdk/models/tax_year_user_resp.rb +388 -0
  109. data/lib/masspay_ruby_sdk/models/txn_history_resp.rb +571 -0
  110. data/lib/masspay_ruby_sdk/models/update_user.rb +490 -0
  111. data/lib/masspay_ruby_sdk/models/user.rb +423 -0
  112. data/lib/masspay_ruby_sdk/models/wallet_txn_resp.rb +375 -0
  113. data/lib/masspay_ruby_sdk/version.rb +14 -0
  114. data/lib/masspay_ruby_sdk.rb +89 -0
  115. data/masspay_ruby_sdk.gemspec +37 -0
  116. data/spec/api_client_spec.rb +227 -0
  117. data/spec/configuration_spec.rb +41 -0
  118. data/spec/spec_helper.rb +110 -0
  119. metadata +203 -0
@@ -0,0 +1,460 @@
1
+ =begin
2
+ #MassPay API
3
+
4
+ #MassPay API
5
+
6
+ The version of the OpenAPI document: 0.1.4
7
+ Contact: support@masspay.io
8
+ Generated by: MassPay Inc.
9
+ OpenAPI Generator version: 6.5.0
10
+ =end
11
+
12
+ require 'date'
13
+ require 'time'
14
+
15
+ module MassPayRubySdk
16
+ # MassPay Card Information
17
+ class GetWalletCardInfo200Response
18
+ # 16 Digits card number
19
+ attr_accessor :card_number
20
+
21
+ # 3 Digits cvv code
22
+ attr_accessor :cvv
23
+
24
+ # Card expiration date
25
+ attr_accessor :expiration_date
26
+
27
+ # Card pin number (used in ATM machines)
28
+ attr_accessor :pin_number
29
+
30
+ # Available balance on the card
31
+ attr_accessor :balance
32
+
33
+ # Card type
34
+ attr_accessor :type
35
+
36
+ # Status of the card
37
+ attr_accessor :status
38
+
39
+ class EnumAttributeValidator
40
+ attr_reader :datatype
41
+ attr_reader :allowable_values
42
+
43
+ def initialize(datatype, allowable_values)
44
+ @allowable_values = allowable_values.map do |value|
45
+ case datatype.to_s
46
+ when /Integer/i
47
+ value.to_i
48
+ when /Float/i
49
+ value.to_f
50
+ else
51
+ value
52
+ end
53
+ end
54
+ end
55
+
56
+ def valid?(value)
57
+ !value || allowable_values.include?(value)
58
+ end
59
+ end
60
+
61
+ # Attribute mapping from ruby-style variable name to JSON key.
62
+ def self.attribute_map
63
+ {
64
+ :'card_number' => :'card_number',
65
+ :'cvv' => :'cvv',
66
+ :'expiration_date' => :'expiration_date',
67
+ :'pin_number' => :'pin_number',
68
+ :'balance' => :'balance',
69
+ :'type' => :'type',
70
+ :'status' => :'status'
71
+ }
72
+ end
73
+
74
+ # Returns all the JSON keys this model knows about
75
+ def self.acceptable_attributes
76
+ attribute_map.values
77
+ end
78
+
79
+ # Attribute type mapping.
80
+ def self.openapi_types
81
+ {
82
+ :'card_number' => :'Integer',
83
+ :'cvv' => :'String',
84
+ :'expiration_date' => :'Date',
85
+ :'pin_number' => :'String',
86
+ :'balance' => :'Float',
87
+ :'type' => :'String',
88
+ :'status' => :'String'
89
+ }
90
+ end
91
+
92
+ # List of attributes with nullable: true
93
+ def self.openapi_nullable
94
+ Set.new([
95
+ ])
96
+ end
97
+
98
+ # Initializes the object
99
+ # @param [Hash] attributes Model attributes in the form of hash
100
+ def initialize(attributes = {})
101
+ if (!attributes.is_a?(Hash))
102
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MassPayRubySdk::GetWalletCardInfo200Response` initialize method"
103
+ end
104
+
105
+ # check to see if the attribute exists and convert string to symbol for hash key
106
+ attributes = attributes.each_with_object({}) { |(k, v), h|
107
+ if (!self.class.attribute_map.key?(k.to_sym))
108
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MassPayRubySdk::GetWalletCardInfo200Response`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
109
+ end
110
+ h[k.to_sym] = v
111
+ }
112
+
113
+ if attributes.key?(:'card_number')
114
+ self.card_number = attributes[:'card_number']
115
+ end
116
+
117
+ if attributes.key?(:'cvv')
118
+ self.cvv = attributes[:'cvv']
119
+ end
120
+
121
+ if attributes.key?(:'expiration_date')
122
+ self.expiration_date = attributes[:'expiration_date']
123
+ end
124
+
125
+ if attributes.key?(:'pin_number')
126
+ self.pin_number = attributes[:'pin_number']
127
+ end
128
+
129
+ if attributes.key?(:'balance')
130
+ self.balance = attributes[:'balance']
131
+ end
132
+
133
+ if attributes.key?(:'type')
134
+ self.type = attributes[:'type']
135
+ end
136
+
137
+ if attributes.key?(:'status')
138
+ self.status = attributes[:'status']
139
+ else
140
+ self.status = 'ACTIVE'
141
+ end
142
+ end
143
+
144
+ # Show invalid properties with the reasons. Usually used together with valid?
145
+ # @return Array for valid properties with the reasons
146
+ def list_invalid_properties
147
+ invalid_properties = Array.new
148
+ if @card_number.nil?
149
+ invalid_properties.push('invalid value for "card_number", card_number cannot be nil.')
150
+ end
151
+
152
+ if @cvv.nil?
153
+ invalid_properties.push('invalid value for "cvv", cvv cannot be nil.')
154
+ end
155
+
156
+ if @cvv.to_s.length > 3
157
+ invalid_properties.push('invalid value for "cvv", the character length must be smaller than or equal to 3.')
158
+ end
159
+
160
+ if @cvv.to_s.length < 3
161
+ invalid_properties.push('invalid value for "cvv", the character length must be great than or equal to 3.')
162
+ end
163
+
164
+ pattern = Regexp.new(/^[0-9]{3}$/)
165
+ if @cvv !~ pattern
166
+ invalid_properties.push("invalid value for \"cvv\", must conform to the pattern #{pattern}.")
167
+ end
168
+
169
+ if @expiration_date.nil?
170
+ invalid_properties.push('invalid value for "expiration_date", expiration_date cannot be nil.')
171
+ end
172
+
173
+ if @pin_number.nil?
174
+ invalid_properties.push('invalid value for "pin_number", pin_number cannot be nil.')
175
+ end
176
+
177
+ if @pin_number.to_s.length > 4
178
+ invalid_properties.push('invalid value for "pin_number", the character length must be smaller than or equal to 4.')
179
+ end
180
+
181
+ if @pin_number.to_s.length < 4
182
+ invalid_properties.push('invalid value for "pin_number", the character length must be great than or equal to 4.')
183
+ end
184
+
185
+ pattern = Regexp.new(/^[0-9]{4}$/)
186
+ if @pin_number !~ pattern
187
+ invalid_properties.push("invalid value for \"pin_number\", must conform to the pattern #{pattern}.")
188
+ end
189
+
190
+ if @balance.nil?
191
+ invalid_properties.push('invalid value for "balance", balance cannot be nil.')
192
+ end
193
+
194
+ if @balance < 0
195
+ invalid_properties.push('invalid value for "balance", must be greater than or equal to 0.')
196
+ end
197
+
198
+ if @type.nil?
199
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
200
+ end
201
+
202
+ if @status.nil?
203
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
204
+ end
205
+
206
+ invalid_properties
207
+ end
208
+
209
+ # Check to see if the all the properties in the model are valid
210
+ # @return true if the model is valid
211
+ def valid?
212
+ return false if @card_number.nil?
213
+ return false if @cvv.nil?
214
+ return false if @cvv.to_s.length > 3
215
+ return false if @cvv.to_s.length < 3
216
+ return false if @cvv !~ Regexp.new(/^[0-9]{3}$/)
217
+ return false if @expiration_date.nil?
218
+ return false if @pin_number.nil?
219
+ return false if @pin_number.to_s.length > 4
220
+ return false if @pin_number.to_s.length < 4
221
+ return false if @pin_number !~ Regexp.new(/^[0-9]{4}$/)
222
+ return false if @balance.nil?
223
+ return false if @balance < 0
224
+ return false if @type.nil?
225
+ type_validator = EnumAttributeValidator.new('String', ["VISA", "MASTERCARD", "DISCOVER", "AMEX", "UNIONPAY"])
226
+ return false unless type_validator.valid?(@type)
227
+ return false if @status.nil?
228
+ status_validator = EnumAttributeValidator.new('String', ["ACTIVE", "INACTIVE", "CLOSED"])
229
+ return false unless status_validator.valid?(@status)
230
+ true
231
+ end
232
+
233
+ # Custom attribute writer method with validation
234
+ # @param [Object] cvv Value to be assigned
235
+ def cvv=(cvv)
236
+ if cvv.nil?
237
+ fail ArgumentError, 'cvv cannot be nil'
238
+ end
239
+
240
+ if cvv.to_s.length > 3
241
+ fail ArgumentError, 'invalid value for "cvv", the character length must be smaller than or equal to 3.'
242
+ end
243
+
244
+ if cvv.to_s.length < 3
245
+ fail ArgumentError, 'invalid value for "cvv", the character length must be great than or equal to 3.'
246
+ end
247
+
248
+ pattern = Regexp.new(/^[0-9]{3}$/)
249
+ if cvv !~ pattern
250
+ fail ArgumentError, "invalid value for \"cvv\", must conform to the pattern #{pattern}."
251
+ end
252
+
253
+ @cvv = cvv
254
+ end
255
+
256
+ # Custom attribute writer method with validation
257
+ # @param [Object] pin_number Value to be assigned
258
+ def pin_number=(pin_number)
259
+ if pin_number.nil?
260
+ fail ArgumentError, 'pin_number cannot be nil'
261
+ end
262
+
263
+ if pin_number.to_s.length > 4
264
+ fail ArgumentError, 'invalid value for "pin_number", the character length must be smaller than or equal to 4.'
265
+ end
266
+
267
+ if pin_number.to_s.length < 4
268
+ fail ArgumentError, 'invalid value for "pin_number", the character length must be great than or equal to 4.'
269
+ end
270
+
271
+ pattern = Regexp.new(/^[0-9]{4}$/)
272
+ if pin_number !~ pattern
273
+ fail ArgumentError, "invalid value for \"pin_number\", must conform to the pattern #{pattern}."
274
+ end
275
+
276
+ @pin_number = pin_number
277
+ end
278
+
279
+ # Custom attribute writer method with validation
280
+ # @param [Object] balance Value to be assigned
281
+ def balance=(balance)
282
+ if balance.nil?
283
+ fail ArgumentError, 'balance cannot be nil'
284
+ end
285
+
286
+ if balance < 0
287
+ fail ArgumentError, 'invalid value for "balance", must be greater than or equal to 0.'
288
+ end
289
+
290
+ @balance = balance
291
+ end
292
+
293
+ # Custom attribute writer method checking allowed values (enum).
294
+ # @param [Object] type Object to be assigned
295
+ def type=(type)
296
+ validator = EnumAttributeValidator.new('String', ["VISA", "MASTERCARD", "DISCOVER", "AMEX", "UNIONPAY"])
297
+ unless validator.valid?(type)
298
+ fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
299
+ end
300
+ @type = type
301
+ end
302
+
303
+ # Custom attribute writer method checking allowed values (enum).
304
+ # @param [Object] status Object to be assigned
305
+ def status=(status)
306
+ validator = EnumAttributeValidator.new('String', ["ACTIVE", "INACTIVE", "CLOSED"])
307
+ unless validator.valid?(status)
308
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
309
+ end
310
+ @status = status
311
+ end
312
+
313
+ # Checks equality by comparing each attribute.
314
+ # @param [Object] Object to be compared
315
+ def ==(o)
316
+ return true if self.equal?(o)
317
+ self.class == o.class &&
318
+ card_number == o.card_number &&
319
+ cvv == o.cvv &&
320
+ expiration_date == o.expiration_date &&
321
+ pin_number == o.pin_number &&
322
+ balance == o.balance &&
323
+ type == o.type &&
324
+ status == o.status
325
+ end
326
+
327
+ # @see the `==` method
328
+ # @param [Object] Object to be compared
329
+ def eql?(o)
330
+ self == o
331
+ end
332
+
333
+ # Calculates hash code according to all attributes.
334
+ # @return [Integer] Hash code
335
+ def hash
336
+ [card_number, cvv, expiration_date, pin_number, balance, type, status].hash
337
+ end
338
+
339
+ # Builds the object from hash
340
+ # @param [Hash] attributes Model attributes in the form of hash
341
+ # @return [Object] Returns the model itself
342
+ def self.build_from_hash(attributes)
343
+ new.build_from_hash(attributes)
344
+ end
345
+
346
+ # Builds the object from hash
347
+ # @param [Hash] attributes Model attributes in the form of hash
348
+ # @return [Object] Returns the model itself
349
+ def build_from_hash(attributes)
350
+ return nil unless attributes.is_a?(Hash)
351
+ attributes = attributes.transform_keys(&:to_sym)
352
+ self.class.openapi_types.each_pair do |key, type|
353
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
354
+ self.send("#{key}=", nil)
355
+ elsif type =~ /\AArray<(.*)>/i
356
+ # check to ensure the input is an array given that the attribute
357
+ # is documented as an array but the input is not
358
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
359
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
360
+ end
361
+ elsif !attributes[self.class.attribute_map[key]].nil?
362
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
363
+ end
364
+ end
365
+
366
+ self
367
+ end
368
+
369
+ # Deserializes the data based on type
370
+ # @param string type Data type
371
+ # @param string value Value to be deserialized
372
+ # @return [Object] Deserialized data
373
+ def _deserialize(type, value)
374
+ case type.to_sym
375
+ when :Time
376
+ Time.parse(value)
377
+ when :Date
378
+ Date.parse(value)
379
+ when :String
380
+ value.to_s
381
+ when :Integer
382
+ value.to_i
383
+ when :Float
384
+ value.to_f
385
+ when :Boolean
386
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
387
+ true
388
+ else
389
+ false
390
+ end
391
+ when :Object
392
+ # generic object (usually a Hash), return directly
393
+ value
394
+ when /\AArray<(?<inner_type>.+)>\z/
395
+ inner_type = Regexp.last_match[:inner_type]
396
+ value.map { |v| _deserialize(inner_type, v) }
397
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
398
+ k_type = Regexp.last_match[:k_type]
399
+ v_type = Regexp.last_match[:v_type]
400
+ {}.tap do |hash|
401
+ value.each do |k, v|
402
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
403
+ end
404
+ end
405
+ else # model
406
+ # models (e.g. Pet) or oneOf
407
+ klass = MassPayRubySdk.const_get(type)
408
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
409
+ end
410
+ end
411
+
412
+ # Returns the string representation of the object
413
+ # @return [String] String presentation of the object
414
+ def to_s
415
+ to_hash.to_s
416
+ end
417
+
418
+ # to_body is an alias to to_hash (backward compatibility)
419
+ # @return [Hash] Returns the object in the form of hash
420
+ def to_body
421
+ to_hash
422
+ end
423
+
424
+ # Returns the object in the form of hash
425
+ # @return [Hash] Returns the object in the form of hash
426
+ def to_hash
427
+ hash = {}
428
+ self.class.attribute_map.each_pair do |attr, param|
429
+ value = self.send(attr)
430
+ if value.nil?
431
+ is_nullable = self.class.openapi_nullable.include?(attr)
432
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
433
+ end
434
+
435
+ hash[param] = _to_hash(value)
436
+ end
437
+ hash
438
+ end
439
+
440
+ # Outputs non-array value in the form of hash
441
+ # For object, use to_hash. Otherwise, just return the value
442
+ # @param [Object] value Any valid value
443
+ # @return [Hash] Returns the value in the form of hash
444
+ def _to_hash(value)
445
+ if value.is_a?(Array)
446
+ value.compact.map { |v| _to_hash(v) }
447
+ elsif value.is_a?(Hash)
448
+ {}.tap do |hash|
449
+ value.each { |k, v| hash[k] = _to_hash(v) }
450
+ end
451
+ elsif value.respond_to? :to_hash
452
+ value.to_hash
453
+ else
454
+ value
455
+ end
456
+ end
457
+
458
+ end
459
+
460
+ end