coinbase 0.0.1 → 4.0.7

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


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

Files changed (48) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +2 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +21 -0
  5. data/README.md +611 -0
  6. data/Rakefile +7 -0
  7. data/bin/console +14 -0
  8. data/bin/setup +7 -0
  9. data/coinbase.gemspec +27 -0
  10. data/lib/coinbase/wallet/adapters/em_http.rb +78 -0
  11. data/lib/coinbase/wallet/adapters/net_http.rb +68 -0
  12. data/lib/coinbase/wallet/api_client.rb +692 -0
  13. data/lib/coinbase/wallet/api_errors.rb +120 -0
  14. data/lib/coinbase/wallet/api_response.rb +41 -0
  15. data/lib/coinbase/wallet/ca-coinbase.crt +629 -0
  16. data/lib/coinbase/wallet/client.rb +101 -0
  17. data/lib/coinbase/wallet/models/account.rb +187 -0
  18. data/lib/coinbase/wallet/models/address.rb +12 -0
  19. data/lib/coinbase/wallet/models/api_object.rb +46 -0
  20. data/lib/coinbase/wallet/models/checkout.rb +19 -0
  21. data/lib/coinbase/wallet/models/order.rb +12 -0
  22. data/lib/coinbase/wallet/models/transaction.rb +21 -0
  23. data/lib/coinbase/wallet/models/transfer.rb +13 -0
  24. data/lib/coinbase/wallet/models/user.rb +15 -0
  25. data/lib/coinbase/wallet/version.rb +5 -0
  26. data/lib/coinbase/wallet.rb +23 -156
  27. data/spec/account_spec.rb +193 -0
  28. data/spec/clients/client_spec.rb +34 -0
  29. data/spec/clients/oauth_client_spec.rb +56 -0
  30. data/spec/endpoints_spec.rb +352 -0
  31. data/spec/error_spec.rb +137 -0
  32. data/spec/models/address_spec.rb +26 -0
  33. data/spec/models/api_object_spec.rb +63 -0
  34. data/spec/models/checkout_spec.rb +52 -0
  35. data/spec/models/current_user_spec.rb +29 -0
  36. data/spec/models/order_spec.rb +52 -0
  37. data/spec/models/request_spec.rb +47 -0
  38. data/spec/models/transfer_spec.rb +64 -0
  39. data/spec/models/user_spec.rb +24 -0
  40. data/spec/spec_helper.rb +13 -0
  41. metadata +62 -98
  42. data/lib/coinbase/address.rb +0 -127
  43. data/lib/coinbase/asset.rb +0 -20
  44. data/lib/coinbase/balance_map.rb +0 -48
  45. data/lib/coinbase/constants.rb +0 -38
  46. data/lib/coinbase/network.rb +0 -55
  47. data/lib/coinbase/transfer.rb +0 -153
  48. 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: 46b1b6007450bccb2a91a8cb509c8d841ad1f1cc
4
+ data.tar.gz: 1e6a21f70d573c0623e9dea1fc69062eeb68ff97
5
5
  SHA512:
6
- metadata.gz: 94fadca140def76fb428a824eca188f3eaa77388963f59ec04d70adfc1c1ccf2002c8af791bfc84bb7d83b07753b83fc755cec3af149e6c4549d51c594490ba6
7
- data.tar.gz: 8d04ee71428ee01611445c71f7642a205493e4a12f365826726132fc5fc783015e7aaa7e98e3813da924c914336bc51592198b6e0b3cc77b4e7e0d2226fdc655
6
+ metadata.gz: e84aacade7475651b0806cf5533e166de7770444fb8da181a7f725f2fc49f202d7e1df287462105a6ec64f3c23dbb2a3d9673d479ea8608f707c8cc30ceb990f
7
+ data.tar.gz: d3682fe8547d4b082ce202a1034d7b905021f9d346e3d8005dc8955d160828e93f775051e76afd24557e4f8f6549cad4d51e8a2851bd42d02f965a206f872bd2
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ *.gem
2
+ Gemfile.lock
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/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,611 @@
1
+ # Coinbase Wallet Gem
2
+
3
+ This is the official client library for the [Coinbase Wallet API v2](https://developers.coinbase.com/api/v2). We provide an intuitive, stable interface to integrate Coinbase Wallet into your Ruby project.
4
+
5
+ _Important:_ As this library is targeted for newer API v2, it requires v2 permissions (i.e. `wallet:accounts:read`). If you're still using v1, please use [older version](https://github.com/coinbase/coinbase-ruby/releases/tag/v2.1.1) of this library.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'coinbase'
12
+
13
+ Then execute:
14
+
15
+ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ gem install coinbase
20
+
21
+ ## Authentication
22
+
23
+ ### API Key (HMAC Client)
24
+
25
+ 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.
26
+
27
+ ```ruby
28
+ require 'coinbase/wallet'
29
+ client = Coinbase::Wallet::Client.new(api_key: <api key>, api_secret: <api secret>)
30
+ ```
31
+
32
+ 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. *To use this interface, you must include em-http-request gem on your own.*
33
+
34
+ ```ruby
35
+ require 'coinbase/wallet'
36
+ require 'em-http'
37
+
38
+ client = Coinbase::Wallet::AsyncClient.new(api_key: <api_key>, api_secret: <api secret>)
39
+ ```
40
+
41
+ ### OAuth2 Client
42
+
43
+ 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.
44
+
45
+ ```ruby
46
+ require 'coinbase/wallet'
47
+
48
+ # Initializing OAuthClient with both access and refresh token
49
+ client = Coinbase::Wallet::OAuthClient.new(access_token: <access token>, refresh_token: <refresh_token>)
50
+
51
+ # Initializing OAuthClient with only access token
52
+ client = Coinbase::Wallet::OAuthClient.new(access_token: <access token>)
53
+ ```
54
+
55
+ The OAuth client provides a few extra methods to refresh and revoke the access token.
56
+
57
+ ```ruby
58
+ client.refresh!
59
+ ```
60
+
61
+ ```ruby
62
+ client.revoke!
63
+ ```
64
+
65
+ _Protip:tm::_ You can test OAuth2 authentication easily with Developer Access Tokens which can be created under your [OAuth2 application settings](https://www.coinbase.com/settings/api). These are short lived tokens which authenticate but don't require full OAuth2 handshake to obtain.
66
+
67
+ #### Two factor authentication
68
+
69
+ 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:
70
+
71
+ ```ruby
72
+ account = client.primary_account
73
+ begin
74
+ account.send(to: 'test@test.com', amount: '1', currency: "BTC")
75
+ rescue Coinbase::Client::TwoFactorRequiredError
76
+ # Show 2FA dialog to user and collect 2FA token
77
+
78
+ # Re-try call with `two_factor_token` param
79
+ account.send(to: 'test@test.com', amount: '1', currency: "BTC", two_factor_token: "123456")
80
+ end
81
+ ```
82
+
83
+ ### Sandbox support
84
+
85
+ All three clients support [Coinbase Sandbox](https://developers.coinbase.com/api/v2#sandbox). You can initialize clients with optional `api_url` parameter:
86
+
87
+ ```ruby
88
+ require 'coinbase/wallet'
89
+ client = Coinbase::Wallet::Client.new(api_key: <sandbox api key>, api_secret: <sandbox api secret>, api_url: "https://api.sandbox.coinbase.com")
90
+ ```
91
+
92
+ Remember that both API key and OAuth2 credentials are different for Sandbox environment and you need to create them separately at [sandbox.coinbase.com](https://sandbox.coinbase.com).
93
+
94
+ ## Requests
95
+
96
+ 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.
97
+
98
+ ```ruby
99
+ account = client.primary_account
100
+ account.send(to: 'example@coinbase.com', amount: 100, currency: "USD", description: 'Sending 100 bitcoin')
101
+ ```
102
+
103
+ ### Pagination
104
+
105
+ 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.
106
+
107
+ ```ruby
108
+ client.transactions(account_id) do |data, resp|
109
+ transactions = data
110
+ end
111
+
112
+ more_pages = true
113
+ while more_pages
114
+ client.transactions(account_id, starting_after: transactions.last['id']) do |data, resp|
115
+ more_pages = resp.has_more?
116
+ transactions << data
117
+ transactions.flatten!
118
+ end
119
+ end
120
+ ```
121
+
122
+ If you want to automatically download the entire dataset, you may pass `fetch_all=true` as a parameter.
123
+
124
+ ```ruby
125
+ client.transactions(account_id, fetch_all: true) do |data, resp|
126
+ ...
127
+ end
128
+ ```
129
+
130
+ ## Responses
131
+
132
+ We provide several ways to access return data. Methods will return the data field of the response in hash format.
133
+
134
+ ```ruby
135
+ txs = account.transactions(account_id)
136
+ txs.each do |tx|
137
+ p tx['id']
138
+ end
139
+ ```
140
+
141
+ 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.**
142
+
143
+ ```ruby
144
+ account.transactions(account_id) do |txs|
145
+ txs.each { |tx| p tx['id'] }
146
+ end
147
+ ```
148
+
149
+ If you need to access the response metadata (headers, pagination info, etc.) you can access the entire response as the second block paramenter.
150
+
151
+ ```ruby
152
+ account.transactions(account_id) do |txs, resp|
153
+ p "STATUS: #{resp.status}"
154
+ p "HEADERS: #{resp.headers}"
155
+ p "BODY: #{resp.body}"
156
+ end
157
+ ```
158
+
159
+ **Response Object**
160
+
161
+ 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.
162
+
163
+ ```ruby
164
+ account = client.primary_account
165
+ p "Account:\t account.name"
166
+ p "ID:\t account.id"
167
+ p "Balance:\t #{account.balance.amount} #{account.balance.currency}"
168
+ ```
169
+
170
+ All values are returned directly from the API unmodified, except the following exceptions:
171
+
172
+ - [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
173
+ - [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
174
+
175
+ 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.
176
+
177
+ ```ruby
178
+ account = client.primary_account
179
+ account.send(to: "example@coinbase.com", amount: 100, description: "Sending 100 bitcoin")
180
+ ```
181
+
182
+ Alternatively you can pass the account ID straight to the client:
183
+
184
+ ```ruby
185
+ client.transactions(<account_id>)
186
+ ```
187
+
188
+ 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.
189
+
190
+ ```ruby
191
+ account.refresh!
192
+ ```
193
+
194
+ ### Warnings
195
+
196
+ 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).
197
+
198
+ ### Errors
199
+
200
+ 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`.
201
+
202
+ |Error|Status|
203
+ |---|---|
204
+ |APIError|*|
205
+ |BadRequestError|400|
206
+ |ParamRequiredError|400|
207
+ |InvalidRequestError|400|
208
+ |PersonalDetailsRequiredError|400|
209
+ |AuthenticationError|401|
210
+ |UnverifiedEmailError|401|
211
+ |InvalidTokenError|401|
212
+ |RevokedTokenError|401|
213
+ |ExpiredTokenError|401|
214
+ |TwoFactorRequiredError|402|
215
+ |InvalidScopeError|403|
216
+ |NotFoundError|404|
217
+ |ValidationError|422|
218
+ |RateLimitError|429|
219
+ |InternalServerError|500|
220
+ |ServiceUnavailableError|503|
221
+
222
+ ## Usage
223
+
224
+ 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).
225
+
226
+ ###[Market Data](https://developers.coinbase.com/api/v2#data-api)
227
+
228
+ **List supported native currencies**
229
+
230
+ ```ruby
231
+ client.currencies
232
+ ```
233
+
234
+ **List exchange rates**
235
+
236
+ ```ruby
237
+ client.exchange_rate
238
+ ```
239
+
240
+ **Buy price**
241
+
242
+ ```ruby
243
+ client.buy_price
244
+ ```
245
+
246
+ **Sell price**
247
+
248
+ ```ruby
249
+ client.sell_price
250
+ ```
251
+
252
+ **Spot price**
253
+
254
+ ```ruby
255
+ client.spot_price
256
+ ```
257
+
258
+ **Current server time**
259
+
260
+ ```ruby
261
+ client.time
262
+ ```
263
+
264
+ ###[Users](https://developers.coinbase.com/api/v2#users)
265
+
266
+ **Get authorization info**
267
+
268
+ ```ruby
269
+ client.auth_info
270
+ ```
271
+
272
+ **Lookup user info**
273
+
274
+ ```ruby
275
+ client.user(user_id)
276
+ ```
277
+
278
+ **Get current user**
279
+
280
+ ```ruby
281
+ client.current_user
282
+ ```
283
+
284
+ **Update current user**
285
+
286
+ ```ruby
287
+ client.update_current_user(name: "New Name")
288
+ ```
289
+
290
+ ###[Accounts](https://developers.coinbase.com/api/v2#accounts)
291
+
292
+ **List all accounts**
293
+
294
+ ```ruby
295
+ client.accounts
296
+ ```
297
+
298
+ **List account details**
299
+
300
+ ```ruby
301
+ client.account(account_id)
302
+ ```
303
+
304
+ **List primary account details**
305
+
306
+ ```ruby
307
+ client.primary_account
308
+ ```
309
+
310
+ **Set account as primary**
311
+
312
+ ```ruby
313
+ account.make_primary!
314
+ ```
315
+
316
+ **Create a new bitcoin account**
317
+
318
+ ```ruby
319
+ client.create_account(name: "New Account")
320
+ ```
321
+
322
+ **Update an account**
323
+
324
+ ```ruby
325
+ account.update!(name: "New Account Name")
326
+ ```
327
+
328
+ **Delete an account**
329
+
330
+ ```ruby
331
+ account.delete!
332
+ ```
333
+
334
+ ###[Addresses](https://developers.coinbase.com/api/v2#addresses)
335
+
336
+ **List receive addresses for account**
337
+
338
+ ```ruby
339
+ account.addresses
340
+ ```
341
+
342
+ **Get receive address info**
343
+
344
+ ```ruby
345
+ account.address(address_id)
346
+ ```
347
+
348
+ **List transactiona for address**
349
+
350
+ ```ruby
351
+ account.address_transactions(address_id)
352
+ ```
353
+
354
+ **Create a new receive address**
355
+
356
+ ```ruby
357
+ account.create_address
358
+ ```
359
+
360
+ ###[Transactions](https://developers.coinbase.com/api/v2#transactions)
361
+
362
+ **List transactions**
363
+
364
+ ```ruby
365
+ account.transactions
366
+ ```
367
+
368
+ **Get transaction info**
369
+
370
+ ```ruby
371
+ account.transaction(transaction_id)
372
+ ```
373
+
374
+ **Send funds**
375
+
376
+ ```ruby
377
+ account.send(to: <bitcoin address>, amount: "5.0", currency: "USD", description: "Your first bitcoin!")
378
+ ```
379
+
380
+ **Transfer funds to a new account**
381
+
382
+ ```ruby
383
+ account.transfer(to: <account ID>, amount: "1", currency: "BTC", description: "Your first bitcoin!")
384
+ ```
385
+
386
+ **Request funds**
387
+
388
+ ```ruby
389
+ account.request(to: <email>, amount: "8.0", currency: "USD", description: "Burrito")
390
+ ```
391
+
392
+ **Resend request**
393
+
394
+ ```ruby
395
+ account.resend_request(request_id)
396
+ ```
397
+
398
+ **Cancel request**
399
+
400
+ ```ruby
401
+ account.cancel_request(request_id)
402
+ ```
403
+
404
+ **Fulfill request**
405
+
406
+ ```ruby
407
+ account.complete_request(request_id)
408
+ ```
409
+
410
+ ###[Buys](https://developers.coinbase.com/api/v2#buys)
411
+
412
+ **List buys**
413
+
414
+ ```ruby
415
+ account.list_buys
416
+ ```
417
+
418
+ **Get buy info**
419
+
420
+ ```ruby
421
+ account.list_buy(buy_id)
422
+ ```
423
+
424
+ **Buy bitcoins**
425
+
426
+ ```ruby
427
+ account.buy(amount: "1", currency: "BTC")
428
+ ```
429
+
430
+ **Commit a buy**
431
+
432
+ You only need to do this if you pass `commit=true` when you call the buy method.
433
+
434
+ ```ruby
435
+ buy = account.buy(amount: "1", currency: "BTC", commit: false)
436
+ account.commit_buy(buy.id)
437
+ ```
438
+
439
+ ###[Sells](https://developers.coinbase.com/api/v2#sells)
440
+
441
+ **List sells**
442
+
443
+ ```ruby
444
+ account.list_sells
445
+ ```
446
+
447
+ **Get sell info**
448
+
449
+ ```ruby
450
+ account.list_sell(sell_id)
451
+ ```
452
+
453
+ **Sell bitcoins**
454
+
455
+ ```ruby
456
+ account.sell(amount: "1", currency: "BTC")
457
+ ```
458
+
459
+ **Commit a sell**
460
+
461
+ You only need to do this if you pass `commit=true` when you call the sell method.
462
+
463
+ ```ruby
464
+ sell = account.sell(amount: "1", currency: "BTC", commit: false)
465
+ account.commit_sell(sell.id)
466
+ ```
467
+
468
+ ###[Deposit](https://developers.coinbase.com/api/v2#deposits)
469
+
470
+ **List deposits**
471
+
472
+ ```ruby
473
+ account.list_deposits
474
+ ```
475
+
476
+ **Get deposit info**
477
+
478
+ ```ruby
479
+ account.list_deposit(deposit_id)
480
+ ```
481
+
482
+ **Deposit funds**
483
+
484
+ ```ruby
485
+ account.deposit(amount: "10", currency: "USD")
486
+ ```
487
+
488
+ **Commit a deposit**
489
+
490
+ You only need to do this if you pass `commit=true` when you call the deposit method.
491
+
492
+ ```ruby
493
+ deposit = account.deposit(amount: "1", currency: "BTC", commit: false)
494
+ account.commit_deposit(deposit.id)
495
+ ```
496
+
497
+ ###[Withdrawals](https://developers.coinbase.com/api/v2#withdrawals)
498
+
499
+ **List withdrawals**
500
+
501
+ ```ruby
502
+ account.list_withdrawals
503
+ ```
504
+
505
+ **Get withdrawal**
506
+
507
+ ```ruby
508
+ account.list_withdrawal(withdrawal_id)
509
+ ```
510
+
511
+ **Withdraw funds**
512
+
513
+ ```ruby
514
+ account.withdraw(amount: "10", currency: "USD")
515
+ ```
516
+
517
+ **Commit a withdrawal**
518
+
519
+ You only need to do this if you pass `commit=true` when you call the withdrawal method.
520
+
521
+ ```ruby
522
+ withdraw = account.withdraw(amount: "1", currency: "BTC", commit: false)
523
+ account.commit_withdrawal(withdrawal.id)
524
+ ```
525
+
526
+ ###[Payment Methods](https://developers.coinbase.com/api/v2#payment-methods)
527
+
528
+ **List payment methods**
529
+
530
+ ```ruby
531
+ client.payment_methods
532
+ ```
533
+
534
+ **Get payment method**
535
+
536
+ ```ruby
537
+ client.payment_method(payment_method_id)
538
+ ```
539
+
540
+ ###[Merchants](https://developers.coinbase.com/api/v2#merchants)
541
+
542
+ #### Get merchant
543
+
544
+ ```ruby
545
+ client.merchant(merchant_id)
546
+ ```
547
+
548
+ ###[Orders](https://developers.coinbase.com/api/v2#orders)
549
+
550
+ #### List orders
551
+
552
+ ```ruby
553
+ client.orders
554
+ ```
555
+
556
+ #### Get order
557
+
558
+ ```ruby
559
+ client.order(order_id)
560
+ ```
561
+
562
+ #### Create order
563
+
564
+ ```ruby
565
+ client.create_order(amount: "1", currency: "BTC", name: "Order #1234")
566
+ ```
567
+
568
+ #### Refund order
569
+
570
+ ```ruby
571
+ order = client.orders.first
572
+ order.refund!
573
+ ```
574
+
575
+ ### Checkouts
576
+
577
+ #### List checkouts
578
+
579
+ ```ruby
580
+ client.checkouts
581
+ ```
582
+
583
+ #### Get checkout
584
+
585
+ ```ruby
586
+ client.checkout(checkout_id)
587
+ ```
588
+
589
+ #### Get checkout's orders
590
+
591
+ ```ruby
592
+ checkout = client.checkout(checkout_id)
593
+ checkout.orders
594
+ ```
595
+
596
+ #### Create order for checkout
597
+
598
+ ```ruby
599
+ checkout = client.checkout(checkout_id)
600
+ checkout.create_order
601
+ ```
602
+
603
+ ## Contributing and testing
604
+
605
+ Any and all contributions are welcome! The process is simple: fork this repo, make your changes, add tests, run the test suite, and submit a pull request. Tests are run via rspec. To run the tests, clone the repository and then:
606
+
607
+ # Install the requirements
608
+ gem install coinbase
609
+
610
+ # Run tests
611
+ rspec spec
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
data/coinbase.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'coinbase/wallet/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "coinbase"
8
+ gem.version = Coinbase::Wallet::VERSION
9
+ gem.authors = ["John Duhamel", "Jori Lallo"]
10
+ gem.email = ["jjd@coinbase.com"]
11
+ gem.description = "Client library for Coinbase Wallet API v2"
12
+ gem.summary = "Client library for Coinbase Wallet API v2"
13
+ gem.homepage = "https://developers.coinbase.com/api/v2"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|gem|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency "bigdecimal"
21
+
22
+ gem.add_development_dependency "rake"
23
+ gem.add_development_dependency "rspec"
24
+ gem.add_development_dependency "webmock"
25
+ gem.add_development_dependency "timecop"
26
+ gem.add_development_dependency "pry"
27
+ end