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,257 @@
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 USD value of the reward
18
+ class StakingRewardUSDValue
19
+ # The value of the reward in USD
20
+ attr_accessor :amount
21
+
22
+ # The conversion price from native currency to USD
23
+ attr_accessor :conversion_price
24
+
25
+ # The time of the conversion in UTC.
26
+ attr_accessor :conversion_time
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'amount' => :'amount',
32
+ :'conversion_price' => :'conversion_price',
33
+ :'conversion_time' => :'conversion_time'
34
+ }
35
+ end
36
+
37
+ # Returns all the JSON keys this model knows about
38
+ def self.acceptable_attributes
39
+ attribute_map.values
40
+ end
41
+
42
+ # Attribute type mapping.
43
+ def self.openapi_types
44
+ {
45
+ :'amount' => :'String',
46
+ :'conversion_price' => :'String',
47
+ :'conversion_time' => :'Time'
48
+ }
49
+ end
50
+
51
+ # List of attributes with nullable: true
52
+ def self.openapi_nullable
53
+ Set.new([
54
+ ])
55
+ end
56
+
57
+ # Initializes the object
58
+ # @param [Hash] attributes Model attributes in the form of hash
59
+ def initialize(attributes = {})
60
+ if (!attributes.is_a?(Hash))
61
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::StakingRewardUSDValue` initialize method"
62
+ end
63
+
64
+ # check to see if the attribute exists and convert string to symbol for hash key
65
+ attributes = attributes.each_with_object({}) { |(k, v), h|
66
+ if (!self.class.attribute_map.key?(k.to_sym))
67
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::StakingRewardUSDValue`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
68
+ end
69
+ h[k.to_sym] = v
70
+ }
71
+
72
+ if attributes.key?(:'amount')
73
+ self.amount = attributes[:'amount']
74
+ else
75
+ self.amount = nil
76
+ end
77
+
78
+ if attributes.key?(:'conversion_price')
79
+ self.conversion_price = attributes[:'conversion_price']
80
+ else
81
+ self.conversion_price = nil
82
+ end
83
+
84
+ if attributes.key?(:'conversion_time')
85
+ self.conversion_time = attributes[:'conversion_time']
86
+ else
87
+ self.conversion_time = nil
88
+ end
89
+ end
90
+
91
+ # Show invalid properties with the reasons. Usually used together with valid?
92
+ # @return Array for valid properties with the reasons
93
+ def list_invalid_properties
94
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
95
+ invalid_properties = Array.new
96
+ if @amount.nil?
97
+ invalid_properties.push('invalid value for "amount", amount cannot be nil.')
98
+ end
99
+
100
+ if @conversion_price.nil?
101
+ invalid_properties.push('invalid value for "conversion_price", conversion_price cannot be nil.')
102
+ end
103
+
104
+ if @conversion_time.nil?
105
+ invalid_properties.push('invalid value for "conversion_time", conversion_time cannot be nil.')
106
+ end
107
+
108
+ invalid_properties
109
+ end
110
+
111
+ # Check to see if the all the properties in the model are valid
112
+ # @return true if the model is valid
113
+ def valid?
114
+ warn '[DEPRECATED] the `valid?` method is obsolete'
115
+ return false if @amount.nil?
116
+ return false if @conversion_price.nil?
117
+ return false if @conversion_time.nil?
118
+ true
119
+ end
120
+
121
+ # Checks equality by comparing each attribute.
122
+ # @param [Object] Object to be compared
123
+ def ==(o)
124
+ return true if self.equal?(o)
125
+ self.class == o.class &&
126
+ amount == o.amount &&
127
+ conversion_price == o.conversion_price &&
128
+ conversion_time == o.conversion_time
129
+ end
130
+
131
+ # @see the `==` method
132
+ # @param [Object] Object to be compared
133
+ def eql?(o)
134
+ self == o
135
+ end
136
+
137
+ # Calculates hash code according to all attributes.
138
+ # @return [Integer] Hash code
139
+ def hash
140
+ [amount, conversion_price, conversion_time].hash
141
+ end
142
+
143
+ # Builds the object from hash
144
+ # @param [Hash] attributes Model attributes in the form of hash
145
+ # @return [Object] Returns the model itself
146
+ def self.build_from_hash(attributes)
147
+ return nil unless attributes.is_a?(Hash)
148
+ attributes = attributes.transform_keys(&:to_sym)
149
+ transformed_hash = {}
150
+ openapi_types.each_pair do |key, type|
151
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
152
+ transformed_hash["#{key}"] = nil
153
+ elsif type =~ /\AArray<(.*)>/i
154
+ # check to ensure the input is an array given that the attribute
155
+ # is documented as an array but the input is not
156
+ if attributes[attribute_map[key]].is_a?(Array)
157
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
158
+ end
159
+ elsif !attributes[attribute_map[key]].nil?
160
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
161
+ end
162
+ end
163
+ new(transformed_hash)
164
+ end
165
+
166
+ # Deserializes the data based on type
167
+ # @param string type Data type
168
+ # @param string value Value to be deserialized
169
+ # @return [Object] Deserialized data
170
+ def self._deserialize(type, value)
171
+ case type.to_sym
172
+ when :Time
173
+ Time.parse(value)
174
+ when :Date
175
+ Date.parse(value)
176
+ when :String
177
+ value.to_s
178
+ when :Integer
179
+ value.to_i
180
+ when :Float
181
+ value.to_f
182
+ when :Boolean
183
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
184
+ true
185
+ else
186
+ false
187
+ end
188
+ when :Object
189
+ # generic object (usually a Hash), return directly
190
+ value
191
+ when /\AArray<(?<inner_type>.+)>\z/
192
+ inner_type = Regexp.last_match[:inner_type]
193
+ value.map { |v| _deserialize(inner_type, v) }
194
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
195
+ k_type = Regexp.last_match[:k_type]
196
+ v_type = Regexp.last_match[:v_type]
197
+ {}.tap do |hash|
198
+ value.each do |k, v|
199
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
200
+ end
201
+ end
202
+ else # model
203
+ # models (e.g. Pet) or oneOf
204
+ klass = Coinbase::Client.const_get(type)
205
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
206
+ end
207
+ end
208
+
209
+ # Returns the string representation of the object
210
+ # @return [String] String presentation of the object
211
+ def to_s
212
+ to_hash.to_s
213
+ end
214
+
215
+ # to_body is an alias to to_hash (backward compatibility)
216
+ # @return [Hash] Returns the object in the form of hash
217
+ def to_body
218
+ to_hash
219
+ end
220
+
221
+ # Returns the object in the form of hash
222
+ # @return [Hash] Returns the object in the form of hash
223
+ def to_hash
224
+ hash = {}
225
+ self.class.attribute_map.each_pair do |attr, param|
226
+ value = self.send(attr)
227
+ if value.nil?
228
+ is_nullable = self.class.openapi_nullable.include?(attr)
229
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
230
+ end
231
+
232
+ hash[param] = _to_hash(value)
233
+ end
234
+ hash
235
+ end
236
+
237
+ # Outputs non-array value in the form of hash
238
+ # For object, use to_hash. Otherwise, just return the value
239
+ # @param [Object] value Any valid value
240
+ # @return [Hash] Returns the value in the form of hash
241
+ def _to_hash(value)
242
+ if value.is_a?(Array)
243
+ value.compact.map { |v| _to_hash(v) }
244
+ elsif value.is_a?(Hash)
245
+ {}.tap do |hash|
246
+ value.each { |k, v| hash[k] = _to_hash(v) }
247
+ end
248
+ elsif value.respond_to? :to_hash
249
+ value.to_hash
250
+ else
251
+ value
252
+ end
253
+ end
254
+
255
+ end
256
+
257
+ end
@@ -180,7 +180,7 @@ module Coinbase::Client
180
180
  return false if @from_address_id.nil?
181
181
  return false if @unsigned_payload.nil?
182
182
  return false if @status.nil?
183
- status_validator = EnumAttributeValidator.new('String', ["pending", "signed", "broadcast", "complete", "failed"])
183
+ status_validator = EnumAttributeValidator.new('String', ["pending", "signed", "broadcast", "complete", "failed", "unknown_default_open_api"])
184
184
  return false unless status_validator.valid?(@status)
185
185
  true
186
186
  end
@@ -188,7 +188,7 @@ module Coinbase::Client
188
188
  # Custom attribute writer method checking allowed values (enum).
189
189
  # @param [Object] status Object to be assigned
190
190
  def status=(status)
191
- validator = EnumAttributeValidator.new('String', ["pending", "signed", "broadcast", "complete", "failed"])
191
+ validator = EnumAttributeValidator.new('String', ["pending", "signed", "broadcast", "complete", "failed", "unknown_default_open_api"])
192
192
  unless validator.valid?(status)
193
193
  fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
194
194
  end
@@ -16,9 +16,10 @@ require 'time'
16
16
  module Coinbase::Client
17
17
  class TransactionType
18
18
  TRANSFER = "transfer".freeze
19
+ UNKNOWN_DEFAULT_OPEN_API = "unknown_default_open_api".freeze
19
20
 
20
21
  def self.all_vars
21
- @all_vars ||= [TRANSFER].freeze
22
+ @all_vars ||= [TRANSFER, UNKNOWN_DEFAULT_OPEN_API].freeze
22
23
  end
23
24
 
24
25
  # Builds the enum from string
@@ -41,6 +41,8 @@ module Coinbase::Client
41
41
 
42
42
  attr_accessor :transaction
43
43
 
44
+ attr_accessor :sponsored_send
45
+
44
46
  # The unsigned payload of the transfer. This is the payload that needs to be signed by the sender.
45
47
  attr_accessor :unsigned_payload
46
48
 
@@ -53,6 +55,9 @@ module Coinbase::Client
53
55
  # The status of the transfer
54
56
  attr_accessor :status
55
57
 
58
+ # Whether the transfer uses sponsored gas
59
+ attr_accessor :gasless
60
+
56
61
  class EnumAttributeValidator
57
62
  attr_reader :datatype
58
63
  attr_reader :allowable_values
@@ -87,10 +92,12 @@ module Coinbase::Client
87
92
  :'asset' => :'asset',
88
93
  :'transfer_id' => :'transfer_id',
89
94
  :'transaction' => :'transaction',
95
+ :'sponsored_send' => :'sponsored_send',
90
96
  :'unsigned_payload' => :'unsigned_payload',
91
97
  :'signed_payload' => :'signed_payload',
92
98
  :'transaction_hash' => :'transaction_hash',
93
- :'status' => :'status'
99
+ :'status' => :'status',
100
+ :'gasless' => :'gasless'
94
101
  }
95
102
  end
96
103
 
@@ -111,10 +118,12 @@ module Coinbase::Client
111
118
  :'asset' => :'Asset',
112
119
  :'transfer_id' => :'String',
113
120
  :'transaction' => :'Transaction',
121
+ :'sponsored_send' => :'SponsoredSend',
114
122
  :'unsigned_payload' => :'String',
115
123
  :'signed_payload' => :'String',
116
124
  :'transaction_hash' => :'String',
117
- :'status' => :'String'
125
+ :'status' => :'String',
126
+ :'gasless' => :'Boolean'
118
127
  }
119
128
  end
120
129
 
@@ -189,14 +198,14 @@ module Coinbase::Client
189
198
 
190
199
  if attributes.key?(:'transaction')
191
200
  self.transaction = attributes[:'transaction']
192
- else
193
- self.transaction = nil
201
+ end
202
+
203
+ if attributes.key?(:'sponsored_send')
204
+ self.sponsored_send = attributes[:'sponsored_send']
194
205
  end
195
206
 
196
207
  if attributes.key?(:'unsigned_payload')
197
208
  self.unsigned_payload = attributes[:'unsigned_payload']
198
- else
199
- self.unsigned_payload = nil
200
209
  end
201
210
 
202
211
  if attributes.key?(:'signed_payload')
@@ -209,8 +218,12 @@ module Coinbase::Client
209
218
 
210
219
  if attributes.key?(:'status')
211
220
  self.status = attributes[:'status']
221
+ end
222
+
223
+ if attributes.key?(:'gasless')
224
+ self.gasless = attributes[:'gasless']
212
225
  else
213
- self.status = nil
226
+ self.gasless = nil
214
227
  end
215
228
  end
216
229
 
@@ -251,16 +264,8 @@ module Coinbase::Client
251
264
  invalid_properties.push('invalid value for "transfer_id", transfer_id cannot be nil.')
252
265
  end
253
266
 
254
- if @transaction.nil?
255
- invalid_properties.push('invalid value for "transaction", transaction cannot be nil.')
256
- end
257
-
258
- if @unsigned_payload.nil?
259
- invalid_properties.push('invalid value for "unsigned_payload", unsigned_payload cannot be nil.')
260
- end
261
-
262
- if @status.nil?
263
- invalid_properties.push('invalid value for "status", status cannot be nil.')
267
+ if @gasless.nil?
268
+ invalid_properties.push('invalid value for "gasless", gasless cannot be nil.')
264
269
  end
265
270
 
266
271
  invalid_properties
@@ -278,18 +283,16 @@ module Coinbase::Client
278
283
  return false if @asset_id.nil?
279
284
  return false if @asset.nil?
280
285
  return false if @transfer_id.nil?
281
- return false if @transaction.nil?
282
- return false if @unsigned_payload.nil?
283
- return false if @status.nil?
284
- status_validator = EnumAttributeValidator.new('String', ["pending", "broadcast", "complete", "failed"])
286
+ status_validator = EnumAttributeValidator.new('String', ["pending", "broadcast", "complete", "failed", "unknown_default_open_api"])
285
287
  return false unless status_validator.valid?(@status)
288
+ return false if @gasless.nil?
286
289
  true
287
290
  end
288
291
 
289
292
  # Custom attribute writer method checking allowed values (enum).
290
293
  # @param [Object] status Object to be assigned
291
294
  def status=(status)
292
- validator = EnumAttributeValidator.new('String', ["pending", "broadcast", "complete", "failed"])
295
+ validator = EnumAttributeValidator.new('String', ["pending", "broadcast", "complete", "failed", "unknown_default_open_api"])
293
296
  unless validator.valid?(status)
294
297
  fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
295
298
  end
@@ -310,10 +313,12 @@ module Coinbase::Client
310
313
  asset == o.asset &&
311
314
  transfer_id == o.transfer_id &&
312
315
  transaction == o.transaction &&
316
+ sponsored_send == o.sponsored_send &&
313
317
  unsigned_payload == o.unsigned_payload &&
314
318
  signed_payload == o.signed_payload &&
315
319
  transaction_hash == o.transaction_hash &&
316
- status == o.status
320
+ status == o.status &&
321
+ gasless == o.gasless
317
322
  end
318
323
 
319
324
  # @see the `==` method
@@ -325,7 +330,7 @@ module Coinbase::Client
325
330
  # Calculates hash code according to all attributes.
326
331
  # @return [Integer] Hash code
327
332
  def hash
328
- [network_id, wallet_id, address_id, destination, amount, asset_id, asset, transfer_id, transaction, unsigned_payload, signed_payload, transaction_hash, status].hash
333
+ [network_id, wallet_id, address_id, destination, amount, asset_id, asset, transfer_id, transaction, sponsored_send, unsigned_payload, signed_payload, transaction_hash, status, gasless].hash
329
334
  end
330
335
 
331
336
  # Builds the object from hash