coinbase-sdk 0.0.13 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
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,307 @@
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
+ class FeatureSet
18
+ # Whether the network supports a faucet
19
+ attr_accessor :faucet
20
+
21
+ # Whether the network supports Server-Signers
22
+ attr_accessor :server_signer
23
+
24
+ # Whether the network supports transfers
25
+ attr_accessor :transfer
26
+
27
+ # Whether the network supports trading
28
+ attr_accessor :trade
29
+
30
+ # Whether the network supports staking
31
+ attr_accessor :stake
32
+
33
+ # Whether the network supports gasless sends
34
+ attr_accessor :gasless_send
35
+
36
+ # Attribute mapping from ruby-style variable name to JSON key.
37
+ def self.attribute_map
38
+ {
39
+ :'faucet' => :'faucet',
40
+ :'server_signer' => :'server_signer',
41
+ :'transfer' => :'transfer',
42
+ :'trade' => :'trade',
43
+ :'stake' => :'stake',
44
+ :'gasless_send' => :'gasless_send'
45
+ }
46
+ end
47
+
48
+ # Returns all the JSON keys this model knows about
49
+ def self.acceptable_attributes
50
+ attribute_map.values
51
+ end
52
+
53
+ # Attribute type mapping.
54
+ def self.openapi_types
55
+ {
56
+ :'faucet' => :'Boolean',
57
+ :'server_signer' => :'Boolean',
58
+ :'transfer' => :'Boolean',
59
+ :'trade' => :'Boolean',
60
+ :'stake' => :'Boolean',
61
+ :'gasless_send' => :'Boolean'
62
+ }
63
+ end
64
+
65
+ # List of attributes with nullable: true
66
+ def self.openapi_nullable
67
+ Set.new([
68
+ ])
69
+ end
70
+
71
+ # Initializes the object
72
+ # @param [Hash] attributes Model attributes in the form of hash
73
+ def initialize(attributes = {})
74
+ if (!attributes.is_a?(Hash))
75
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::FeatureSet` initialize method"
76
+ end
77
+
78
+ # check to see if the attribute exists and convert string to symbol for hash key
79
+ attributes = attributes.each_with_object({}) { |(k, v), h|
80
+ if (!self.class.attribute_map.key?(k.to_sym))
81
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::FeatureSet`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
82
+ end
83
+ h[k.to_sym] = v
84
+ }
85
+
86
+ if attributes.key?(:'faucet')
87
+ self.faucet = attributes[:'faucet']
88
+ else
89
+ self.faucet = nil
90
+ end
91
+
92
+ if attributes.key?(:'server_signer')
93
+ self.server_signer = attributes[:'server_signer']
94
+ else
95
+ self.server_signer = nil
96
+ end
97
+
98
+ if attributes.key?(:'transfer')
99
+ self.transfer = attributes[:'transfer']
100
+ else
101
+ self.transfer = nil
102
+ end
103
+
104
+ if attributes.key?(:'trade')
105
+ self.trade = attributes[:'trade']
106
+ else
107
+ self.trade = nil
108
+ end
109
+
110
+ if attributes.key?(:'stake')
111
+ self.stake = attributes[:'stake']
112
+ else
113
+ self.stake = nil
114
+ end
115
+
116
+ if attributes.key?(:'gasless_send')
117
+ self.gasless_send = attributes[:'gasless_send']
118
+ else
119
+ self.gasless_send = nil
120
+ end
121
+ end
122
+
123
+ # Show invalid properties with the reasons. Usually used together with valid?
124
+ # @return Array for valid properties with the reasons
125
+ def list_invalid_properties
126
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
127
+ invalid_properties = Array.new
128
+ if @faucet.nil?
129
+ invalid_properties.push('invalid value for "faucet", faucet cannot be nil.')
130
+ end
131
+
132
+ if @server_signer.nil?
133
+ invalid_properties.push('invalid value for "server_signer", server_signer cannot be nil.')
134
+ end
135
+
136
+ if @transfer.nil?
137
+ invalid_properties.push('invalid value for "transfer", transfer cannot be nil.')
138
+ end
139
+
140
+ if @trade.nil?
141
+ invalid_properties.push('invalid value for "trade", trade cannot be nil.')
142
+ end
143
+
144
+ if @stake.nil?
145
+ invalid_properties.push('invalid value for "stake", stake cannot be nil.')
146
+ end
147
+
148
+ if @gasless_send.nil?
149
+ invalid_properties.push('invalid value for "gasless_send", gasless_send cannot be nil.')
150
+ end
151
+
152
+ invalid_properties
153
+ end
154
+
155
+ # Check to see if the all the properties in the model are valid
156
+ # @return true if the model is valid
157
+ def valid?
158
+ warn '[DEPRECATED] the `valid?` method is obsolete'
159
+ return false if @faucet.nil?
160
+ return false if @server_signer.nil?
161
+ return false if @transfer.nil?
162
+ return false if @trade.nil?
163
+ return false if @stake.nil?
164
+ return false if @gasless_send.nil?
165
+ true
166
+ end
167
+
168
+ # Checks equality by comparing each attribute.
169
+ # @param [Object] Object to be compared
170
+ def ==(o)
171
+ return true if self.equal?(o)
172
+ self.class == o.class &&
173
+ faucet == o.faucet &&
174
+ server_signer == o.server_signer &&
175
+ transfer == o.transfer &&
176
+ trade == o.trade &&
177
+ stake == o.stake &&
178
+ gasless_send == o.gasless_send
179
+ end
180
+
181
+ # @see the `==` method
182
+ # @param [Object] Object to be compared
183
+ def eql?(o)
184
+ self == o
185
+ end
186
+
187
+ # Calculates hash code according to all attributes.
188
+ # @return [Integer] Hash code
189
+ def hash
190
+ [faucet, server_signer, transfer, trade, stake, gasless_send].hash
191
+ end
192
+
193
+ # Builds the object from hash
194
+ # @param [Hash] attributes Model attributes in the form of hash
195
+ # @return [Object] Returns the model itself
196
+ def self.build_from_hash(attributes)
197
+ return nil unless attributes.is_a?(Hash)
198
+ attributes = attributes.transform_keys(&:to_sym)
199
+ transformed_hash = {}
200
+ openapi_types.each_pair do |key, type|
201
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
202
+ transformed_hash["#{key}"] = nil
203
+ elsif type =~ /\AArray<(.*)>/i
204
+ # check to ensure the input is an array given that the attribute
205
+ # is documented as an array but the input is not
206
+ if attributes[attribute_map[key]].is_a?(Array)
207
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
208
+ end
209
+ elsif !attributes[attribute_map[key]].nil?
210
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
211
+ end
212
+ end
213
+ new(transformed_hash)
214
+ end
215
+
216
+ # Deserializes the data based on type
217
+ # @param string type Data type
218
+ # @param string value Value to be deserialized
219
+ # @return [Object] Deserialized data
220
+ def self._deserialize(type, value)
221
+ case type.to_sym
222
+ when :Time
223
+ Time.parse(value)
224
+ when :Date
225
+ Date.parse(value)
226
+ when :String
227
+ value.to_s
228
+ when :Integer
229
+ value.to_i
230
+ when :Float
231
+ value.to_f
232
+ when :Boolean
233
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
234
+ true
235
+ else
236
+ false
237
+ end
238
+ when :Object
239
+ # generic object (usually a Hash), return directly
240
+ value
241
+ when /\AArray<(?<inner_type>.+)>\z/
242
+ inner_type = Regexp.last_match[:inner_type]
243
+ value.map { |v| _deserialize(inner_type, v) }
244
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
245
+ k_type = Regexp.last_match[:k_type]
246
+ v_type = Regexp.last_match[:v_type]
247
+ {}.tap do |hash|
248
+ value.each do |k, v|
249
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
250
+ end
251
+ end
252
+ else # model
253
+ # models (e.g. Pet) or oneOf
254
+ klass = Coinbase::Client.const_get(type)
255
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
256
+ end
257
+ end
258
+
259
+ # Returns the string representation of the object
260
+ # @return [String] String presentation of the object
261
+ def to_s
262
+ to_hash.to_s
263
+ end
264
+
265
+ # to_body is an alias to to_hash (backward compatibility)
266
+ # @return [Hash] Returns the object in the form of hash
267
+ def to_body
268
+ to_hash
269
+ end
270
+
271
+ # Returns the object in the form of hash
272
+ # @return [Hash] Returns the object in the form of hash
273
+ def to_hash
274
+ hash = {}
275
+ self.class.attribute_map.each_pair do |attr, param|
276
+ value = self.send(attr)
277
+ if value.nil?
278
+ is_nullable = self.class.openapi_nullable.include?(attr)
279
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
280
+ end
281
+
282
+ hash[param] = _to_hash(value)
283
+ end
284
+ hash
285
+ end
286
+
287
+ # Outputs non-array value in the form of hash
288
+ # For object, use to_hash. Otherwise, just return the value
289
+ # @param [Object] value Any valid value
290
+ # @return [Hash] Returns the value in the form of hash
291
+ def _to_hash(value)
292
+ if value.is_a?(Array)
293
+ value.compact.map { |v| _to_hash(v) }
294
+ elsif value.is_a?(Hash)
295
+ {}.tap do |hash|
296
+ value.each { |k, v| hash[k] = _to_hash(v) }
297
+ end
298
+ elsif value.respond_to? :to_hash
299
+ value.to_hash
300
+ else
301
+ value
302
+ end
303
+ end
304
+
305
+ end
306
+
307
+ end
@@ -0,0 +1,258 @@
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
+ #
18
+ class FetchHistoricalStakingBalances200Response
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
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'data' => :'data',
31
+ :'has_more' => :'has_more',
32
+ :'next_page' => :'next_page'
33
+ }
34
+ end
35
+
36
+ # Returns all the JSON keys this model knows about
37
+ def self.acceptable_attributes
38
+ attribute_map.values
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'data' => :'Array<StakingBalance>',
45
+ :'has_more' => :'Boolean',
46
+ :'next_page' => :'String'
47
+ }
48
+ end
49
+
50
+ # List of attributes with nullable: true
51
+ def self.openapi_nullable
52
+ Set.new([
53
+ ])
54
+ end
55
+
56
+ # Initializes the object
57
+ # @param [Hash] attributes Model attributes in the form of hash
58
+ def initialize(attributes = {})
59
+ if (!attributes.is_a?(Hash))
60
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::FetchHistoricalStakingBalances200Response` initialize method"
61
+ end
62
+
63
+ # check to see if the attribute exists and convert string to symbol for hash key
64
+ attributes = attributes.each_with_object({}) { |(k, v), h|
65
+ if (!self.class.attribute_map.key?(k.to_sym))
66
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::FetchHistoricalStakingBalances200Response`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
67
+ end
68
+ h[k.to_sym] = v
69
+ }
70
+
71
+ if attributes.key?(:'data')
72
+ if (value = attributes[:'data']).is_a?(Array)
73
+ self.data = value
74
+ end
75
+ else
76
+ self.data = nil
77
+ end
78
+
79
+ if attributes.key?(:'has_more')
80
+ self.has_more = attributes[:'has_more']
81
+ else
82
+ self.has_more = nil
83
+ end
84
+
85
+ if attributes.key?(:'next_page')
86
+ self.next_page = attributes[:'next_page']
87
+ else
88
+ self.next_page = nil
89
+ end
90
+ end
91
+
92
+ # Show invalid properties with the reasons. Usually used together with valid?
93
+ # @return Array for valid properties with the reasons
94
+ def list_invalid_properties
95
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
96
+ invalid_properties = Array.new
97
+ if @data.nil?
98
+ invalid_properties.push('invalid value for "data", data cannot be nil.')
99
+ end
100
+
101
+ if @has_more.nil?
102
+ invalid_properties.push('invalid value for "has_more", has_more cannot be nil.')
103
+ end
104
+
105
+ if @next_page.nil?
106
+ invalid_properties.push('invalid value for "next_page", next_page cannot be nil.')
107
+ end
108
+
109
+ invalid_properties
110
+ end
111
+
112
+ # Check to see if the all the properties in the model are valid
113
+ # @return true if the model is valid
114
+ def valid?
115
+ warn '[DEPRECATED] the `valid?` method is obsolete'
116
+ return false if @data.nil?
117
+ return false if @has_more.nil?
118
+ return false if @next_page.nil?
119
+ true
120
+ end
121
+
122
+ # Checks equality by comparing each attribute.
123
+ # @param [Object] Object to be compared
124
+ def ==(o)
125
+ return true if self.equal?(o)
126
+ self.class == o.class &&
127
+ data == o.data &&
128
+ has_more == o.has_more &&
129
+ next_page == o.next_page
130
+ end
131
+
132
+ # @see the `==` method
133
+ # @param [Object] Object to be compared
134
+ def eql?(o)
135
+ self == o
136
+ end
137
+
138
+ # Calculates hash code according to all attributes.
139
+ # @return [Integer] Hash code
140
+ def hash
141
+ [data, has_more, next_page].hash
142
+ end
143
+
144
+ # Builds the object from hash
145
+ # @param [Hash] attributes Model attributes in the form of hash
146
+ # @return [Object] Returns the model itself
147
+ def self.build_from_hash(attributes)
148
+ return nil unless attributes.is_a?(Hash)
149
+ attributes = attributes.transform_keys(&:to_sym)
150
+ transformed_hash = {}
151
+ openapi_types.each_pair do |key, type|
152
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
153
+ transformed_hash["#{key}"] = nil
154
+ elsif type =~ /\AArray<(.*)>/i
155
+ # check to ensure the input is an array given that the attribute
156
+ # is documented as an array but the input is not
157
+ if attributes[attribute_map[key]].is_a?(Array)
158
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
159
+ end
160
+ elsif !attributes[attribute_map[key]].nil?
161
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
162
+ end
163
+ end
164
+ new(transformed_hash)
165
+ end
166
+
167
+ # Deserializes the data based on type
168
+ # @param string type Data type
169
+ # @param string value Value to be deserialized
170
+ # @return [Object] Deserialized data
171
+ def self._deserialize(type, value)
172
+ case type.to_sym
173
+ when :Time
174
+ Time.parse(value)
175
+ when :Date
176
+ Date.parse(value)
177
+ when :String
178
+ value.to_s
179
+ when :Integer
180
+ value.to_i
181
+ when :Float
182
+ value.to_f
183
+ when :Boolean
184
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
185
+ true
186
+ else
187
+ false
188
+ end
189
+ when :Object
190
+ # generic object (usually a Hash), return directly
191
+ value
192
+ when /\AArray<(?<inner_type>.+)>\z/
193
+ inner_type = Regexp.last_match[:inner_type]
194
+ value.map { |v| _deserialize(inner_type, v) }
195
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
196
+ k_type = Regexp.last_match[:k_type]
197
+ v_type = Regexp.last_match[:v_type]
198
+ {}.tap do |hash|
199
+ value.each do |k, v|
200
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
201
+ end
202
+ end
203
+ else # model
204
+ # models (e.g. Pet) or oneOf
205
+ klass = Coinbase::Client.const_get(type)
206
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
207
+ end
208
+ end
209
+
210
+ # Returns the string representation of the object
211
+ # @return [String] String presentation of the object
212
+ def to_s
213
+ to_hash.to_s
214
+ end
215
+
216
+ # to_body is an alias to to_hash (backward compatibility)
217
+ # @return [Hash] Returns the object in the form of hash
218
+ def to_body
219
+ to_hash
220
+ end
221
+
222
+ # Returns the object in the form of hash
223
+ # @return [Hash] Returns the object in the form of hash
224
+ def to_hash
225
+ hash = {}
226
+ self.class.attribute_map.each_pair do |attr, param|
227
+ value = self.send(attr)
228
+ if value.nil?
229
+ is_nullable = self.class.openapi_nullable.include?(attr)
230
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
231
+ end
232
+
233
+ hash[param] = _to_hash(value)
234
+ end
235
+ hash
236
+ end
237
+
238
+ # Outputs non-array value in the form of hash
239
+ # For object, use to_hash. Otherwise, just return the value
240
+ # @param [Object] value Any valid value
241
+ # @return [Hash] Returns the value in the form of hash
242
+ def _to_hash(value)
243
+ if value.is_a?(Array)
244
+ value.compact.map { |v| _to_hash(v) }
245
+ elsif value.is_a?(Hash)
246
+ {}.tap do |hash|
247
+ value.each { |k, v| hash[k] = _to_hash(v) }
248
+ end
249
+ elsif value.respond_to? :to_hash
250
+ value.to_hash
251
+ else
252
+ value
253
+ end
254
+ end
255
+
256
+ end
257
+
258
+ end