coinbase-sdk 0.0.1 → 0.0.3

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 (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,348 @@
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 'cgi'
14
+
15
+ module Coinbase::Client
16
+ class WalletsApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Create a new wallet
23
+ # Create a new wallet scoped to the user.
24
+ # @param [Hash] opts the optional parameters
25
+ # @option opts [CreateWalletRequest] :create_wallet_request
26
+ # @return [Wallet]
27
+ def create_wallet(opts = {})
28
+ data, _status_code, _headers = create_wallet_with_http_info(opts)
29
+ data
30
+ end
31
+
32
+ # Create a new wallet
33
+ # Create a new wallet scoped to the user.
34
+ # @param [Hash] opts the optional parameters
35
+ # @option opts [CreateWalletRequest] :create_wallet_request
36
+ # @return [Array<(Wallet, Integer, Hash)>] Wallet data, response status code and response headers
37
+ def create_wallet_with_http_info(opts = {})
38
+ if @api_client.config.debugging
39
+ @api_client.config.logger.debug 'Calling API: WalletsApi.create_wallet ...'
40
+ end
41
+ # resource path
42
+ local_var_path = '/v1/wallets'
43
+
44
+ # query parameters
45
+ query_params = opts[:query_params] || {}
46
+
47
+ # header parameters
48
+ header_params = opts[:header_params] || {}
49
+ # HTTP header 'Accept' (if needed)
50
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
51
+ # HTTP header 'Content-Type'
52
+ content_type = @api_client.select_header_content_type(['application/json'])
53
+ if !content_type.nil?
54
+ header_params['Content-Type'] = content_type
55
+ end
56
+
57
+ # form parameters
58
+ form_params = opts[:form_params] || {}
59
+
60
+ # http body (model)
61
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'create_wallet_request'])
62
+
63
+ # return_type
64
+ return_type = opts[:debug_return_type] || 'Wallet'
65
+
66
+ # auth_names
67
+ auth_names = opts[:debug_auth_names] || []
68
+
69
+ new_options = opts.merge(
70
+ :operation => :"WalletsApi.create_wallet",
71
+ :header_params => header_params,
72
+ :query_params => query_params,
73
+ :form_params => form_params,
74
+ :body => post_body,
75
+ :auth_names => auth_names,
76
+ :return_type => return_type
77
+ )
78
+
79
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
80
+ if @api_client.config.debugging
81
+ @api_client.config.logger.debug "API called: WalletsApi#create_wallet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
82
+ end
83
+ return data, status_code, headers
84
+ end
85
+
86
+ # Get wallet by ID
87
+ # Get wallet
88
+ # @param wallet_id [String] The ID of the wallet to fetch
89
+ # @param [Hash] opts the optional parameters
90
+ # @return [Wallet]
91
+ def get_wallet(wallet_id, opts = {})
92
+ data, _status_code, _headers = get_wallet_with_http_info(wallet_id, opts)
93
+ data
94
+ end
95
+
96
+ # Get wallet by ID
97
+ # Get wallet
98
+ # @param wallet_id [String] The ID of the wallet to fetch
99
+ # @param [Hash] opts the optional parameters
100
+ # @return [Array<(Wallet, Integer, Hash)>] Wallet data, response status code and response headers
101
+ def get_wallet_with_http_info(wallet_id, opts = {})
102
+ if @api_client.config.debugging
103
+ @api_client.config.logger.debug 'Calling API: WalletsApi.get_wallet ...'
104
+ end
105
+ # verify the required parameter 'wallet_id' is set
106
+ if @api_client.config.client_side_validation && wallet_id.nil?
107
+ fail ArgumentError, "Missing the required parameter 'wallet_id' when calling WalletsApi.get_wallet"
108
+ end
109
+ # resource path
110
+ local_var_path = '/v1/wallets/{wallet_id}'.sub('{' + 'wallet_id' + '}', CGI.escape(wallet_id.to_s))
111
+
112
+ # query parameters
113
+ query_params = opts[:query_params] || {}
114
+
115
+ # header parameters
116
+ header_params = opts[:header_params] || {}
117
+ # HTTP header 'Accept' (if needed)
118
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
119
+
120
+ # form parameters
121
+ form_params = opts[:form_params] || {}
122
+
123
+ # http body (model)
124
+ post_body = opts[:debug_body]
125
+
126
+ # return_type
127
+ return_type = opts[:debug_return_type] || 'Wallet'
128
+
129
+ # auth_names
130
+ auth_names = opts[:debug_auth_names] || []
131
+
132
+ new_options = opts.merge(
133
+ :operation => :"WalletsApi.get_wallet",
134
+ :header_params => header_params,
135
+ :query_params => query_params,
136
+ :form_params => form_params,
137
+ :body => post_body,
138
+ :auth_names => auth_names,
139
+ :return_type => return_type
140
+ )
141
+
142
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
143
+ if @api_client.config.debugging
144
+ @api_client.config.logger.debug "API called: WalletsApi#get_wallet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
145
+ end
146
+ return data, status_code, headers
147
+ end
148
+
149
+ # Get the balance of an asset in the wallet
150
+ # Get the aggregated balance of an asset across all of the addresses in the wallet.
151
+ # @param wallet_id [String] The ID of the wallet to fetch the balance for
152
+ # @param asset_id [String] The symbol of the asset to fetch the balance for
153
+ # @param [Hash] opts the optional parameters
154
+ # @return [Balance]
155
+ def get_wallet_balance(wallet_id, asset_id, opts = {})
156
+ data, _status_code, _headers = get_wallet_balance_with_http_info(wallet_id, asset_id, opts)
157
+ data
158
+ end
159
+
160
+ # Get the balance of an asset in the wallet
161
+ # Get the aggregated balance of an asset across all of the addresses in the wallet.
162
+ # @param wallet_id [String] The ID of the wallet to fetch the balance for
163
+ # @param asset_id [String] The symbol of the asset to fetch the balance for
164
+ # @param [Hash] opts the optional parameters
165
+ # @return [Array<(Balance, Integer, Hash)>] Balance data, response status code and response headers
166
+ def get_wallet_balance_with_http_info(wallet_id, asset_id, opts = {})
167
+ if @api_client.config.debugging
168
+ @api_client.config.logger.debug 'Calling API: WalletsApi.get_wallet_balance ...'
169
+ end
170
+ # verify the required parameter 'wallet_id' is set
171
+ if @api_client.config.client_side_validation && wallet_id.nil?
172
+ fail ArgumentError, "Missing the required parameter 'wallet_id' when calling WalletsApi.get_wallet_balance"
173
+ end
174
+ # verify the required parameter 'asset_id' is set
175
+ if @api_client.config.client_side_validation && asset_id.nil?
176
+ fail ArgumentError, "Missing the required parameter 'asset_id' when calling WalletsApi.get_wallet_balance"
177
+ end
178
+ # resource path
179
+ local_var_path = '/v1/wallets/{wallet_id}/balances/{asset_id}'.sub('{' + 'wallet_id' + '}', CGI.escape(wallet_id.to_s)).sub('{' + 'asset_id' + '}', CGI.escape(asset_id.to_s))
180
+
181
+ # query parameters
182
+ query_params = opts[:query_params] || {}
183
+
184
+ # header parameters
185
+ header_params = opts[:header_params] || {}
186
+ # HTTP header 'Accept' (if needed)
187
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
188
+
189
+ # form parameters
190
+ form_params = opts[:form_params] || {}
191
+
192
+ # http body (model)
193
+ post_body = opts[:debug_body]
194
+
195
+ # return_type
196
+ return_type = opts[:debug_return_type] || 'Balance'
197
+
198
+ # auth_names
199
+ auth_names = opts[:debug_auth_names] || []
200
+
201
+ new_options = opts.merge(
202
+ :operation => :"WalletsApi.get_wallet_balance",
203
+ :header_params => header_params,
204
+ :query_params => query_params,
205
+ :form_params => form_params,
206
+ :body => post_body,
207
+ :auth_names => auth_names,
208
+ :return_type => return_type
209
+ )
210
+
211
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
212
+ if @api_client.config.debugging
213
+ @api_client.config.logger.debug "API called: WalletsApi#get_wallet_balance\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
214
+ end
215
+ return data, status_code, headers
216
+ end
217
+
218
+ # List wallet balances
219
+ # List the balances of all of the addresses in the wallet aggregated by asset.
220
+ # @param wallet_id [String] The ID of the wallet to fetch the balances for
221
+ # @param [Hash] opts the optional parameters
222
+ # @return [AddressBalanceList]
223
+ def list_wallet_balances(wallet_id, opts = {})
224
+ data, _status_code, _headers = list_wallet_balances_with_http_info(wallet_id, opts)
225
+ data
226
+ end
227
+
228
+ # List wallet balances
229
+ # List the balances of all of the addresses in the wallet aggregated by asset.
230
+ # @param wallet_id [String] The ID of the wallet to fetch the balances for
231
+ # @param [Hash] opts the optional parameters
232
+ # @return [Array<(AddressBalanceList, Integer, Hash)>] AddressBalanceList data, response status code and response headers
233
+ def list_wallet_balances_with_http_info(wallet_id, opts = {})
234
+ if @api_client.config.debugging
235
+ @api_client.config.logger.debug 'Calling API: WalletsApi.list_wallet_balances ...'
236
+ end
237
+ # verify the required parameter 'wallet_id' is set
238
+ if @api_client.config.client_side_validation && wallet_id.nil?
239
+ fail ArgumentError, "Missing the required parameter 'wallet_id' when calling WalletsApi.list_wallet_balances"
240
+ end
241
+ # resource path
242
+ local_var_path = '/v1/wallets/{wallet_id}/balances'.sub('{' + 'wallet_id' + '}', CGI.escape(wallet_id.to_s))
243
+
244
+ # query parameters
245
+ query_params = opts[:query_params] || {}
246
+
247
+ # header parameters
248
+ header_params = opts[:header_params] || {}
249
+ # HTTP header 'Accept' (if needed)
250
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
251
+
252
+ # form parameters
253
+ form_params = opts[:form_params] || {}
254
+
255
+ # http body (model)
256
+ post_body = opts[:debug_body]
257
+
258
+ # return_type
259
+ return_type = opts[:debug_return_type] || 'AddressBalanceList'
260
+
261
+ # auth_names
262
+ auth_names = opts[:debug_auth_names] || []
263
+
264
+ new_options = opts.merge(
265
+ :operation => :"WalletsApi.list_wallet_balances",
266
+ :header_params => header_params,
267
+ :query_params => query_params,
268
+ :form_params => form_params,
269
+ :body => post_body,
270
+ :auth_names => auth_names,
271
+ :return_type => return_type
272
+ )
273
+
274
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
275
+ if @api_client.config.debugging
276
+ @api_client.config.logger.debug "API called: WalletsApi#list_wallet_balances\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
277
+ end
278
+ return data, status_code, headers
279
+ end
280
+
281
+ # List wallets
282
+ # List wallets belonging to the user.
283
+ # @param [Hash] opts the optional parameters
284
+ # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.
285
+ # @option opts [String] :page A cursor for pagination across multiple pages of results. Don&#39;t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results.
286
+ # @return [WalletList]
287
+ def list_wallets(opts = {})
288
+ data, _status_code, _headers = list_wallets_with_http_info(opts)
289
+ data
290
+ end
291
+
292
+ # List wallets
293
+ # List wallets belonging to the user.
294
+ # @param [Hash] opts the optional parameters
295
+ # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.
296
+ # @option opts [String] :page A cursor for pagination across multiple pages of results. Don&#39;t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results.
297
+ # @return [Array<(WalletList, Integer, Hash)>] WalletList data, response status code and response headers
298
+ def list_wallets_with_http_info(opts = {})
299
+ if @api_client.config.debugging
300
+ @api_client.config.logger.debug 'Calling API: WalletsApi.list_wallets ...'
301
+ end
302
+ if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'].to_s.length > 5000
303
+ fail ArgumentError, 'invalid value for "opts[:"page"]" when calling WalletsApi.list_wallets, the character length must be smaller than or equal to 5000.'
304
+ end
305
+
306
+ # resource path
307
+ local_var_path = '/v1/wallets'
308
+
309
+ # query parameters
310
+ query_params = opts[:query_params] || {}
311
+ query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
312
+ query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
313
+
314
+ # header parameters
315
+ header_params = opts[:header_params] || {}
316
+ # HTTP header 'Accept' (if needed)
317
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
318
+
319
+ # form parameters
320
+ form_params = opts[:form_params] || {}
321
+
322
+ # http body (model)
323
+ post_body = opts[:debug_body]
324
+
325
+ # return_type
326
+ return_type = opts[:debug_return_type] || 'WalletList'
327
+
328
+ # auth_names
329
+ auth_names = opts[:debug_auth_names] || []
330
+
331
+ new_options = opts.merge(
332
+ :operation => :"WalletsApi.list_wallets",
333
+ :header_params => header_params,
334
+ :query_params => query_params,
335
+ :form_params => form_params,
336
+ :body => post_body,
337
+ :auth_names => auth_names,
338
+ :return_type => return_type
339
+ )
340
+
341
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
342
+ if @api_client.config.debugging
343
+ @api_client.config.logger.debug "API called: WalletsApi#list_wallets\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
344
+ end
345
+ return data, status_code, headers
346
+ end
347
+ end
348
+ end