coinbase-sdk 0.0.13 → 0.0.16

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 (58) hide show
  1. checksums.yaml +4 -4
  2. data/lib/coinbase/address/external_address.rb +3 -166
  3. data/lib/coinbase/address/wallet_address.rb +51 -4
  4. data/lib/coinbase/address.rb +164 -0
  5. data/lib/coinbase/client/api/assets_api.rb +2 -2
  6. data/lib/coinbase/client/api/contract_events_api.rb +121 -0
  7. data/lib/coinbase/client/api/external_addresses_api.rb +85 -0
  8. data/lib/coinbase/client/api/networks_api.rb +85 -0
  9. data/lib/coinbase/client/api/stake_api.rb +361 -0
  10. data/lib/coinbase/client/api/webhooks_api.rb +286 -0
  11. data/lib/coinbase/client/models/address_historical_balance_list.rb +258 -0
  12. data/lib/coinbase/client/models/broadcast_staking_operation_request.rb +239 -0
  13. data/lib/coinbase/client/models/contract_event.rb +336 -0
  14. data/lib/coinbase/client/models/contract_event_list.rb +259 -0
  15. data/lib/coinbase/client/models/create_staking_operation_request.rb +274 -0
  16. data/lib/coinbase/client/models/create_transfer_request.rb +14 -4
  17. data/lib/coinbase/client/models/create_webhook_request.rb +282 -0
  18. data/lib/coinbase/client/models/ethereum_validator.rb +374 -0
  19. data/lib/coinbase/client/models/feature_set.rb +307 -0
  20. data/lib/coinbase/client/models/fetch_historical_staking_balances200_response.rb +258 -0
  21. data/lib/coinbase/client/models/get_validator200_response.rb +221 -0
  22. data/lib/coinbase/client/models/get_validator200_response_validator.rb +214 -0
  23. data/lib/coinbase/client/models/historical_balance.rb +273 -0
  24. data/lib/coinbase/client/models/network.rb +355 -0
  25. data/lib/coinbase/client/models/network_identifier.rb +44 -0
  26. data/lib/coinbase/client/models/sponsored_send.rb +338 -0
  27. data/lib/coinbase/client/models/staking_balance.rb +289 -0
  28. data/lib/coinbase/client/models/staking_context_context.rb +222 -74
  29. data/lib/coinbase/client/models/staking_operation.rb +15 -5
  30. data/lib/coinbase/client/models/staking_reward.rb +22 -6
  31. data/lib/coinbase/client/models/staking_reward_format.rb +2 -1
  32. data/lib/coinbase/client/models/staking_reward_usd_value.rb +257 -0
  33. data/lib/coinbase/client/models/transaction.rb +2 -2
  34. data/lib/coinbase/client/models/transaction_type.rb +2 -1
  35. data/lib/coinbase/client/models/transfer.rb +29 -24
  36. data/lib/coinbase/client/models/update_webhook_request.rb +289 -0
  37. data/lib/coinbase/client/models/validator_list_data.rb +216 -0
  38. data/lib/coinbase/client/models/wallet.rb +13 -16
  39. data/lib/coinbase/client/models/webhook.rb +299 -0
  40. data/lib/coinbase/client/models/webhook_event_filter.rb +236 -0
  41. data/lib/coinbase/client/models/webhook_event_type.rb +42 -0
  42. data/lib/coinbase/client/models/webhook_list.rb +244 -0
  43. data/lib/coinbase/client.rb +22 -3
  44. data/lib/coinbase/errors.rb +7 -0
  45. data/lib/coinbase/historical_balance.rb +53 -0
  46. data/lib/coinbase/middleware.rb +12 -0
  47. data/lib/coinbase/server_signer.rb +14 -3
  48. data/lib/coinbase/sponsored_send.rb +110 -0
  49. data/lib/coinbase/staking_balance.rb +86 -0
  50. data/lib/coinbase/staking_operation.rb +106 -5
  51. data/lib/coinbase/staking_reward.rb +18 -0
  52. data/lib/coinbase/trade.rb +1 -1
  53. data/lib/coinbase/transaction.rb +7 -3
  54. data/lib/coinbase/transfer.rb +56 -29
  55. data/lib/coinbase/wallet/data.rb +31 -0
  56. data/lib/coinbase/wallet.rb +91 -46
  57. data/lib/coinbase.rb +17 -4
  58. metadata +74 -2
@@ -0,0 +1,338 @@
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
+ Contact: yuga.cohler@coinbase.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.6.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Coinbase::Client
17
+ # An onchain sponsored gasless send.
18
+ class SponsoredSend
19
+ # The onchain address of the recipient
20
+ attr_accessor :to_address_id
21
+
22
+ # The raw typed data for the sponsored send
23
+ attr_accessor :raw_typed_data
24
+
25
+ # The typed data hash for the sponsored send. This is the typed data hash that needs to be signed by the sender.
26
+ attr_accessor :typed_data_hash
27
+
28
+ # The signed hash of the sponsored send typed data.
29
+ attr_accessor :signature
30
+
31
+ # The hash of the onchain sponsored send transaction
32
+ attr_accessor :transaction_hash
33
+
34
+ # The link to view the transaction on a block explorer. This is optional and may not be present for all transactions.
35
+ attr_accessor :transaction_link
36
+
37
+ # The status of the sponsored send
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
+ :'to_address_id' => :'to_address_id',
66
+ :'raw_typed_data' => :'raw_typed_data',
67
+ :'typed_data_hash' => :'typed_data_hash',
68
+ :'signature' => :'signature',
69
+ :'transaction_hash' => :'transaction_hash',
70
+ :'transaction_link' => :'transaction_link',
71
+ :'status' => :'status'
72
+ }
73
+ end
74
+
75
+ # Returns all the JSON keys this model knows about
76
+ def self.acceptable_attributes
77
+ attribute_map.values
78
+ end
79
+
80
+ # Attribute type mapping.
81
+ def self.openapi_types
82
+ {
83
+ :'to_address_id' => :'String',
84
+ :'raw_typed_data' => :'String',
85
+ :'typed_data_hash' => :'String',
86
+ :'signature' => :'String',
87
+ :'transaction_hash' => :'String',
88
+ :'transaction_link' => :'String',
89
+ :'status' => :'String'
90
+ }
91
+ end
92
+
93
+ # List of attributes with nullable: true
94
+ def self.openapi_nullable
95
+ Set.new([
96
+ ])
97
+ end
98
+
99
+ # Initializes the object
100
+ # @param [Hash] attributes Model attributes in the form of hash
101
+ def initialize(attributes = {})
102
+ if (!attributes.is_a?(Hash))
103
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::SponsoredSend` initialize method"
104
+ end
105
+
106
+ # check to see if the attribute exists and convert string to symbol for hash key
107
+ attributes = attributes.each_with_object({}) { |(k, v), h|
108
+ if (!self.class.attribute_map.key?(k.to_sym))
109
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::SponsoredSend`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
110
+ end
111
+ h[k.to_sym] = v
112
+ }
113
+
114
+ if attributes.key?(:'to_address_id')
115
+ self.to_address_id = attributes[:'to_address_id']
116
+ else
117
+ self.to_address_id = nil
118
+ end
119
+
120
+ if attributes.key?(:'raw_typed_data')
121
+ self.raw_typed_data = attributes[:'raw_typed_data']
122
+ else
123
+ self.raw_typed_data = nil
124
+ end
125
+
126
+ if attributes.key?(:'typed_data_hash')
127
+ self.typed_data_hash = attributes[:'typed_data_hash']
128
+ else
129
+ self.typed_data_hash = nil
130
+ end
131
+
132
+ if attributes.key?(:'signature')
133
+ self.signature = attributes[:'signature']
134
+ end
135
+
136
+ if attributes.key?(:'transaction_hash')
137
+ self.transaction_hash = attributes[:'transaction_hash']
138
+ end
139
+
140
+ if attributes.key?(:'transaction_link')
141
+ self.transaction_link = attributes[:'transaction_link']
142
+ end
143
+
144
+ if attributes.key?(:'status')
145
+ self.status = attributes[:'status']
146
+ else
147
+ self.status = nil
148
+ end
149
+ end
150
+
151
+ # Show invalid properties with the reasons. Usually used together with valid?
152
+ # @return Array for valid properties with the reasons
153
+ def list_invalid_properties
154
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
155
+ invalid_properties = Array.new
156
+ if @to_address_id.nil?
157
+ invalid_properties.push('invalid value for "to_address_id", to_address_id cannot be nil.')
158
+ end
159
+
160
+ if @raw_typed_data.nil?
161
+ invalid_properties.push('invalid value for "raw_typed_data", raw_typed_data cannot be nil.')
162
+ end
163
+
164
+ if @typed_data_hash.nil?
165
+ invalid_properties.push('invalid value for "typed_data_hash", typed_data_hash cannot be nil.')
166
+ end
167
+
168
+ if @status.nil?
169
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
170
+ end
171
+
172
+ invalid_properties
173
+ end
174
+
175
+ # Check to see if the all the properties in the model are valid
176
+ # @return true if the model is valid
177
+ def valid?
178
+ warn '[DEPRECATED] the `valid?` method is obsolete'
179
+ return false if @to_address_id.nil?
180
+ return false if @raw_typed_data.nil?
181
+ return false if @typed_data_hash.nil?
182
+ return false if @status.nil?
183
+ status_validator = EnumAttributeValidator.new('String', ["pending", "signed", "submitted", "complete", "failed", "unknown_default_open_api"])
184
+ return false unless status_validator.valid?(@status)
185
+ true
186
+ end
187
+
188
+ # Custom attribute writer method checking allowed values (enum).
189
+ # @param [Object] status Object to be assigned
190
+ def status=(status)
191
+ validator = EnumAttributeValidator.new('String', ["pending", "signed", "submitted", "complete", "failed", "unknown_default_open_api"])
192
+ unless validator.valid?(status)
193
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
194
+ end
195
+ @status = status
196
+ end
197
+
198
+ # Checks equality by comparing each attribute.
199
+ # @param [Object] Object to be compared
200
+ def ==(o)
201
+ return true if self.equal?(o)
202
+ self.class == o.class &&
203
+ to_address_id == o.to_address_id &&
204
+ raw_typed_data == o.raw_typed_data &&
205
+ typed_data_hash == o.typed_data_hash &&
206
+ signature == o.signature &&
207
+ transaction_hash == o.transaction_hash &&
208
+ transaction_link == o.transaction_link &&
209
+ status == o.status
210
+ end
211
+
212
+ # @see the `==` method
213
+ # @param [Object] Object to be compared
214
+ def eql?(o)
215
+ self == o
216
+ end
217
+
218
+ # Calculates hash code according to all attributes.
219
+ # @return [Integer] Hash code
220
+ def hash
221
+ [to_address_id, raw_typed_data, typed_data_hash, signature, transaction_hash, transaction_link, status].hash
222
+ end
223
+
224
+ # Builds the object from hash
225
+ # @param [Hash] attributes Model attributes in the form of hash
226
+ # @return [Object] Returns the model itself
227
+ def self.build_from_hash(attributes)
228
+ return nil unless attributes.is_a?(Hash)
229
+ attributes = attributes.transform_keys(&:to_sym)
230
+ transformed_hash = {}
231
+ openapi_types.each_pair do |key, type|
232
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
233
+ transformed_hash["#{key}"] = nil
234
+ elsif type =~ /\AArray<(.*)>/i
235
+ # check to ensure the input is an array given that the attribute
236
+ # is documented as an array but the input is not
237
+ if attributes[attribute_map[key]].is_a?(Array)
238
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
239
+ end
240
+ elsif !attributes[attribute_map[key]].nil?
241
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
242
+ end
243
+ end
244
+ new(transformed_hash)
245
+ end
246
+
247
+ # Deserializes the data based on type
248
+ # @param string type Data type
249
+ # @param string value Value to be deserialized
250
+ # @return [Object] Deserialized data
251
+ def self._deserialize(type, value)
252
+ case type.to_sym
253
+ when :Time
254
+ Time.parse(value)
255
+ when :Date
256
+ Date.parse(value)
257
+ when :String
258
+ value.to_s
259
+ when :Integer
260
+ value.to_i
261
+ when :Float
262
+ value.to_f
263
+ when :Boolean
264
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
265
+ true
266
+ else
267
+ false
268
+ end
269
+ when :Object
270
+ # generic object (usually a Hash), return directly
271
+ value
272
+ when /\AArray<(?<inner_type>.+)>\z/
273
+ inner_type = Regexp.last_match[:inner_type]
274
+ value.map { |v| _deserialize(inner_type, v) }
275
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
276
+ k_type = Regexp.last_match[:k_type]
277
+ v_type = Regexp.last_match[:v_type]
278
+ {}.tap do |hash|
279
+ value.each do |k, v|
280
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
281
+ end
282
+ end
283
+ else # model
284
+ # models (e.g. Pet) or oneOf
285
+ klass = Coinbase::Client.const_get(type)
286
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
287
+ end
288
+ end
289
+
290
+ # Returns the string representation of the object
291
+ # @return [String] String presentation of the object
292
+ def to_s
293
+ to_hash.to_s
294
+ end
295
+
296
+ # to_body is an alias to to_hash (backward compatibility)
297
+ # @return [Hash] Returns the object in the form of hash
298
+ def to_body
299
+ to_hash
300
+ end
301
+
302
+ # Returns the object in the form of hash
303
+ # @return [Hash] Returns the object in the form of hash
304
+ def to_hash
305
+ hash = {}
306
+ self.class.attribute_map.each_pair do |attr, param|
307
+ value = self.send(attr)
308
+ if value.nil?
309
+ is_nullable = self.class.openapi_nullable.include?(attr)
310
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
311
+ end
312
+
313
+ hash[param] = _to_hash(value)
314
+ end
315
+ hash
316
+ end
317
+
318
+ # Outputs non-array value in the form of hash
319
+ # For object, use to_hash. Otherwise, just return the value
320
+ # @param [Object] value Any valid value
321
+ # @return [Hash] Returns the value in the form of hash
322
+ def _to_hash(value)
323
+ if value.is_a?(Array)
324
+ value.compact.map { |v| _to_hash(v) }
325
+ elsif value.is_a?(Hash)
326
+ {}.tap do |hash|
327
+ value.each { |k, v| hash[k] = _to_hash(v) }
328
+ end
329
+ elsif value.respond_to? :to_hash
330
+ value.to_hash
331
+ else
332
+ value
333
+ end
334
+ end
335
+
336
+ end
337
+
338
+ end
@@ -0,0 +1,289 @@
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
+ Contact: yuga.cohler@coinbase.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.6.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Coinbase::Client
17
+ # The staking balances for an address.
18
+ class StakingBalance
19
+ # The onchain address for which the staking balances are being fetched.
20
+ attr_accessor :address
21
+
22
+ # The date of the staking balance in format 'YYYY-MM-DD' in UTC.
23
+ attr_accessor :date
24
+
25
+ attr_accessor :bonded_stake
26
+
27
+ attr_accessor :unbonded_balance
28
+
29
+ # The type of staking participation.
30
+ attr_accessor :participant_type
31
+
32
+ # Attribute mapping from ruby-style variable name to JSON key.
33
+ def self.attribute_map
34
+ {
35
+ :'address' => :'address',
36
+ :'date' => :'date',
37
+ :'bonded_stake' => :'bonded_stake',
38
+ :'unbonded_balance' => :'unbonded_balance',
39
+ :'participant_type' => :'participant_type'
40
+ }
41
+ end
42
+
43
+ # Returns all the JSON keys this model knows about
44
+ def self.acceptable_attributes
45
+ attribute_map.values
46
+ end
47
+
48
+ # Attribute type mapping.
49
+ def self.openapi_types
50
+ {
51
+ :'address' => :'String',
52
+ :'date' => :'Date',
53
+ :'bonded_stake' => :'Balance',
54
+ :'unbonded_balance' => :'Balance',
55
+ :'participant_type' => :'String'
56
+ }
57
+ end
58
+
59
+ # List of attributes with nullable: true
60
+ def self.openapi_nullable
61
+ Set.new([
62
+ ])
63
+ end
64
+
65
+ # Initializes the object
66
+ # @param [Hash] attributes Model attributes in the form of hash
67
+ def initialize(attributes = {})
68
+ if (!attributes.is_a?(Hash))
69
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::StakingBalance` initialize method"
70
+ end
71
+
72
+ # check to see if the attribute exists and convert string to symbol for hash key
73
+ attributes = attributes.each_with_object({}) { |(k, v), h|
74
+ if (!self.class.attribute_map.key?(k.to_sym))
75
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::StakingBalance`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
76
+ end
77
+ h[k.to_sym] = v
78
+ }
79
+
80
+ if attributes.key?(:'address')
81
+ self.address = attributes[:'address']
82
+ else
83
+ self.address = nil
84
+ end
85
+
86
+ if attributes.key?(:'date')
87
+ self.date = attributes[:'date']
88
+ else
89
+ self.date = nil
90
+ end
91
+
92
+ if attributes.key?(:'bonded_stake')
93
+ self.bonded_stake = attributes[:'bonded_stake']
94
+ else
95
+ self.bonded_stake = nil
96
+ end
97
+
98
+ if attributes.key?(:'unbonded_balance')
99
+ self.unbonded_balance = attributes[:'unbonded_balance']
100
+ else
101
+ self.unbonded_balance = nil
102
+ end
103
+
104
+ if attributes.key?(:'participant_type')
105
+ self.participant_type = attributes[:'participant_type']
106
+ else
107
+ self.participant_type = nil
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
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
115
+ invalid_properties = Array.new
116
+ if @address.nil?
117
+ invalid_properties.push('invalid value for "address", address cannot be nil.')
118
+ end
119
+
120
+ if @date.nil?
121
+ invalid_properties.push('invalid value for "date", date cannot be nil.')
122
+ end
123
+
124
+ if @bonded_stake.nil?
125
+ invalid_properties.push('invalid value for "bonded_stake", bonded_stake cannot be nil.')
126
+ end
127
+
128
+ if @unbonded_balance.nil?
129
+ invalid_properties.push('invalid value for "unbonded_balance", unbonded_balance cannot be nil.')
130
+ end
131
+
132
+ if @participant_type.nil?
133
+ invalid_properties.push('invalid value for "participant_type", participant_type cannot be nil.')
134
+ end
135
+
136
+ invalid_properties
137
+ end
138
+
139
+ # Check to see if the all the properties in the model are valid
140
+ # @return true if the model is valid
141
+ def valid?
142
+ warn '[DEPRECATED] the `valid?` method is obsolete'
143
+ return false if @address.nil?
144
+ return false if @date.nil?
145
+ return false if @bonded_stake.nil?
146
+ return false if @unbonded_balance.nil?
147
+ return false if @participant_type.nil?
148
+ true
149
+ end
150
+
151
+ # Checks equality by comparing each attribute.
152
+ # @param [Object] Object to be compared
153
+ def ==(o)
154
+ return true if self.equal?(o)
155
+ self.class == o.class &&
156
+ address == o.address &&
157
+ date == o.date &&
158
+ bonded_stake == o.bonded_stake &&
159
+ unbonded_balance == o.unbonded_balance &&
160
+ participant_type == o.participant_type
161
+ end
162
+
163
+ # @see the `==` method
164
+ # @param [Object] Object to be compared
165
+ def eql?(o)
166
+ self == o
167
+ end
168
+
169
+ # Calculates hash code according to all attributes.
170
+ # @return [Integer] Hash code
171
+ def hash
172
+ [address, date, bonded_stake, unbonded_balance, participant_type].hash
173
+ end
174
+
175
+ # Builds the object from hash
176
+ # @param [Hash] attributes Model attributes in the form of hash
177
+ # @return [Object] Returns the model itself
178
+ def self.build_from_hash(attributes)
179
+ return nil unless attributes.is_a?(Hash)
180
+ attributes = attributes.transform_keys(&:to_sym)
181
+ transformed_hash = {}
182
+ openapi_types.each_pair do |key, type|
183
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
184
+ transformed_hash["#{key}"] = nil
185
+ elsif type =~ /\AArray<(.*)>/i
186
+ # check to ensure the input is an array given that the attribute
187
+ # is documented as an array but the input is not
188
+ if attributes[attribute_map[key]].is_a?(Array)
189
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
190
+ end
191
+ elsif !attributes[attribute_map[key]].nil?
192
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
193
+ end
194
+ end
195
+ new(transformed_hash)
196
+ end
197
+
198
+ # Deserializes the data based on type
199
+ # @param string type Data type
200
+ # @param string value Value to be deserialized
201
+ # @return [Object] Deserialized data
202
+ def self._deserialize(type, value)
203
+ case type.to_sym
204
+ when :Time
205
+ Time.parse(value)
206
+ when :Date
207
+ Date.parse(value)
208
+ when :String
209
+ value.to_s
210
+ when :Integer
211
+ value.to_i
212
+ when :Float
213
+ value.to_f
214
+ when :Boolean
215
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
216
+ true
217
+ else
218
+ false
219
+ end
220
+ when :Object
221
+ # generic object (usually a Hash), return directly
222
+ value
223
+ when /\AArray<(?<inner_type>.+)>\z/
224
+ inner_type = Regexp.last_match[:inner_type]
225
+ value.map { |v| _deserialize(inner_type, v) }
226
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
227
+ k_type = Regexp.last_match[:k_type]
228
+ v_type = Regexp.last_match[:v_type]
229
+ {}.tap do |hash|
230
+ value.each do |k, v|
231
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
232
+ end
233
+ end
234
+ else # model
235
+ # models (e.g. Pet) or oneOf
236
+ klass = Coinbase::Client.const_get(type)
237
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
238
+ end
239
+ end
240
+
241
+ # Returns the string representation of the object
242
+ # @return [String] String presentation of the object
243
+ def to_s
244
+ to_hash.to_s
245
+ end
246
+
247
+ # to_body is an alias to to_hash (backward compatibility)
248
+ # @return [Hash] Returns the object in the form of hash
249
+ def to_body
250
+ to_hash
251
+ end
252
+
253
+ # Returns the object in the form of hash
254
+ # @return [Hash] Returns the object in the form of hash
255
+ def to_hash
256
+ hash = {}
257
+ self.class.attribute_map.each_pair do |attr, param|
258
+ value = self.send(attr)
259
+ if value.nil?
260
+ is_nullable = self.class.openapi_nullable.include?(attr)
261
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
262
+ end
263
+
264
+ hash[param] = _to_hash(value)
265
+ end
266
+ hash
267
+ end
268
+
269
+ # Outputs non-array value in the form of hash
270
+ # For object, use to_hash. Otherwise, just return the value
271
+ # @param [Object] value Any valid value
272
+ # @return [Hash] Returns the value in the form of hash
273
+ def _to_hash(value)
274
+ if value.is_a?(Array)
275
+ value.compact.map { |v| _to_hash(v) }
276
+ elsif value.is_a?(Hash)
277
+ {}.tap do |hash|
278
+ value.each { |k, v| hash[k] = _to_hash(v) }
279
+ end
280
+ elsif value.respond_to? :to_hash
281
+ value.to_hash
282
+ else
283
+ value
284
+ end
285
+ end
286
+
287
+ end
288
+
289
+ end