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