coinbase-sdk 0.7.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 (31) hide show
  1. checksums.yaml +4 -4
  2. data/lib/coinbase/address.rb +8 -3
  3. data/lib/coinbase/client/api/external_addresses_api.rb +78 -0
  4. data/lib/coinbase/client/api/fund_api.rb +336 -0
  5. data/lib/coinbase/client/api/onchain_identity_api.rb +108 -0
  6. data/lib/coinbase/client/api/smart_contracts_api.rb +80 -0
  7. data/lib/coinbase/client/api/webhooks_api.rb +5 -5
  8. data/lib/coinbase/client/models/create_fund_operation_request.rb +249 -0
  9. data/lib/coinbase/client/models/create_fund_quote_request.rb +239 -0
  10. data/lib/coinbase/client/models/create_wallet_webhook_request.rb +1 -1
  11. data/lib/coinbase/client/models/crypto_amount.rb +239 -0
  12. data/lib/coinbase/client/models/ethereum_token_transfer.rb +327 -0
  13. data/lib/coinbase/client/models/ethereum_transaction.rb +12 -1
  14. data/lib/coinbase/client/models/faucet_transaction.rb +20 -4
  15. data/lib/coinbase/client/models/fiat_amount.rb +240 -0
  16. data/lib/coinbase/client/models/fund_operation.rb +373 -0
  17. data/lib/coinbase/client/models/fund_operation_fees.rb +238 -0
  18. data/lib/coinbase/client/models/fund_operation_list.rb +275 -0
  19. data/lib/coinbase/client/models/fund_quote.rb +339 -0
  20. data/lib/coinbase/client/models/onchain_name.rb +357 -0
  21. data/lib/coinbase/client/models/onchain_name_list.rb +262 -0
  22. data/lib/coinbase/client/models/read_contract_request.rb +249 -0
  23. data/lib/coinbase/client/models/solidity_value.rb +287 -0
  24. data/lib/coinbase/client/models/token_transfer_type.rb +43 -0
  25. data/lib/coinbase/client/models/update_webhook_request.rb +0 -7
  26. data/lib/coinbase/client.rb +17 -0
  27. data/lib/coinbase/faucet_transaction.rb +64 -4
  28. data/lib/coinbase/smart_contract.rb +95 -0
  29. data/lib/coinbase/transaction.rb +8 -2
  30. data/lib/coinbase/version.rb +1 -1
  31. metadata +18 -2
@@ -0,0 +1,240 @@
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 amount in fiat currency
18
+ class FiatAmount
19
+ # The amount of the fiat in whole units.
20
+ attr_accessor :amount
21
+
22
+ # The currency of the fiat
23
+ attr_accessor :currency
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'amount' => :'amount',
29
+ :'currency' => :'currency'
30
+ }
31
+ end
32
+
33
+ # Returns all the JSON keys this model knows about
34
+ def self.acceptable_attributes
35
+ attribute_map.values
36
+ end
37
+
38
+ # Attribute type mapping.
39
+ def self.openapi_types
40
+ {
41
+ :'amount' => :'String',
42
+ :'currency' => :'String'
43
+ }
44
+ end
45
+
46
+ # List of attributes with nullable: true
47
+ def self.openapi_nullable
48
+ Set.new([
49
+ ])
50
+ end
51
+
52
+ # Initializes the object
53
+ # @param [Hash] attributes Model attributes in the form of hash
54
+ def initialize(attributes = {})
55
+ if (!attributes.is_a?(Hash))
56
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::FiatAmount` initialize method"
57
+ end
58
+
59
+ # check to see if the attribute exists and convert string to symbol for hash key
60
+ attributes = attributes.each_with_object({}) { |(k, v), h|
61
+ if (!self.class.attribute_map.key?(k.to_sym))
62
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::FiatAmount`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
63
+ end
64
+ h[k.to_sym] = v
65
+ }
66
+
67
+ if attributes.key?(:'amount')
68
+ self.amount = attributes[:'amount']
69
+ else
70
+ self.amount = nil
71
+ end
72
+
73
+ if attributes.key?(:'currency')
74
+ self.currency = attributes[:'currency']
75
+ else
76
+ self.currency = nil
77
+ end
78
+ end
79
+
80
+ # Show invalid properties with the reasons. Usually used together with valid?
81
+ # @return Array for valid properties with the reasons
82
+ def list_invalid_properties
83
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
84
+ invalid_properties = Array.new
85
+ if @amount.nil?
86
+ invalid_properties.push('invalid value for "amount", amount cannot be nil.')
87
+ end
88
+
89
+ if @currency.nil?
90
+ invalid_properties.push('invalid value for "currency", currency cannot be nil.')
91
+ end
92
+
93
+ invalid_properties
94
+ end
95
+
96
+ # Check to see if the all the properties in the model are valid
97
+ # @return true if the model is valid
98
+ def valid?
99
+ warn '[DEPRECATED] the `valid?` method is obsolete'
100
+ return false if @amount.nil?
101
+ return false if @currency.nil?
102
+ true
103
+ end
104
+
105
+ # Checks equality by comparing each attribute.
106
+ # @param [Object] Object to be compared
107
+ def ==(o)
108
+ return true if self.equal?(o)
109
+ self.class == o.class &&
110
+ amount == o.amount &&
111
+ currency == o.currency
112
+ end
113
+
114
+ # @see the `==` method
115
+ # @param [Object] Object to be compared
116
+ def eql?(o)
117
+ self == o
118
+ end
119
+
120
+ # Calculates hash code according to all attributes.
121
+ # @return [Integer] Hash code
122
+ def hash
123
+ [amount, currency].hash
124
+ end
125
+
126
+ # Builds the object from hash
127
+ # @param [Hash] attributes Model attributes in the form of hash
128
+ # @return [Object] Returns the model itself
129
+ def self.build_from_hash(attributes)
130
+ return nil unless attributes.is_a?(Hash)
131
+ attributes = attributes.transform_keys(&:to_sym)
132
+ transformed_hash = {}
133
+ openapi_types.each_pair do |key, type|
134
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
135
+ transformed_hash["#{key}"] = nil
136
+ elsif type =~ /\AArray<(.*)>/i
137
+ # check to ensure the input is an array given that the attribute
138
+ # is documented as an array but the input is not
139
+ if attributes[attribute_map[key]].is_a?(Array)
140
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
141
+ end
142
+ elsif !attributes[attribute_map[key]].nil?
143
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
144
+ end
145
+ end
146
+ new(transformed_hash)
147
+ end
148
+
149
+ # Deserializes the data based on type
150
+ # @param string type Data type
151
+ # @param string value Value to be deserialized
152
+ # @return [Object] Deserialized data
153
+ def self._deserialize(type, value)
154
+ case type.to_sym
155
+ when :Time
156
+ Time.parse(value)
157
+ when :Date
158
+ Date.parse(value)
159
+ when :String
160
+ value.to_s
161
+ when :Integer
162
+ value.to_i
163
+ when :Float
164
+ value.to_f
165
+ when :Boolean
166
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
167
+ true
168
+ else
169
+ false
170
+ end
171
+ when :Object
172
+ # generic object (usually a Hash), return directly
173
+ value
174
+ when /\AArray<(?<inner_type>.+)>\z/
175
+ inner_type = Regexp.last_match[:inner_type]
176
+ value.map { |v| _deserialize(inner_type, v) }
177
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
178
+ k_type = Regexp.last_match[:k_type]
179
+ v_type = Regexp.last_match[:v_type]
180
+ {}.tap do |hash|
181
+ value.each do |k, v|
182
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
183
+ end
184
+ end
185
+ else # model
186
+ # models (e.g. Pet) or oneOf
187
+ klass = Coinbase::Client.const_get(type)
188
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
189
+ end
190
+ end
191
+
192
+ # Returns the string representation of the object
193
+ # @return [String] String presentation of the object
194
+ def to_s
195
+ to_hash.to_s
196
+ end
197
+
198
+ # to_body is an alias to to_hash (backward compatibility)
199
+ # @return [Hash] Returns the object in the form of hash
200
+ def to_body
201
+ to_hash
202
+ end
203
+
204
+ # Returns the object in the form of hash
205
+ # @return [Hash] Returns the object in the form of hash
206
+ def to_hash
207
+ hash = {}
208
+ self.class.attribute_map.each_pair do |attr, param|
209
+ value = self.send(attr)
210
+ if value.nil?
211
+ is_nullable = self.class.openapi_nullable.include?(attr)
212
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
213
+ end
214
+
215
+ hash[param] = _to_hash(value)
216
+ end
217
+ hash
218
+ end
219
+
220
+ # Outputs non-array value in the form of hash
221
+ # For object, use to_hash. Otherwise, just return the value
222
+ # @param [Object] value Any valid value
223
+ # @return [Hash] Returns the value in the form of hash
224
+ def _to_hash(value)
225
+ if value.is_a?(Array)
226
+ value.compact.map { |v| _to_hash(v) }
227
+ elsif value.is_a?(Hash)
228
+ {}.tap do |hash|
229
+ value.each { |k, v| hash[k] = _to_hash(v) }
230
+ end
231
+ elsif value.respond_to? :to_hash
232
+ value.to_hash
233
+ else
234
+ value
235
+ end
236
+ end
237
+
238
+ end
239
+
240
+ end
@@ -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