coinbase-sdk 0.6.0 → 0.10.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 (40) hide show
  1. checksums.yaml +4 -4
  2. data/lib/coinbase/address/wallet_address.rb +44 -0
  3. data/lib/coinbase/address.rb +13 -4
  4. data/lib/coinbase/client/api/external_addresses_api.rb +26 -27
  5. data/lib/coinbase/client/api/fund_api.rb +336 -0
  6. data/lib/coinbase/client/api/onchain_identity_api.rb +108 -0
  7. data/lib/coinbase/client/api/smart_contracts_api.rb +80 -0
  8. data/lib/coinbase/client/api/transaction_history_api.rb +101 -0
  9. data/lib/coinbase/client/api/webhooks_api.rb +70 -0
  10. data/lib/coinbase/client/models/create_fund_operation_request.rb +249 -0
  11. data/lib/coinbase/client/models/create_fund_quote_request.rb +239 -0
  12. data/lib/coinbase/client/models/create_wallet_webhook_request.rb +232 -0
  13. data/lib/coinbase/client/models/crypto_amount.rb +239 -0
  14. data/lib/coinbase/client/models/ethereum_token_transfer.rb +327 -0
  15. data/lib/coinbase/client/models/ethereum_transaction.rb +12 -1
  16. data/lib/coinbase/client/models/faucet_transaction.rb +20 -4
  17. data/lib/coinbase/client/models/fiat_amount.rb +240 -0
  18. data/lib/coinbase/client/models/fund_operation.rb +373 -0
  19. data/lib/coinbase/client/models/fund_operation_fees.rb +238 -0
  20. data/lib/coinbase/client/models/fund_operation_list.rb +275 -0
  21. data/lib/coinbase/client/models/fund_quote.rb +339 -0
  22. data/lib/coinbase/client/models/multi_token_contract_options.rb +223 -0
  23. data/lib/coinbase/client/models/network_identifier.rb +2 -1
  24. data/lib/coinbase/client/models/nft_contract_options.rb +21 -4
  25. data/lib/coinbase/client/models/onchain_name.rb +357 -0
  26. data/lib/coinbase/client/models/onchain_name_list.rb +262 -0
  27. data/lib/coinbase/client/models/read_contract_request.rb +249 -0
  28. data/lib/coinbase/client/models/smart_contract_options.rb +1 -0
  29. data/lib/coinbase/client/models/smart_contract_type.rb +2 -1
  30. data/lib/coinbase/client/models/solidity_value.rb +287 -0
  31. data/lib/coinbase/client/models/{feature.rb → token_transfer_type.rb} +10 -10
  32. data/lib/coinbase/client/models/update_webhook_request.rb +0 -7
  33. data/lib/coinbase/client.rb +19 -0
  34. data/lib/coinbase/faucet_transaction.rb +64 -4
  35. data/lib/coinbase/smart_contract.rb +149 -0
  36. data/lib/coinbase/transaction.rb +8 -2
  37. data/lib/coinbase/version.rb +1 -1
  38. data/lib/coinbase/wallet.rb +35 -1
  39. data/lib/coinbase/webhook.rb +3 -7
  40. metadata +21 -3
@@ -0,0 +1,373 @@
1
+ =begin
2
+ #Coinbase Platform API
3
+
4
+ #This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs.
5
+
6
+ The version of the OpenAPI document: 0.0.1-alpha
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.8.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Coinbase::Client
17
+ # An operation to fund a wallet with crypto
18
+ class FundOperation
19
+ # The ID of the fund operation
20
+ attr_accessor :fund_operation_id
21
+
22
+ # The ID of the blockchain network
23
+ attr_accessor :network_id
24
+
25
+ # The ID of the wallet that will receive the crypto
26
+ attr_accessor :wallet_id
27
+
28
+ # The ID of the address that will receive the crypto
29
+ attr_accessor :address_id
30
+
31
+ attr_accessor :crypto_amount
32
+
33
+ attr_accessor :fiat_amount
34
+
35
+ attr_accessor :fees
36
+
37
+ # The status of the fund operation
38
+ attr_accessor :status
39
+
40
+ class EnumAttributeValidator
41
+ attr_reader :datatype
42
+ attr_reader :allowable_values
43
+
44
+ def initialize(datatype, allowable_values)
45
+ @allowable_values = allowable_values.map do |value|
46
+ case datatype.to_s
47
+ when /Integer/i
48
+ value.to_i
49
+ when /Float/i
50
+ value.to_f
51
+ else
52
+ value
53
+ end
54
+ end
55
+ end
56
+
57
+ def valid?(value)
58
+ !value || allowable_values.include?(value)
59
+ end
60
+ end
61
+
62
+ # Attribute mapping from ruby-style variable name to JSON key.
63
+ def self.attribute_map
64
+ {
65
+ :'fund_operation_id' => :'fund_operation_id',
66
+ :'network_id' => :'network_id',
67
+ :'wallet_id' => :'wallet_id',
68
+ :'address_id' => :'address_id',
69
+ :'crypto_amount' => :'crypto_amount',
70
+ :'fiat_amount' => :'fiat_amount',
71
+ :'fees' => :'fees',
72
+ :'status' => :'status'
73
+ }
74
+ end
75
+
76
+ # Returns all the JSON keys this model knows about
77
+ def self.acceptable_attributes
78
+ attribute_map.values
79
+ end
80
+
81
+ # Attribute type mapping.
82
+ def self.openapi_types
83
+ {
84
+ :'fund_operation_id' => :'String',
85
+ :'network_id' => :'String',
86
+ :'wallet_id' => :'String',
87
+ :'address_id' => :'String',
88
+ :'crypto_amount' => :'CryptoAmount',
89
+ :'fiat_amount' => :'FiatAmount',
90
+ :'fees' => :'FundOperationFees',
91
+ :'status' => :'String'
92
+ }
93
+ end
94
+
95
+ # List of attributes with nullable: true
96
+ def self.openapi_nullable
97
+ Set.new([
98
+ ])
99
+ end
100
+
101
+ # Initializes the object
102
+ # @param [Hash] attributes Model attributes in the form of hash
103
+ def initialize(attributes = {})
104
+ if (!attributes.is_a?(Hash))
105
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::FundOperation` initialize method"
106
+ end
107
+
108
+ # check to see if the attribute exists and convert string to symbol for hash key
109
+ attributes = attributes.each_with_object({}) { |(k, v), h|
110
+ if (!self.class.attribute_map.key?(k.to_sym))
111
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::FundOperation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
112
+ end
113
+ h[k.to_sym] = v
114
+ }
115
+
116
+ if attributes.key?(:'fund_operation_id')
117
+ self.fund_operation_id = attributes[:'fund_operation_id']
118
+ else
119
+ self.fund_operation_id = nil
120
+ end
121
+
122
+ if attributes.key?(:'network_id')
123
+ self.network_id = attributes[:'network_id']
124
+ else
125
+ self.network_id = nil
126
+ end
127
+
128
+ if attributes.key?(:'wallet_id')
129
+ self.wallet_id = attributes[:'wallet_id']
130
+ else
131
+ self.wallet_id = nil
132
+ end
133
+
134
+ if attributes.key?(:'address_id')
135
+ self.address_id = attributes[:'address_id']
136
+ else
137
+ self.address_id = nil
138
+ end
139
+
140
+ if attributes.key?(:'crypto_amount')
141
+ self.crypto_amount = attributes[:'crypto_amount']
142
+ else
143
+ self.crypto_amount = nil
144
+ end
145
+
146
+ if attributes.key?(:'fiat_amount')
147
+ self.fiat_amount = attributes[:'fiat_amount']
148
+ else
149
+ self.fiat_amount = nil
150
+ end
151
+
152
+ if attributes.key?(:'fees')
153
+ self.fees = attributes[:'fees']
154
+ else
155
+ self.fees = nil
156
+ end
157
+
158
+ if attributes.key?(:'status')
159
+ self.status = attributes[:'status']
160
+ else
161
+ self.status = nil
162
+ end
163
+ end
164
+
165
+ # Show invalid properties with the reasons. Usually used together with valid?
166
+ # @return Array for valid properties with the reasons
167
+ def list_invalid_properties
168
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
169
+ invalid_properties = Array.new
170
+ if @fund_operation_id.nil?
171
+ invalid_properties.push('invalid value for "fund_operation_id", fund_operation_id cannot be nil.')
172
+ end
173
+
174
+ if @network_id.nil?
175
+ invalid_properties.push('invalid value for "network_id", network_id cannot be nil.')
176
+ end
177
+
178
+ if @wallet_id.nil?
179
+ invalid_properties.push('invalid value for "wallet_id", wallet_id cannot be nil.')
180
+ end
181
+
182
+ if @address_id.nil?
183
+ invalid_properties.push('invalid value for "address_id", address_id cannot be nil.')
184
+ end
185
+
186
+ if @crypto_amount.nil?
187
+ invalid_properties.push('invalid value for "crypto_amount", crypto_amount cannot be nil.')
188
+ end
189
+
190
+ if @fiat_amount.nil?
191
+ invalid_properties.push('invalid value for "fiat_amount", fiat_amount cannot be nil.')
192
+ end
193
+
194
+ if @fees.nil?
195
+ invalid_properties.push('invalid value for "fees", fees cannot be nil.')
196
+ end
197
+
198
+ if @status.nil?
199
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
200
+ end
201
+
202
+ invalid_properties
203
+ end
204
+
205
+ # Check to see if the all the properties in the model are valid
206
+ # @return true if the model is valid
207
+ def valid?
208
+ warn '[DEPRECATED] the `valid?` method is obsolete'
209
+ return false if @fund_operation_id.nil?
210
+ return false if @network_id.nil?
211
+ return false if @wallet_id.nil?
212
+ return false if @address_id.nil?
213
+ return false if @crypto_amount.nil?
214
+ return false if @fiat_amount.nil?
215
+ return false if @fees.nil?
216
+ return false if @status.nil?
217
+ status_validator = EnumAttributeValidator.new('String', ["pending", "complete", "failed", "unknown_default_open_api"])
218
+ return false unless status_validator.valid?(@status)
219
+ true
220
+ end
221
+
222
+ # Custom attribute writer method checking allowed values (enum).
223
+ # @param [Object] status Object to be assigned
224
+ def status=(status)
225
+ validator = EnumAttributeValidator.new('String', ["pending", "complete", "failed", "unknown_default_open_api"])
226
+ unless validator.valid?(status)
227
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
228
+ end
229
+ @status = status
230
+ end
231
+
232
+ # Checks equality by comparing each attribute.
233
+ # @param [Object] Object to be compared
234
+ def ==(o)
235
+ return true if self.equal?(o)
236
+ self.class == o.class &&
237
+ fund_operation_id == o.fund_operation_id &&
238
+ network_id == o.network_id &&
239
+ wallet_id == o.wallet_id &&
240
+ address_id == o.address_id &&
241
+ crypto_amount == o.crypto_amount &&
242
+ fiat_amount == o.fiat_amount &&
243
+ fees == o.fees &&
244
+ status == o.status
245
+ end
246
+
247
+ # @see the `==` method
248
+ # @param [Object] Object to be compared
249
+ def eql?(o)
250
+ self == o
251
+ end
252
+
253
+ # Calculates hash code according to all attributes.
254
+ # @return [Integer] Hash code
255
+ def hash
256
+ [fund_operation_id, network_id, wallet_id, address_id, crypto_amount, fiat_amount, fees, status].hash
257
+ end
258
+
259
+ # Builds the object from hash
260
+ # @param [Hash] attributes Model attributes in the form of hash
261
+ # @return [Object] Returns the model itself
262
+ def self.build_from_hash(attributes)
263
+ return nil unless attributes.is_a?(Hash)
264
+ attributes = attributes.transform_keys(&:to_sym)
265
+ transformed_hash = {}
266
+ openapi_types.each_pair do |key, type|
267
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
268
+ transformed_hash["#{key}"] = nil
269
+ elsif type =~ /\AArray<(.*)>/i
270
+ # check to ensure the input is an array given that the attribute
271
+ # is documented as an array but the input is not
272
+ if attributes[attribute_map[key]].is_a?(Array)
273
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
274
+ end
275
+ elsif !attributes[attribute_map[key]].nil?
276
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
277
+ end
278
+ end
279
+ new(transformed_hash)
280
+ end
281
+
282
+ # Deserializes the data based on type
283
+ # @param string type Data type
284
+ # @param string value Value to be deserialized
285
+ # @return [Object] Deserialized data
286
+ def self._deserialize(type, value)
287
+ case type.to_sym
288
+ when :Time
289
+ Time.parse(value)
290
+ when :Date
291
+ Date.parse(value)
292
+ when :String
293
+ value.to_s
294
+ when :Integer
295
+ value.to_i
296
+ when :Float
297
+ value.to_f
298
+ when :Boolean
299
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
300
+ true
301
+ else
302
+ false
303
+ end
304
+ when :Object
305
+ # generic object (usually a Hash), return directly
306
+ value
307
+ when /\AArray<(?<inner_type>.+)>\z/
308
+ inner_type = Regexp.last_match[:inner_type]
309
+ value.map { |v| _deserialize(inner_type, v) }
310
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
311
+ k_type = Regexp.last_match[:k_type]
312
+ v_type = Regexp.last_match[:v_type]
313
+ {}.tap do |hash|
314
+ value.each do |k, v|
315
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
316
+ end
317
+ end
318
+ else # model
319
+ # models (e.g. Pet) or oneOf
320
+ klass = Coinbase::Client.const_get(type)
321
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
322
+ end
323
+ end
324
+
325
+ # Returns the string representation of the object
326
+ # @return [String] String presentation of the object
327
+ def to_s
328
+ to_hash.to_s
329
+ end
330
+
331
+ # to_body is an alias to to_hash (backward compatibility)
332
+ # @return [Hash] Returns the object in the form of hash
333
+ def to_body
334
+ to_hash
335
+ end
336
+
337
+ # Returns the object in the form of hash
338
+ # @return [Hash] Returns the object in the form of hash
339
+ def to_hash
340
+ hash = {}
341
+ self.class.attribute_map.each_pair do |attr, param|
342
+ value = self.send(attr)
343
+ if value.nil?
344
+ is_nullable = self.class.openapi_nullable.include?(attr)
345
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
346
+ end
347
+
348
+ hash[param] = _to_hash(value)
349
+ end
350
+ hash
351
+ end
352
+
353
+ # Outputs non-array value in the form of hash
354
+ # For object, use to_hash. Otherwise, just return the value
355
+ # @param [Object] value Any valid value
356
+ # @return [Hash] Returns the value in the form of hash
357
+ def _to_hash(value)
358
+ if value.is_a?(Array)
359
+ value.compact.map { |v| _to_hash(v) }
360
+ elsif value.is_a?(Hash)
361
+ {}.tap do |hash|
362
+ value.each { |k, v| hash[k] = _to_hash(v) }
363
+ end
364
+ elsif value.respond_to? :to_hash
365
+ value.to_hash
366
+ else
367
+ value
368
+ end
369
+ end
370
+
371
+ end
372
+
373
+ end
@@ -0,0 +1,238 @@
1
+ =begin
2
+ #Coinbase Platform API
3
+
4
+ #This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs.
5
+
6
+ The version of the OpenAPI document: 0.0.1-alpha
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.8.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Coinbase::Client
17
+ # The fees for a fund operation.
18
+ class FundOperationFees
19
+ attr_accessor :buy_fee
20
+
21
+ attr_accessor :transfer_fee
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'buy_fee' => :'buy_fee',
27
+ :'transfer_fee' => :'transfer_fee'
28
+ }
29
+ end
30
+
31
+ # Returns all the JSON keys this model knows about
32
+ def self.acceptable_attributes
33
+ attribute_map.values
34
+ end
35
+
36
+ # Attribute type mapping.
37
+ def self.openapi_types
38
+ {
39
+ :'buy_fee' => :'FiatAmount',
40
+ :'transfer_fee' => :'CryptoAmount'
41
+ }
42
+ end
43
+
44
+ # List of attributes with nullable: true
45
+ def self.openapi_nullable
46
+ Set.new([
47
+ ])
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ if (!attributes.is_a?(Hash))
54
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::FundOperationFees` initialize method"
55
+ end
56
+
57
+ # check to see if the attribute exists and convert string to symbol for hash key
58
+ attributes = attributes.each_with_object({}) { |(k, v), h|
59
+ if (!self.class.attribute_map.key?(k.to_sym))
60
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::FundOperationFees`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
61
+ end
62
+ h[k.to_sym] = v
63
+ }
64
+
65
+ if attributes.key?(:'buy_fee')
66
+ self.buy_fee = attributes[:'buy_fee']
67
+ else
68
+ self.buy_fee = nil
69
+ end
70
+
71
+ if attributes.key?(:'transfer_fee')
72
+ self.transfer_fee = attributes[:'transfer_fee']
73
+ else
74
+ self.transfer_fee = nil
75
+ end
76
+ end
77
+
78
+ # Show invalid properties with the reasons. Usually used together with valid?
79
+ # @return Array for valid properties with the reasons
80
+ def list_invalid_properties
81
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
82
+ invalid_properties = Array.new
83
+ if @buy_fee.nil?
84
+ invalid_properties.push('invalid value for "buy_fee", buy_fee cannot be nil.')
85
+ end
86
+
87
+ if @transfer_fee.nil?
88
+ invalid_properties.push('invalid value for "transfer_fee", transfer_fee cannot be nil.')
89
+ end
90
+
91
+ invalid_properties
92
+ end
93
+
94
+ # Check to see if the all the properties in the model are valid
95
+ # @return true if the model is valid
96
+ def valid?
97
+ warn '[DEPRECATED] the `valid?` method is obsolete'
98
+ return false if @buy_fee.nil?
99
+ return false if @transfer_fee.nil?
100
+ true
101
+ end
102
+
103
+ # Checks equality by comparing each attribute.
104
+ # @param [Object] Object to be compared
105
+ def ==(o)
106
+ return true if self.equal?(o)
107
+ self.class == o.class &&
108
+ buy_fee == o.buy_fee &&
109
+ transfer_fee == o.transfer_fee
110
+ end
111
+
112
+ # @see the `==` method
113
+ # @param [Object] Object to be compared
114
+ def eql?(o)
115
+ self == o
116
+ end
117
+
118
+ # Calculates hash code according to all attributes.
119
+ # @return [Integer] Hash code
120
+ def hash
121
+ [buy_fee, transfer_fee].hash
122
+ end
123
+
124
+ # Builds the object from hash
125
+ # @param [Hash] attributes Model attributes in the form of hash
126
+ # @return [Object] Returns the model itself
127
+ def self.build_from_hash(attributes)
128
+ return nil unless attributes.is_a?(Hash)
129
+ attributes = attributes.transform_keys(&:to_sym)
130
+ transformed_hash = {}
131
+ openapi_types.each_pair do |key, type|
132
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
133
+ transformed_hash["#{key}"] = nil
134
+ elsif type =~ /\AArray<(.*)>/i
135
+ # check to ensure the input is an array given that the attribute
136
+ # is documented as an array but the input is not
137
+ if attributes[attribute_map[key]].is_a?(Array)
138
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
139
+ end
140
+ elsif !attributes[attribute_map[key]].nil?
141
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
142
+ end
143
+ end
144
+ new(transformed_hash)
145
+ end
146
+
147
+ # Deserializes the data based on type
148
+ # @param string type Data type
149
+ # @param string value Value to be deserialized
150
+ # @return [Object] Deserialized data
151
+ def self._deserialize(type, value)
152
+ case type.to_sym
153
+ when :Time
154
+ Time.parse(value)
155
+ when :Date
156
+ Date.parse(value)
157
+ when :String
158
+ value.to_s
159
+ when :Integer
160
+ value.to_i
161
+ when :Float
162
+ value.to_f
163
+ when :Boolean
164
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
165
+ true
166
+ else
167
+ false
168
+ end
169
+ when :Object
170
+ # generic object (usually a Hash), return directly
171
+ value
172
+ when /\AArray<(?<inner_type>.+)>\z/
173
+ inner_type = Regexp.last_match[:inner_type]
174
+ value.map { |v| _deserialize(inner_type, v) }
175
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
176
+ k_type = Regexp.last_match[:k_type]
177
+ v_type = Regexp.last_match[:v_type]
178
+ {}.tap do |hash|
179
+ value.each do |k, v|
180
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
181
+ end
182
+ end
183
+ else # model
184
+ # models (e.g. Pet) or oneOf
185
+ klass = Coinbase::Client.const_get(type)
186
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
187
+ end
188
+ end
189
+
190
+ # Returns the string representation of the object
191
+ # @return [String] String presentation of the object
192
+ def to_s
193
+ to_hash.to_s
194
+ end
195
+
196
+ # to_body is an alias to to_hash (backward compatibility)
197
+ # @return [Hash] Returns the object in the form of hash
198
+ def to_body
199
+ to_hash
200
+ end
201
+
202
+ # Returns the object in the form of hash
203
+ # @return [Hash] Returns the object in the form of hash
204
+ def to_hash
205
+ hash = {}
206
+ self.class.attribute_map.each_pair do |attr, param|
207
+ value = self.send(attr)
208
+ if value.nil?
209
+ is_nullable = self.class.openapi_nullable.include?(attr)
210
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
211
+ end
212
+
213
+ hash[param] = _to_hash(value)
214
+ end
215
+ hash
216
+ end
217
+
218
+ # Outputs non-array value in the form of hash
219
+ # For object, use to_hash. Otherwise, just return the value
220
+ # @param [Object] value Any valid value
221
+ # @return [Hash] Returns the value in the form of hash
222
+ def _to_hash(value)
223
+ if value.is_a?(Array)
224
+ value.compact.map { |v| _to_hash(v) }
225
+ elsif value.is_a?(Hash)
226
+ {}.tap do |hash|
227
+ value.each { |k, v| hash[k] = _to_hash(v) }
228
+ end
229
+ elsif value.respond_to? :to_hash
230
+ value.to_hash
231
+ else
232
+ value
233
+ end
234
+ end
235
+
236
+ end
237
+
238
+ end