coinbase-sdk 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/lib/coinbase/address.rb +152 -51
  3. data/lib/coinbase/asset.rb +2 -1
  4. data/lib/coinbase/authenticator.rb +52 -0
  5. data/lib/coinbase/balance_map.rb +2 -2
  6. data/lib/coinbase/client/api/addresses_api.rb +454 -0
  7. data/lib/coinbase/client/api/transfers_api.rb +342 -0
  8. data/lib/coinbase/client/api/users_api.rb +79 -0
  9. data/lib/coinbase/client/api/wallets_api.rb +348 -0
  10. data/lib/coinbase/client/api_client.rb +431 -0
  11. data/lib/coinbase/client/api_error.rb +58 -0
  12. data/lib/coinbase/client/configuration.rb +375 -0
  13. data/lib/coinbase/client/models/address.rb +273 -0
  14. data/lib/coinbase/client/models/address_balance_list.rb +275 -0
  15. data/lib/coinbase/client/models/address_list.rb +275 -0
  16. data/lib/coinbase/client/models/asset.rb +260 -0
  17. data/lib/coinbase/client/models/balance.rb +239 -0
  18. data/lib/coinbase/client/models/broadcast_transfer_request.rb +222 -0
  19. data/lib/coinbase/client/models/create_address_request.rb +239 -0
  20. data/lib/coinbase/client/models/create_transfer_request.rb +273 -0
  21. data/lib/coinbase/client/models/create_wallet_request.rb +221 -0
  22. data/lib/coinbase/client/models/error.rb +278 -0
  23. data/lib/coinbase/client/models/faucet_transaction.rb +222 -0
  24. data/lib/coinbase/client/models/transfer.rb +413 -0
  25. data/lib/coinbase/client/models/transfer_list.rb +275 -0
  26. data/lib/coinbase/client/models/user.rb +231 -0
  27. data/lib/coinbase/client/models/wallet.rb +241 -0
  28. data/lib/coinbase/client/models/wallet_list.rb +275 -0
  29. data/lib/coinbase/client/version.rb +15 -0
  30. data/lib/coinbase/client.rb +59 -0
  31. data/lib/coinbase/constants.rb +8 -2
  32. data/lib/coinbase/errors.rb +120 -0
  33. data/lib/coinbase/faucet_transaction.rb +42 -0
  34. data/lib/coinbase/middleware.rb +21 -0
  35. data/lib/coinbase/network.rb +2 -2
  36. data/lib/coinbase/transfer.rb +106 -65
  37. data/lib/coinbase/user.rb +180 -0
  38. data/lib/coinbase/wallet.rb +168 -52
  39. data/lib/coinbase.rb +127 -9
  40. metadata +92 -6
@@ -0,0 +1,413 @@
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.5.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Coinbase::Client
17
+ # A transfer of an asset from one address to another
18
+ class Transfer
19
+ # The ID of the blockchain network
20
+ attr_accessor :network_id
21
+
22
+ # The ID of the wallet that owns the from address
23
+ attr_accessor :wallet_id
24
+
25
+ # The onchain address of the sender
26
+ attr_accessor :address_id
27
+
28
+ # The onchain address of the recipient
29
+ attr_accessor :destination
30
+
31
+ # The amount in the atomic units of the asset
32
+ attr_accessor :amount
33
+
34
+ # The ID of the asset being transferred
35
+ attr_accessor :asset_id
36
+
37
+ # The ID of the transfer
38
+ attr_accessor :transfer_id
39
+
40
+ # The unsigned payload of the transfer. This is the payload that needs to be signed by the sender.
41
+ attr_accessor :unsigned_payload
42
+
43
+ # The signed payload of the transfer. This is the payload that has been signed by the sender.
44
+ attr_accessor :signed_payload
45
+
46
+ # The hash of the transfer transaction
47
+ attr_accessor :transaction_hash
48
+
49
+ # The status of the transfer
50
+ attr_accessor :status
51
+
52
+ class EnumAttributeValidator
53
+ attr_reader :datatype
54
+ attr_reader :allowable_values
55
+
56
+ def initialize(datatype, allowable_values)
57
+ @allowable_values = allowable_values.map do |value|
58
+ case datatype.to_s
59
+ when /Integer/i
60
+ value.to_i
61
+ when /Float/i
62
+ value.to_f
63
+ else
64
+ value
65
+ end
66
+ end
67
+ end
68
+
69
+ def valid?(value)
70
+ !value || allowable_values.include?(value)
71
+ end
72
+ end
73
+
74
+ # Attribute mapping from ruby-style variable name to JSON key.
75
+ def self.attribute_map
76
+ {
77
+ :'network_id' => :'network_id',
78
+ :'wallet_id' => :'wallet_id',
79
+ :'address_id' => :'address_id',
80
+ :'destination' => :'destination',
81
+ :'amount' => :'amount',
82
+ :'asset_id' => :'asset_id',
83
+ :'transfer_id' => :'transfer_id',
84
+ :'unsigned_payload' => :'unsigned_payload',
85
+ :'signed_payload' => :'signed_payload',
86
+ :'transaction_hash' => :'transaction_hash',
87
+ :'status' => :'status'
88
+ }
89
+ end
90
+
91
+ # Returns all the JSON keys this model knows about
92
+ def self.acceptable_attributes
93
+ attribute_map.values
94
+ end
95
+
96
+ # Attribute type mapping.
97
+ def self.openapi_types
98
+ {
99
+ :'network_id' => :'String',
100
+ :'wallet_id' => :'String',
101
+ :'address_id' => :'String',
102
+ :'destination' => :'String',
103
+ :'amount' => :'String',
104
+ :'asset_id' => :'String',
105
+ :'transfer_id' => :'String',
106
+ :'unsigned_payload' => :'String',
107
+ :'signed_payload' => :'String',
108
+ :'transaction_hash' => :'String',
109
+ :'status' => :'String'
110
+ }
111
+ end
112
+
113
+ # List of attributes with nullable: true
114
+ def self.openapi_nullable
115
+ Set.new([
116
+ ])
117
+ end
118
+
119
+ # Initializes the object
120
+ # @param [Hash] attributes Model attributes in the form of hash
121
+ def initialize(attributes = {})
122
+ if (!attributes.is_a?(Hash))
123
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::Transfer` initialize method"
124
+ end
125
+
126
+ # check to see if the attribute exists and convert string to symbol for hash key
127
+ attributes = attributes.each_with_object({}) { |(k, v), h|
128
+ if (!self.class.attribute_map.key?(k.to_sym))
129
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::Transfer`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
130
+ end
131
+ h[k.to_sym] = v
132
+ }
133
+
134
+ if attributes.key?(:'network_id')
135
+ self.network_id = attributes[:'network_id']
136
+ else
137
+ self.network_id = nil
138
+ end
139
+
140
+ if attributes.key?(:'wallet_id')
141
+ self.wallet_id = attributes[:'wallet_id']
142
+ else
143
+ self.wallet_id = nil
144
+ end
145
+
146
+ if attributes.key?(:'address_id')
147
+ self.address_id = attributes[:'address_id']
148
+ else
149
+ self.address_id = nil
150
+ end
151
+
152
+ if attributes.key?(:'destination')
153
+ self.destination = attributes[:'destination']
154
+ else
155
+ self.destination = nil
156
+ end
157
+
158
+ if attributes.key?(:'amount')
159
+ self.amount = attributes[:'amount']
160
+ else
161
+ self.amount = nil
162
+ end
163
+
164
+ if attributes.key?(:'asset_id')
165
+ self.asset_id = attributes[:'asset_id']
166
+ else
167
+ self.asset_id = nil
168
+ end
169
+
170
+ if attributes.key?(:'transfer_id')
171
+ self.transfer_id = attributes[:'transfer_id']
172
+ else
173
+ self.transfer_id = nil
174
+ end
175
+
176
+ if attributes.key?(:'unsigned_payload')
177
+ self.unsigned_payload = attributes[:'unsigned_payload']
178
+ else
179
+ self.unsigned_payload = nil
180
+ end
181
+
182
+ if attributes.key?(:'signed_payload')
183
+ self.signed_payload = attributes[:'signed_payload']
184
+ end
185
+
186
+ if attributes.key?(:'transaction_hash')
187
+ self.transaction_hash = attributes[:'transaction_hash']
188
+ end
189
+
190
+ if attributes.key?(:'status')
191
+ self.status = attributes[:'status']
192
+ else
193
+ self.status = nil
194
+ end
195
+ end
196
+
197
+ # Show invalid properties with the reasons. Usually used together with valid?
198
+ # @return Array for valid properties with the reasons
199
+ def list_invalid_properties
200
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
201
+ invalid_properties = Array.new
202
+ if @network_id.nil?
203
+ invalid_properties.push('invalid value for "network_id", network_id cannot be nil.')
204
+ end
205
+
206
+ if @wallet_id.nil?
207
+ invalid_properties.push('invalid value for "wallet_id", wallet_id cannot be nil.')
208
+ end
209
+
210
+ if @address_id.nil?
211
+ invalid_properties.push('invalid value for "address_id", address_id cannot be nil.')
212
+ end
213
+
214
+ if @destination.nil?
215
+ invalid_properties.push('invalid value for "destination", destination cannot be nil.')
216
+ end
217
+
218
+ if @amount.nil?
219
+ invalid_properties.push('invalid value for "amount", amount cannot be nil.')
220
+ end
221
+
222
+ if @asset_id.nil?
223
+ invalid_properties.push('invalid value for "asset_id", asset_id cannot be nil.')
224
+ end
225
+
226
+ if @transfer_id.nil?
227
+ invalid_properties.push('invalid value for "transfer_id", transfer_id cannot be nil.')
228
+ end
229
+
230
+ if @unsigned_payload.nil?
231
+ invalid_properties.push('invalid value for "unsigned_payload", unsigned_payload cannot be nil.')
232
+ end
233
+
234
+ if @status.nil?
235
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
236
+ end
237
+
238
+ invalid_properties
239
+ end
240
+
241
+ # Check to see if the all the properties in the model are valid
242
+ # @return true if the model is valid
243
+ def valid?
244
+ warn '[DEPRECATED] the `valid?` method is obsolete'
245
+ return false if @network_id.nil?
246
+ return false if @wallet_id.nil?
247
+ return false if @address_id.nil?
248
+ return false if @destination.nil?
249
+ return false if @amount.nil?
250
+ return false if @asset_id.nil?
251
+ return false if @transfer_id.nil?
252
+ return false if @unsigned_payload.nil?
253
+ return false if @status.nil?
254
+ status_validator = EnumAttributeValidator.new('String', ["pending", "broadcast", "complete", "failed"])
255
+ return false unless status_validator.valid?(@status)
256
+ true
257
+ end
258
+
259
+ # Custom attribute writer method checking allowed values (enum).
260
+ # @param [Object] status Object to be assigned
261
+ def status=(status)
262
+ validator = EnumAttributeValidator.new('String', ["pending", "broadcast", "complete", "failed"])
263
+ unless validator.valid?(status)
264
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
265
+ end
266
+ @status = status
267
+ end
268
+
269
+ # Checks equality by comparing each attribute.
270
+ # @param [Object] Object to be compared
271
+ def ==(o)
272
+ return true if self.equal?(o)
273
+ self.class == o.class &&
274
+ network_id == o.network_id &&
275
+ wallet_id == o.wallet_id &&
276
+ address_id == o.address_id &&
277
+ destination == o.destination &&
278
+ amount == o.amount &&
279
+ asset_id == o.asset_id &&
280
+ transfer_id == o.transfer_id &&
281
+ unsigned_payload == o.unsigned_payload &&
282
+ signed_payload == o.signed_payload &&
283
+ transaction_hash == o.transaction_hash &&
284
+ status == o.status
285
+ end
286
+
287
+ # @see the `==` method
288
+ # @param [Object] Object to be compared
289
+ def eql?(o)
290
+ self == o
291
+ end
292
+
293
+ # Calculates hash code according to all attributes.
294
+ # @return [Integer] Hash code
295
+ def hash
296
+ [network_id, wallet_id, address_id, destination, amount, asset_id, transfer_id, unsigned_payload, signed_payload, transaction_hash, status].hash
297
+ end
298
+
299
+ # Builds the object from hash
300
+ # @param [Hash] attributes Model attributes in the form of hash
301
+ # @return [Object] Returns the model itself
302
+ def self.build_from_hash(attributes)
303
+ return nil unless attributes.is_a?(Hash)
304
+ attributes = attributes.transform_keys(&:to_sym)
305
+ transformed_hash = {}
306
+ openapi_types.each_pair do |key, type|
307
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
308
+ transformed_hash["#{key}"] = nil
309
+ elsif type =~ /\AArray<(.*)>/i
310
+ # check to ensure the input is an array given that the attribute
311
+ # is documented as an array but the input is not
312
+ if attributes[attribute_map[key]].is_a?(Array)
313
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
314
+ end
315
+ elsif !attributes[attribute_map[key]].nil?
316
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
317
+ end
318
+ end
319
+ new(transformed_hash)
320
+ end
321
+
322
+ # Deserializes the data based on type
323
+ # @param string type Data type
324
+ # @param string value Value to be deserialized
325
+ # @return [Object] Deserialized data
326
+ def self._deserialize(type, value)
327
+ case type.to_sym
328
+ when :Time
329
+ Time.parse(value)
330
+ when :Date
331
+ Date.parse(value)
332
+ when :String
333
+ value.to_s
334
+ when :Integer
335
+ value.to_i
336
+ when :Float
337
+ value.to_f
338
+ when :Boolean
339
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
340
+ true
341
+ else
342
+ false
343
+ end
344
+ when :Object
345
+ # generic object (usually a Hash), return directly
346
+ value
347
+ when /\AArray<(?<inner_type>.+)>\z/
348
+ inner_type = Regexp.last_match[:inner_type]
349
+ value.map { |v| _deserialize(inner_type, v) }
350
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
351
+ k_type = Regexp.last_match[:k_type]
352
+ v_type = Regexp.last_match[:v_type]
353
+ {}.tap do |hash|
354
+ value.each do |k, v|
355
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
356
+ end
357
+ end
358
+ else # model
359
+ # models (e.g. Pet) or oneOf
360
+ klass = Coinbase::Client.const_get(type)
361
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
362
+ end
363
+ end
364
+
365
+ # Returns the string representation of the object
366
+ # @return [String] String presentation of the object
367
+ def to_s
368
+ to_hash.to_s
369
+ end
370
+
371
+ # to_body is an alias to to_hash (backward compatibility)
372
+ # @return [Hash] Returns the object in the form of hash
373
+ def to_body
374
+ to_hash
375
+ end
376
+
377
+ # Returns the object in the form of hash
378
+ # @return [Hash] Returns the object in the form of hash
379
+ def to_hash
380
+ hash = {}
381
+ self.class.attribute_map.each_pair do |attr, param|
382
+ value = self.send(attr)
383
+ if value.nil?
384
+ is_nullable = self.class.openapi_nullable.include?(attr)
385
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
386
+ end
387
+
388
+ hash[param] = _to_hash(value)
389
+ end
390
+ hash
391
+ end
392
+
393
+ # Outputs non-array value in the form of hash
394
+ # For object, use to_hash. Otherwise, just return the value
395
+ # @param [Object] value Any valid value
396
+ # @return [Hash] Returns the value in the form of hash
397
+ def _to_hash(value)
398
+ if value.is_a?(Array)
399
+ value.compact.map { |v| _to_hash(v) }
400
+ elsif value.is_a?(Hash)
401
+ {}.tap do |hash|
402
+ value.each { |k, v| hash[k] = _to_hash(v) }
403
+ end
404
+ elsif value.respond_to? :to_hash
405
+ value.to_hash
406
+ else
407
+ value
408
+ end
409
+ end
410
+
411
+ end
412
+
413
+ end
@@ -0,0 +1,275 @@
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.5.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Coinbase::Client
17
+ #
18
+ class TransferList
19
+ attr_accessor :data
20
+
21
+ # True if this list has another page of items after this one that can be fetched.
22
+ attr_accessor :has_more
23
+
24
+ # The page token to be used to fetch the next page.
25
+ attr_accessor :next_page
26
+
27
+ # The total number of transfers for the address in the wallet.
28
+ attr_accessor :total_count
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :'data' => :'data',
34
+ :'has_more' => :'has_more',
35
+ :'next_page' => :'next_page',
36
+ :'total_count' => :'total_count'
37
+ }
38
+ end
39
+
40
+ # Returns all the JSON keys this model knows about
41
+ def self.acceptable_attributes
42
+ attribute_map.values
43
+ end
44
+
45
+ # Attribute type mapping.
46
+ def self.openapi_types
47
+ {
48
+ :'data' => :'Array<Transfer>',
49
+ :'has_more' => :'Boolean',
50
+ :'next_page' => :'String',
51
+ :'total_count' => :'Integer'
52
+ }
53
+ end
54
+
55
+ # List of attributes with nullable: true
56
+ def self.openapi_nullable
57
+ Set.new([
58
+ ])
59
+ end
60
+
61
+ # Initializes the object
62
+ # @param [Hash] attributes Model attributes in the form of hash
63
+ def initialize(attributes = {})
64
+ if (!attributes.is_a?(Hash))
65
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::TransferList` initialize method"
66
+ end
67
+
68
+ # check to see if the attribute exists and convert string to symbol for hash key
69
+ attributes = attributes.each_with_object({}) { |(k, v), h|
70
+ if (!self.class.attribute_map.key?(k.to_sym))
71
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::TransferList`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
72
+ end
73
+ h[k.to_sym] = v
74
+ }
75
+
76
+ if attributes.key?(:'data')
77
+ if (value = attributes[:'data']).is_a?(Array)
78
+ self.data = value
79
+ end
80
+ else
81
+ self.data = nil
82
+ end
83
+
84
+ if attributes.key?(:'has_more')
85
+ self.has_more = attributes[:'has_more']
86
+ else
87
+ self.has_more = nil
88
+ end
89
+
90
+ if attributes.key?(:'next_page')
91
+ self.next_page = attributes[:'next_page']
92
+ else
93
+ self.next_page = nil
94
+ end
95
+
96
+ if attributes.key?(:'total_count')
97
+ self.total_count = attributes[:'total_count']
98
+ else
99
+ self.total_count = nil
100
+ end
101
+ end
102
+
103
+ # Show invalid properties with the reasons. Usually used together with valid?
104
+ # @return Array for valid properties with the reasons
105
+ def list_invalid_properties
106
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
107
+ invalid_properties = Array.new
108
+ if @data.nil?
109
+ invalid_properties.push('invalid value for "data", data cannot be nil.')
110
+ end
111
+
112
+ if @has_more.nil?
113
+ invalid_properties.push('invalid value for "has_more", has_more cannot be nil.')
114
+ end
115
+
116
+ if @next_page.nil?
117
+ invalid_properties.push('invalid value for "next_page", next_page cannot be nil.')
118
+ end
119
+
120
+ if @total_count.nil?
121
+ invalid_properties.push('invalid value for "total_count", total_count cannot be nil.')
122
+ end
123
+
124
+ invalid_properties
125
+ end
126
+
127
+ # Check to see if the all the properties in the model are valid
128
+ # @return true if the model is valid
129
+ def valid?
130
+ warn '[DEPRECATED] the `valid?` method is obsolete'
131
+ return false if @data.nil?
132
+ return false if @has_more.nil?
133
+ return false if @next_page.nil?
134
+ return false if @total_count.nil?
135
+ true
136
+ end
137
+
138
+ # Checks equality by comparing each attribute.
139
+ # @param [Object] Object to be compared
140
+ def ==(o)
141
+ return true if self.equal?(o)
142
+ self.class == o.class &&
143
+ data == o.data &&
144
+ has_more == o.has_more &&
145
+ next_page == o.next_page &&
146
+ total_count == o.total_count
147
+ end
148
+
149
+ # @see the `==` method
150
+ # @param [Object] Object to be compared
151
+ def eql?(o)
152
+ self == o
153
+ end
154
+
155
+ # Calculates hash code according to all attributes.
156
+ # @return [Integer] Hash code
157
+ def hash
158
+ [data, has_more, next_page, total_count].hash
159
+ end
160
+
161
+ # Builds the object from hash
162
+ # @param [Hash] attributes Model attributes in the form of hash
163
+ # @return [Object] Returns the model itself
164
+ def self.build_from_hash(attributes)
165
+ return nil unless attributes.is_a?(Hash)
166
+ attributes = attributes.transform_keys(&:to_sym)
167
+ transformed_hash = {}
168
+ openapi_types.each_pair do |key, type|
169
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
170
+ transformed_hash["#{key}"] = nil
171
+ elsif type =~ /\AArray<(.*)>/i
172
+ # check to ensure the input is an array given that the attribute
173
+ # is documented as an array but the input is not
174
+ if attributes[attribute_map[key]].is_a?(Array)
175
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
176
+ end
177
+ elsif !attributes[attribute_map[key]].nil?
178
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
179
+ end
180
+ end
181
+ new(transformed_hash)
182
+ end
183
+
184
+ # Deserializes the data based on type
185
+ # @param string type Data type
186
+ # @param string value Value to be deserialized
187
+ # @return [Object] Deserialized data
188
+ def self._deserialize(type, value)
189
+ case type.to_sym
190
+ when :Time
191
+ Time.parse(value)
192
+ when :Date
193
+ Date.parse(value)
194
+ when :String
195
+ value.to_s
196
+ when :Integer
197
+ value.to_i
198
+ when :Float
199
+ value.to_f
200
+ when :Boolean
201
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
202
+ true
203
+ else
204
+ false
205
+ end
206
+ when :Object
207
+ # generic object (usually a Hash), return directly
208
+ value
209
+ when /\AArray<(?<inner_type>.+)>\z/
210
+ inner_type = Regexp.last_match[:inner_type]
211
+ value.map { |v| _deserialize(inner_type, v) }
212
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
213
+ k_type = Regexp.last_match[:k_type]
214
+ v_type = Regexp.last_match[:v_type]
215
+ {}.tap do |hash|
216
+ value.each do |k, v|
217
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
218
+ end
219
+ end
220
+ else # model
221
+ # models (e.g. Pet) or oneOf
222
+ klass = Coinbase::Client.const_get(type)
223
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
224
+ end
225
+ end
226
+
227
+ # Returns the string representation of the object
228
+ # @return [String] String presentation of the object
229
+ def to_s
230
+ to_hash.to_s
231
+ end
232
+
233
+ # to_body is an alias to to_hash (backward compatibility)
234
+ # @return [Hash] Returns the object in the form of hash
235
+ def to_body
236
+ to_hash
237
+ end
238
+
239
+ # Returns the object in the form of hash
240
+ # @return [Hash] Returns the object in the form of hash
241
+ def to_hash
242
+ hash = {}
243
+ self.class.attribute_map.each_pair do |attr, param|
244
+ value = self.send(attr)
245
+ if value.nil?
246
+ is_nullable = self.class.openapi_nullable.include?(attr)
247
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
248
+ end
249
+
250
+ hash[param] = _to_hash(value)
251
+ end
252
+ hash
253
+ end
254
+
255
+ # Outputs non-array value in the form of hash
256
+ # For object, use to_hash. Otherwise, just return the value
257
+ # @param [Object] value Any valid value
258
+ # @return [Hash] Returns the value in the form of hash
259
+ def _to_hash(value)
260
+ if value.is_a?(Array)
261
+ value.compact.map { |v| _to_hash(v) }
262
+ elsif value.is_a?(Hash)
263
+ {}.tap do |hash|
264
+ value.each { |k, v| hash[k] = _to_hash(v) }
265
+ end
266
+ elsif value.respond_to? :to_hash
267
+ value.to_hash
268
+ else
269
+ value
270
+ end
271
+ end
272
+
273
+ end
274
+
275
+ end