coinbase 0.0.1 → 4.0.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.

Potentially problematic release.


This version of coinbase might be problematic. Click here for more details.

Files changed (46) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -0
  3. data/Gemfile +4 -0
  4. data/Gemfile.lock +67 -0
  5. data/LICENSE.txt +21 -0
  6. data/README.md +578 -0
  7. data/Rakefile +7 -0
  8. data/bin/console +14 -0
  9. data/bin/setup +7 -0
  10. data/coinbase.gemspec +30 -0
  11. data/lib/coinbase/wallet/adapters/em_http.rb +64 -0
  12. data/lib/coinbase/wallet/adapters/net_http.rb +62 -0
  13. data/lib/coinbase/wallet/api_client.rb +659 -0
  14. data/lib/coinbase/wallet/api_errors.rb +112 -0
  15. data/lib/coinbase/wallet/api_response.rb +37 -0
  16. data/lib/coinbase/wallet/client.rb +98 -0
  17. data/lib/coinbase/wallet/models/account.rb +187 -0
  18. data/lib/coinbase/wallet/models/api_object.rb +46 -0
  19. data/lib/coinbase/wallet/models/checkout.rb +19 -0
  20. data/lib/coinbase/wallet/models/order.rb +12 -0
  21. data/lib/coinbase/wallet/models/transaction.rb +21 -0
  22. data/lib/coinbase/wallet/models/transfer.rb +13 -0
  23. data/lib/coinbase/wallet/models/user.rb +15 -0
  24. data/lib/coinbase/wallet/version.rb +5 -0
  25. data/lib/coinbase/wallet.rb +23 -156
  26. data/spec/account_spec.rb +193 -0
  27. data/spec/clients/client_spec.rb +34 -0
  28. data/spec/clients/oauth_client_spec.rb +56 -0
  29. data/spec/endpoints_spec.rb +346 -0
  30. data/spec/error_spec.rb +130 -0
  31. data/spec/models/api_object_spec.rb +63 -0
  32. data/spec/models/checkout_spec.rb +52 -0
  33. data/spec/models/current_user_spec.rb +29 -0
  34. data/spec/models/order_spec.rb +52 -0
  35. data/spec/models/request_spec.rb +47 -0
  36. data/spec/models/transfer_spec.rb +64 -0
  37. data/spec/models/user_spec.rb +24 -0
  38. data/spec/spec_helper.rb +13 -0
  39. metadata +72 -82
  40. data/lib/coinbase/address.rb +0 -127
  41. data/lib/coinbase/asset.rb +0 -20
  42. data/lib/coinbase/balance_map.rb +0 -48
  43. data/lib/coinbase/constants.rb +0 -38
  44. data/lib/coinbase/network.rb +0 -55
  45. data/lib/coinbase/transfer.rb +0 -153
  46. data/lib/coinbase.rb +0 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: fd20c87743ea6c8d95575db35841ffd10b1dc87376d9d1e2e08803998b8322e8
4
- data.tar.gz: 475ac4213ae2e15c5ea5002441302faa908524ccb067e7a0ce99194d15c5b049
2
+ SHA1:
3
+ metadata.gz: 3bfc8d9d9a5aaea0b9dd0c84a98294c73df0e733
4
+ data.tar.gz: b07060654f8b2ecd3b71f9e8617d6e904f879b38
5
5
  SHA512:
6
- metadata.gz: 94fadca140def76fb428a824eca188f3eaa77388963f59ec04d70adfc1c1ccf2002c8af791bfc84bb7d83b07753b83fc755cec3af149e6c4549d51c594490ba6
7
- data.tar.gz: 8d04ee71428ee01611445c71f7642a205493e4a12f365826726132fc5fc783015e7aaa7e98e3813da924c914336bc51592198b6e0b3cc77b4e7e0d2226fdc655
6
+ metadata.gz: 8582fdb33927af319b8abc778990073f772a2097ef0307555ed3ebd3a2b7812c214e730ceb2b30fde0b91fcaf25b54c512e3e2416d4dda635dcad9d4a59ba4df
7
+ data.tar.gz: d29b41a4ea6732b1c04aabd2eb3823c7a5bb83886f3ac56f0ebc5207be18ff428454ada5215c0dbc23afeb9ca6ff57f0d0051a4775046d96bb0e00d7ad9cc08c
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in coinbase-wallet.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,67 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ coinbase-wallet (4.0.0)
5
+ bigdecimal
6
+ em-http-request
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.3.8)
12
+ bigdecimal (1.2.7)
13
+ coderay (1.1.0)
14
+ cookiejar (0.3.2)
15
+ crack (0.4.2)
16
+ safe_yaml (~> 1.0.0)
17
+ diff-lcs (1.2.5)
18
+ em-http-request (1.1.2)
19
+ addressable (>= 2.3.4)
20
+ cookiejar
21
+ em-socksify (>= 0.3)
22
+ eventmachine (>= 1.0.3)
23
+ http_parser.rb (>= 0.6.0)
24
+ em-socksify (0.3.0)
25
+ eventmachine (>= 1.0.0.beta.4)
26
+ eventmachine (1.0.7)
27
+ http_parser.rb (0.6.0)
28
+ method_source (0.8.2)
29
+ pry (0.10.1)
30
+ coderay (~> 1.1.0)
31
+ method_source (~> 0.8.1)
32
+ slop (~> 3.4)
33
+ rake (10.4.2)
34
+ rspec (3.3.0)
35
+ rspec-core (~> 3.3.0)
36
+ rspec-expectations (~> 3.3.0)
37
+ rspec-mocks (~> 3.3.0)
38
+ rspec-core (3.3.1)
39
+ rspec-support (~> 3.3.0)
40
+ rspec-expectations (3.3.0)
41
+ diff-lcs (>= 1.2.0, < 2.0)
42
+ rspec-support (~> 3.3.0)
43
+ rspec-mocks (3.3.1)
44
+ diff-lcs (>= 1.2.0, < 2.0)
45
+ rspec-support (~> 3.3.0)
46
+ rspec-support (3.3.0)
47
+ safe_yaml (1.0.4)
48
+ slop (3.6.0)
49
+ timecop (0.7.1)
50
+ webmock (1.21.0)
51
+ addressable (>= 2.3.6)
52
+ crack (>= 0.3.2)
53
+
54
+ PLATFORMS
55
+ ruby
56
+
57
+ DEPENDENCIES
58
+ bundler (~> 1.10)
59
+ coinbase-wallet!
60
+ pry (~> 0)
61
+ rake (~> 10.0)
62
+ rspec
63
+ timecop
64
+ webmock
65
+
66
+ BUNDLED WITH
67
+ 1.10.5
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 John Duhamel
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,578 @@
1
+ # Coinbase Wallet Gem
2
+
3
+ This is the official client library for the Coinbase Wallet API v2. We provide an intuitive, stable interface to integrate Coinbase Wallet into your Ruby project.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'coinbase'
10
+
11
+ Then execute:
12
+
13
+ $ bundle install
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install coinbase
18
+
19
+ ## Authentication
20
+
21
+ ### API Key (HMAC Client)
22
+
23
+ We provide a synchronous client based on Net::HTTP as well as a asynchronous client based on the EM-HTTP-Request gem. For most users, the synchronous client will suffice.
24
+
25
+ ```ruby
26
+ require 'coinbase/wallet'
27
+ client = Coinbase::Wallet::Client.new(api_key: <api key>, api_secret: <api secret>)
28
+ ```
29
+
30
+ The primary intention of the asynchronous client is to integrate nicely with the [Coinbase Exchange Gem](https://github.com/coinbase/coinbase-exchange-ruby). If your project interfaces with our Exchange as well, please consider using this.
31
+
32
+ ```ruby
33
+ require 'coinbase/wallet'
34
+ client = Coinbase::Wallet::AsyncClient.new(api_key: <api_key>, api_secret: <api secret>)
35
+ ```
36
+
37
+ ### OAuth2 Client
38
+
39
+ We provide an OAuth client if you need access to user accounts other than your own. Currently, the gem does not handle the handshake process, and assumes you have an access token when it's initialized. The OAuth client is synchronous. Please reach out if you would like us to add an asynchronous OAuth client as well.
40
+
41
+ ```ruby
42
+ require 'coinbase/wallet'
43
+
44
+ # Initializing OAuthClient with both access and refresh token
45
+ client = Coinbase::Wallet::OAuthClient.new(access_token: <access token>, refresh_token: <refresh_token>)
46
+
47
+ # Initializing OAuthClient with only access token
48
+ client = Coinbase::Wallet::OAuthClient.new(access_token: <access token>)
49
+ ```
50
+
51
+ The OAuth client provides a few extra methods to refresh and revoke the access token.
52
+
53
+ ```ruby
54
+ client.refresh!
55
+ ```
56
+
57
+ ```ruby
58
+ client.revoke!
59
+ ```
60
+
61
+ #### Two factor authentication
62
+
63
+ Send money endpoint requires 2FA token in certain situations (read more [here](https://developers.coinbase.com/docs/wallet/coinbase-connect#two-factor-authentication)). Specific exception is thrown when this is required:
64
+
65
+ ```ruby
66
+ account = client.primary_account
67
+ begin
68
+ account.send(to: 'test@test.com', amount: '1', currency: "BTC")
69
+ rescue Coinbase::Client::TwoFactorRequiredError
70
+ # Show 2FA dialog to user and collect 2FA token
71
+
72
+ # Re-try call with `two_factor_token` param
73
+ account.send(to: 'test@test.com', amount: '1', currency: "BTC", two_factor_token: "123456")
74
+ end
75
+ ```
76
+
77
+ ## Requests
78
+
79
+ We provide one method per API endpoint. Several methods require one or more identifiers to be passed as arguments. Additionally, all parameters can be appended as [keyword arguements](https://robots.thoughtbot.com/ruby-2-keyword-arguments). If a required parameter is not supplied, the client will raise an error. For instance, the following call will send 100 bitcoin to the account registered with example@coinbase.com.
80
+
81
+ ```ruby
82
+ account = client.primary_account
83
+ account.send(to: 'example@coinbase.com', amount: 100, currency: "USD", description: 'Sending 100 bitcoin')
84
+ ```
85
+
86
+ ### Pagination
87
+
88
+ Several endpoints are [paginated](https://developers.coinbase.com/api/v2#pagination). By default, the gem will only fetch the first page of data for a given request. You can implement your own pagination scheme, such as [pipelining](https://en.wikipedia.org/wiki/HTTP_pipelining), by setting the starting_after parameter in your response.
89
+
90
+ ```ruby
91
+ client.transactions(account_id) do |data, resp|
92
+ transactions = data
93
+ end
94
+
95
+ more_pages = true
96
+ while more_pages
97
+ client.transactions(account_id, starting_after: transactions.last['id']) do |data, resp|
98
+ more_pages = resp.has_more?
99
+ transactions << data
100
+ transactions.flatten!
101
+ end
102
+ end
103
+ ```
104
+
105
+ If you want to automatically download the entire dataset, you may pass `fetch_all=true` as a parameter.
106
+
107
+ ```ruby
108
+ client.transactions(account_id, fetch_all: true) do |data, resp|
109
+ ...
110
+ end
111
+ ```
112
+
113
+ ## Responses
114
+
115
+ We provide several ways to access return data. Methods will return the data field of the response in hash format.
116
+
117
+ ```ruby
118
+ txs = account.transactions(account_id)
119
+ txs.each do |tx|
120
+ p tx['id']
121
+ end
122
+ ```
123
+
124
+ You can also handle data inside a block you pass to the method. **You must access data this way if you're using the asynchronous client.**
125
+
126
+ ```ruby
127
+ account.transactions(account_id) do |txs|
128
+ txs.each { |tx| p tx['id'] }
129
+ end
130
+ ```
131
+
132
+ If you need to access the response metadata (headers, pagination info, etc.) you can access the entire response as the second block paramenter.
133
+
134
+ ```ruby
135
+ account.transactions(account_id) do |txs, resp|
136
+ p "STATUS: #{resp.status}"
137
+ p "HEADERS: #{resp.headers}"
138
+ p "BODY: #{resp.body}"
139
+ end
140
+ ```
141
+
142
+ **Response Object**
143
+
144
+ The default representation of response data is a JSON hash. However, we further abstract the response to allow access to response fields as though they were methods.
145
+
146
+ ```ruby
147
+ account = client.primary_account
148
+ p "Account:\t account.name"
149
+ p "ID:\t account.id"
150
+ p "Balance:\t #{account.balance.amount} #{account.balance.currency}"
151
+ ```
152
+
153
+ All values are returned directly from the API unmodified, except the following exceptions:
154
+
155
+ - [Money amounts](https://developers.coinbase.com/api/v2#money-hash) are always converted into [BigDecimal](http://ruby-doc.org/stdlib-2.1.1/libdoc/bigdecimal/rdoc/BigDecimal.html) objects. You should always use BigDecimal when handing bitcoin amounts for accurate presicion
156
+ - [Timestamps](https://developers.coinbase.com/api/v2#timestamps) are always converted into [Time](http://ruby-doc.org/stdlib-2.1.1/libdoc/time/rdoc/Time.html) objects
157
+
158
+ Most methods require an associated account. Thus, responses for the [account endpoints](https://developers.coinbase.com/api/v2#accounts) contain methods for accessing all the relevant endpoints. This is convient, as it doesn't require you to supply the same account id over and over again.
159
+
160
+ ```ruby
161
+ account = client.primary_account
162
+ account.send(to: "example@coinbase.com", amount: 100, description: "Sending 100 bitcoin")
163
+ ```
164
+
165
+ Alternatively you can pass the account ID straight to the client:
166
+
167
+ ```ruby
168
+ client.transactions(<account_id>)
169
+ ```
170
+
171
+ Account response objects will automatically update if they detect any changes to the account. The easiest way to refresh an account is to call the refresh! method.
172
+
173
+ ```ruby
174
+ account.refresh!
175
+ ```
176
+
177
+ ### Warnings
178
+
179
+ It's prudent to be conscious of warnings. By default, the gem will print all warning to STDERR. If you wish to redirect this stream to somewhere else, such as a log file, then you can simply [change the $stderr global variable](http://stackoverflow.com/questions/4459330/how-do-i-temporarily-redirect-stderr-in-ruby).
180
+
181
+ ### Errors
182
+
183
+ If the request is not successful, the gem will raise an error. We try to raise a unique error for every possible API response. All errors are subclasses of `Coinbase::Wallet::APIError`.
184
+
185
+ |Error|Status|
186
+ |---|---|
187
+ |APIError|*|
188
+ |BadRequestError|400|
189
+ |ParamRequiredError|400|
190
+ |InvalidRequestError|400|
191
+ |PersonalDetailsRequiredError|400|
192
+ |AuthenticationError|401|
193
+ |UnverifiedEmailError|401|
194
+ |InvalidTokenError|401|
195
+ |RevokedTokenError|401|
196
+ |ExpiredTokenError|401|
197
+ |TwoFactorRequiredError|402|
198
+ |InvalidScopeError|403|
199
+ |NotFoundError|404|
200
+ |ValidationError|422|
201
+ |RateLimitError|429|
202
+ |InternalServerError|500|
203
+ |ServiceUnavailableError|503|
204
+
205
+ ## Usage
206
+
207
+ This is not intended to provide complete documentation of the API. For more detail, please refer to the [official documentation](https://developers.coinbase.com/api/v2).
208
+
209
+ ###[Market Data](https://developers.coinbase.com/api/v2#data-api)
210
+
211
+ **List supported native currencies**
212
+
213
+ ```ruby
214
+ client.currencies
215
+ ```
216
+
217
+ **List exchange rates**
218
+
219
+ ```ruby
220
+ client.exchange_rate
221
+ ```
222
+
223
+ **Buy price**
224
+
225
+ ```ruby
226
+ client.buy_price
227
+ ```
228
+
229
+ **Sell price**
230
+
231
+ ```ruby
232
+ client.sell_price
233
+ ```
234
+
235
+ **Spot price**
236
+
237
+ ```ruby
238
+ client.spot_price
239
+ ```
240
+
241
+ **Current server time**
242
+
243
+ ```ruby
244
+ client.time
245
+ ```
246
+
247
+ ###[Users](https://developers.coinbase.com/api/v2#users)
248
+
249
+ **Get authorization info**
250
+
251
+ ```ruby
252
+ client.auth_info
253
+ ```
254
+
255
+ **Lookup user info**
256
+
257
+ ```ruby
258
+ client.user(user_id)
259
+ ```
260
+
261
+ **Get current user**
262
+
263
+ ```ruby
264
+ client.current_user
265
+ ```
266
+
267
+ **Update current user**
268
+
269
+ ```ruby
270
+ client.update_current_user(name: "New Name")
271
+ ```
272
+
273
+ ###[Accounts](https://developers.coinbase.com/api/v2#accounts)
274
+
275
+ **List all accounts**
276
+
277
+ ```ruby
278
+ client.accounts
279
+ ```
280
+
281
+ **List account details**
282
+
283
+ ```ruby
284
+ client.account(account_id)
285
+ ```
286
+
287
+ **List primary account details**
288
+
289
+ ```ruby
290
+ client.primary_account
291
+ ```
292
+
293
+ **Set account as primary**
294
+
295
+ ```ruby
296
+ account.make_primary!
297
+ ```
298
+
299
+ **Create a new bitcoin account**
300
+
301
+ ```ruby
302
+ client.create_account(name: "New Account")
303
+ ```
304
+
305
+ **Update an account**
306
+
307
+ ```ruby
308
+ account.update!(name: "New Account Name")
309
+ ```
310
+
311
+ **Delete an account**
312
+
313
+ ```ruby
314
+ account.delete!
315
+ ```
316
+
317
+ ###[Addresses](https://developers.coinbase.com/api/v2#addresses)
318
+
319
+ **List receive addresses for account**
320
+
321
+ ```ruby
322
+ account.addresses
323
+ ```
324
+
325
+ **Get receive address info**
326
+
327
+ ```ruby
328
+ account.address(address_id)
329
+ ```
330
+
331
+ **Create a new receive address**
332
+
333
+ ```ruby
334
+ account.create_address
335
+ ```
336
+
337
+ ###[Transactions](https://developers.coinbase.com/api/v2#transactions)
338
+
339
+ **List transactions**
340
+
341
+ ```ruby
342
+ account.transactions
343
+ ```
344
+
345
+ **Get transaction info**
346
+
347
+ ```ruby
348
+ account.transaction(transaction_id)
349
+ ```
350
+
351
+ **Send funds**
352
+
353
+ ```ruby
354
+ account.send(to: <bitcoin address>, amount: "5.0", currency: "USD", description: "Your first bitcoin!")
355
+ ```
356
+
357
+ **Transfer funds to a new account**
358
+
359
+ ```ruby
360
+ account.transfer(to: <account ID>, amount: "1", currency: "BTC", description: "Your first bitcoin!")
361
+ ```
362
+
363
+ **Request funds**
364
+
365
+ ```ruby
366
+ account .request(to: <email>, amount: "8.0", currency: "USD", description: "Burrito")
367
+ ```
368
+
369
+ **Resend request**
370
+
371
+ ```ruby
372
+ account.resend_request(request_id)
373
+ ```
374
+
375
+ **Cancel request**
376
+
377
+ ```ruby
378
+ account.cancel_request(request_id)
379
+ ```
380
+
381
+ **Fulfill request**
382
+
383
+ ```ruby
384
+ account.complete_request(request_id)
385
+ ```
386
+
387
+ ###[Buys](https://developers.coinbase.com/api/v2#buys)
388
+
389
+ **List buys**
390
+
391
+ ```ruby
392
+ account.list_buys
393
+ ```
394
+
395
+ **Get buy info**
396
+
397
+ ```ruby
398
+ account.list_buy(buy_id)
399
+ ```
400
+
401
+ **Buy bitcoins**
402
+
403
+ ```ruby
404
+ account.buy(amount: "1", currency: "BTC")
405
+ ```
406
+
407
+ **Commit a buy**
408
+
409
+ You only need to do this if you pass `commit=true` when you call the buy method.
410
+
411
+ ```ruby
412
+ buy = account.buy(amount: "1", currency: "BTC", commit: false)
413
+ account.commit_buy(buy.id)
414
+ ```
415
+
416
+ ###[Sells](https://developers.coinbase.com/api/v2#sells)
417
+
418
+ **List sells**
419
+
420
+ ```ruby
421
+ account.list_sells
422
+ ```
423
+
424
+ **Get sell info**
425
+
426
+ ```ruby
427
+ account.list_sell(sell_id)
428
+ ```
429
+
430
+ **Sell bitcoins**
431
+
432
+ ```ruby
433
+ account.sell(amount: "1", currency: "BTC")
434
+ ```
435
+
436
+ **Commit a sell**
437
+
438
+ You only need to do this if you pass `commit=true` when you call the sell method.
439
+
440
+ ```ruby
441
+ sell = account.sell(amount: "1", currency: "BTC", commit: false)
442
+ account.commit_sell(sell.id)
443
+ ```
444
+
445
+ ###[Deposit](https://developers.coinbase.com/api/v2#deposits)
446
+
447
+ **List deposits**
448
+
449
+ ```ruby
450
+ account.list_deposits
451
+ ```
452
+
453
+ **Get deposit info**
454
+
455
+ ```ruby
456
+ account.list_deposit(deposit_id)
457
+ ```
458
+
459
+ **Deposit funds**
460
+
461
+ ```ruby
462
+ account.deposit(amount: "10", currency: "USD")
463
+ ```
464
+
465
+ **Commit a deposit**
466
+
467
+ You only need to do this if you pass `commit=true` when you call the deposit method.
468
+
469
+ ```ruby
470
+ deposit = account.deposit(amount: "1", currency: "BTC", commit: false)
471
+ account.commit_deposit(deposit.id)
472
+ ```
473
+
474
+ ###[Withdrawals](https://developers.coinbase.com/api/v2#withdrawals)
475
+
476
+ **List withdrawals**
477
+
478
+ ```ruby
479
+ account.list_withdrawals
480
+ ```
481
+
482
+ **Get withdrawal**
483
+
484
+ ```ruby
485
+ account.list_withdrawal(withdrawal_id)
486
+ ```
487
+
488
+ **Withdraw funds**
489
+
490
+ ```ruby
491
+ account.withdraw(amount: "10", currency: "USD")
492
+ ```
493
+
494
+ **Commit a withdrawal**
495
+
496
+ You only need to do this if you pass `commit=true` when you call the withdrawal method.
497
+
498
+ ```ruby
499
+ withdraw = account.withdraw(amount: "1", currency: "BTC", commit: false)
500
+ account.commit_withdrawal(withdrawal.id)
501
+ ```
502
+
503
+ ###[Payment Methods](https://developers.coinbase.com/api/v2#payment-methods)
504
+
505
+ **List payment methods**
506
+
507
+ ```ruby
508
+ client.payment_methods
509
+ ```
510
+
511
+ **Get payment method**
512
+
513
+ ```ruby
514
+ client.payment_method(payment_method_id)
515
+ ```
516
+
517
+ ###[Merchants](https://developers.coinbase.com/api/v2#merchants)
518
+
519
+ #### Get merchant
520
+
521
+ ```ruby
522
+ client.merchant(merchant_id)
523
+ ```
524
+
525
+ ###[Orders](https://developers.coinbase.com/api/v2#orders)
526
+
527
+ #### List orders
528
+
529
+ ```ruby
530
+ client.orders
531
+ ```
532
+
533
+ #### Get order
534
+
535
+ ```ruby
536
+ client.order(order_id)
537
+ ```
538
+
539
+ #### Create order
540
+
541
+ ```ruby
542
+ client.create_order(amount: "1", currency: "BTC", name: "Order #1234")
543
+ ```
544
+
545
+ #### Refund order
546
+
547
+ ```ruby
548
+ order = client.orders.first
549
+ order.refund!
550
+ ```
551
+
552
+ ### Checkouts
553
+
554
+ #### List checkouts
555
+
556
+ ```ruby
557
+ client.checkouts
558
+ ```
559
+
560
+ #### Get checkout
561
+
562
+ ```ruby
563
+ client.checkout(checkout_id)
564
+ ```
565
+
566
+ #### Get checkout's orders
567
+
568
+ ```ruby
569
+ checkout = client.checkout(checkout_id)
570
+ checkout.orders
571
+ ```
572
+
573
+ #### Create order for checkout
574
+
575
+ ```ruby
576
+ checkout = client.checkout(checkout_id)
577
+ checkout.create_order(amount: "1", currency: "BTC", name: "Order #1234")
578
+ ```
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec) do
5
+ end
6
+
7
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "coinbase/wallet"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here