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.
- checksums.yaml +5 -5
- data/.gitignore +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +611 -0
- data/Rakefile +7 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/coinbase.gemspec +27 -0
- data/lib/coinbase/wallet/adapters/em_http.rb +78 -0
- data/lib/coinbase/wallet/adapters/net_http.rb +68 -0
- data/lib/coinbase/wallet/api_client.rb +692 -0
- data/lib/coinbase/wallet/api_errors.rb +120 -0
- data/lib/coinbase/wallet/api_response.rb +41 -0
- data/lib/coinbase/wallet/ca-coinbase.crt +629 -0
- data/lib/coinbase/wallet/client.rb +101 -0
- data/lib/coinbase/wallet/models/account.rb +187 -0
- data/lib/coinbase/wallet/models/address.rb +12 -0
- data/lib/coinbase/wallet/models/api_object.rb +46 -0
- data/lib/coinbase/wallet/models/checkout.rb +19 -0
- data/lib/coinbase/wallet/models/order.rb +12 -0
- data/lib/coinbase/wallet/models/transaction.rb +21 -0
- data/lib/coinbase/wallet/models/transfer.rb +13 -0
- data/lib/coinbase/wallet/models/user.rb +15 -0
- data/lib/coinbase/wallet/version.rb +5 -0
- data/lib/coinbase/wallet.rb +23 -156
- data/spec/account_spec.rb +193 -0
- data/spec/clients/client_spec.rb +34 -0
- data/spec/clients/oauth_client_spec.rb +56 -0
- data/spec/endpoints_spec.rb +352 -0
- data/spec/error_spec.rb +137 -0
- data/spec/models/address_spec.rb +26 -0
- data/spec/models/api_object_spec.rb +63 -0
- data/spec/models/checkout_spec.rb +52 -0
- data/spec/models/current_user_spec.rb +29 -0
- data/spec/models/order_spec.rb +52 -0
- data/spec/models/request_spec.rb +47 -0
- data/spec/models/transfer_spec.rb +64 -0
- data/spec/models/user_spec.rb +24 -0
- data/spec/spec_helper.rb +13 -0
- metadata +62 -98
- data/lib/coinbase/address.rb +0 -127
- data/lib/coinbase/asset.rb +0 -20
- data/lib/coinbase/balance_map.rb +0 -48
- data/lib/coinbase/constants.rb +0 -38
- data/lib/coinbase/network.rb +0 -55
- data/lib/coinbase/transfer.rb +0 -153
- data/lib/coinbase.rb +0 -18
@@ -0,0 +1,193 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Coinbase::Wallet::Account do
|
4
|
+
before :all do
|
5
|
+
@object_data = {
|
6
|
+
'id' => '2bbf394c-193b-5b2a-9155-3b4732659ede',
|
7
|
+
'name' => 'My Wallet',
|
8
|
+
'primary' => true,
|
9
|
+
'type' => 'wallet',
|
10
|
+
'currency' => 'BTC',
|
11
|
+
'balance' => {
|
12
|
+
'amount' => '39.59000000',
|
13
|
+
'currency' => 'BTC'
|
14
|
+
},
|
15
|
+
'native_balance' => {
|
16
|
+
'amount' => '395.90',
|
17
|
+
'currency' => 'USD'
|
18
|
+
},
|
19
|
+
'created_at' => '2015-01-31T20:49:02Z',
|
20
|
+
'updated_at' => '2015-01-31T20:49:02Z',
|
21
|
+
'resource' => 'account',
|
22
|
+
'resource_path' => '/v2/accounts/2bbf394c-193b-5b2a-9155-3b4732659ede'
|
23
|
+
}
|
24
|
+
|
25
|
+
@client = Coinbase::Wallet::Client.new(api_key: 'api_key', api_secret: 'api_secret')
|
26
|
+
@object = Coinbase::Wallet::Account.new(@client, @object_data)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "updates itself" do
|
30
|
+
ret = @object_data.clone
|
31
|
+
ret['name'] = 'new name'
|
32
|
+
stub_request(:put, /#{@object.resource_path}/)
|
33
|
+
.to_return(body: { data: ret }.to_json)
|
34
|
+
@object.update!(name: "new name")
|
35
|
+
expect(@object.name).to eq "new name"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "makes itself primary" do
|
39
|
+
stub_request(:post, /#{@object.resource_path}\/primary/)
|
40
|
+
.to_return(body: { data: mock_item }.to_json)
|
41
|
+
expect(@object.make_primary!).to eq mock_item
|
42
|
+
end
|
43
|
+
|
44
|
+
it "deletes itself" do
|
45
|
+
stub_request(:delete, /#{@object.resource_path}/)
|
46
|
+
.to_return(body: { data: mock_item }.to_json)
|
47
|
+
expect(@object.delete!).to eq mock_item
|
48
|
+
end
|
49
|
+
|
50
|
+
it "gets addresses" do
|
51
|
+
stub_request(:get, /#{@object.resource_path}\/addresses/)
|
52
|
+
.to_return(body: { data: mock_collection }.to_json)
|
53
|
+
expect(@object.addresses).to eq mock_collection
|
54
|
+
end
|
55
|
+
|
56
|
+
it "gets address" do
|
57
|
+
stub_request(:get, /#{@object.resource_path}\/addresses\/test/)
|
58
|
+
.to_return(body: { data: mock_item }.to_json)
|
59
|
+
expect(@object.address("test")).to eq mock_item
|
60
|
+
end
|
61
|
+
|
62
|
+
it "creates address" do
|
63
|
+
stub_request(:post, /#{@object.resource_path}\/addresses/)
|
64
|
+
.to_return(body: { data: mock_item }.to_json)
|
65
|
+
expect(@object.create_address).to eq mock_item
|
66
|
+
end
|
67
|
+
|
68
|
+
it "gets transactions" do
|
69
|
+
stub_request(:get, /#{@object.resource_path}\/transactions/)
|
70
|
+
.to_return(body: { data: mock_collection }.to_json)
|
71
|
+
expect(@object.transactions).to eq mock_collection
|
72
|
+
end
|
73
|
+
|
74
|
+
it "gets transaction" do
|
75
|
+
stub_request(:get, /#{@object.resource_path}\/transactions\/test/)
|
76
|
+
.to_return(body: { data: mock_item }.to_json)
|
77
|
+
expect(@object.transaction('test')).to eq mock_item
|
78
|
+
end
|
79
|
+
|
80
|
+
it "sends money" do
|
81
|
+
stub_request(:post, /#{@object.resource_path}\/transactions/)
|
82
|
+
.to_return(body: { data: mock_item }.to_json)
|
83
|
+
expect(@object.send(amount: 10, to: 'example@coinbase.com')).to eq mock_item
|
84
|
+
end
|
85
|
+
|
86
|
+
it "transfers money" do
|
87
|
+
stub_request(:post, /#{@object.resource_path}\/transactions/)
|
88
|
+
.to_return(body: { data: mock_item }.to_json)
|
89
|
+
expect(@object.transfer(amount: 10, to: 'example@coinbase.com')).to eq mock_item
|
90
|
+
end
|
91
|
+
|
92
|
+
it "requests money" do
|
93
|
+
stub_request(:post, /#{@object.resource_path}\/transactions/)
|
94
|
+
.to_return(body: { data: mock_item }.to_json)
|
95
|
+
expect(@object.request(amount: 10, currency: "BTC", to: 'example@coinbase.com')).to eq mock_item
|
96
|
+
end
|
97
|
+
|
98
|
+
it "gets buys" do
|
99
|
+
stub_request(:get, /#{@object.resource_path}\/buys/)
|
100
|
+
.to_return(body: { data: mock_collection }.to_json)
|
101
|
+
expect(@object.list_buys).to eq mock_collection
|
102
|
+
end
|
103
|
+
|
104
|
+
it "gets buy" do
|
105
|
+
stub_request(:get, /#{@object.resource_path}\/buys\/test/)
|
106
|
+
.to_return(body: { data: mock_item }.to_json)
|
107
|
+
expect(@object.list_buy('test')).to eq mock_item
|
108
|
+
end
|
109
|
+
|
110
|
+
it "buys bitcoin" do
|
111
|
+
stub_request(:post, /#{@object.resource_path}\/buys/)
|
112
|
+
.to_return(body: { data: mock_item }.to_json)
|
113
|
+
expect(@object.buy(amount: 10, currency: 'BTC')).to eq mock_item
|
114
|
+
end
|
115
|
+
|
116
|
+
it "commits buy" do
|
117
|
+
stub_request(:post, /#{@object.resource_path}\/buys\/test\/commit/)
|
118
|
+
.to_return(body: { data: mock_item }.to_json)
|
119
|
+
expect(@object.commit_buy("test")).to eq mock_item
|
120
|
+
end
|
121
|
+
|
122
|
+
it "gets sells" do
|
123
|
+
stub_request(:get, /#{@object.resource_path}\/sells/)
|
124
|
+
.to_return(body: { data: mock_collection }.to_json)
|
125
|
+
expect(@object.list_sells).to eq mock_collection
|
126
|
+
end
|
127
|
+
|
128
|
+
it "gets sell" do
|
129
|
+
stub_request(:get, /#{@object.resource_path}\/sells\/test/)
|
130
|
+
.to_return(body: { data: mock_item }.to_json)
|
131
|
+
expect(@object.list_sell('test')).to eq mock_item
|
132
|
+
end
|
133
|
+
|
134
|
+
it "sells bitcoin" do
|
135
|
+
stub_request(:post, /#{@object.resource_path}\/sells/)
|
136
|
+
.to_return(body: { data: mock_item }.to_json)
|
137
|
+
expect(@object.sell(amount: 10, currency: 'BTC')).to eq mock_item
|
138
|
+
end
|
139
|
+
|
140
|
+
it "commits sell" do
|
141
|
+
stub_request(:post, /#{@object.resource_path}\/sells\/test\/commit/)
|
142
|
+
.to_return(body: { data: mock_item }.to_json)
|
143
|
+
expect(@object.commit_sell("test")).to eq mock_item
|
144
|
+
end
|
145
|
+
|
146
|
+
it "gets deposits" do
|
147
|
+
stub_request(:get, /#{@object.resource_path}\/deposits/)
|
148
|
+
.to_return(body: { data: mock_collection }.to_json)
|
149
|
+
expect(@object.list_deposits).to eq mock_collection
|
150
|
+
end
|
151
|
+
|
152
|
+
it "gets deposit" do
|
153
|
+
stub_request(:get, /#{@object.resource_path}\/deposits\/test/)
|
154
|
+
.to_return(body: { data: mock_item }.to_json)
|
155
|
+
expect(@object.list_deposit('test')).to eq mock_item
|
156
|
+
end
|
157
|
+
|
158
|
+
it "deposits bitcoin" do
|
159
|
+
stub_request(:post, /#{@object.resource_path}\/deposits/)
|
160
|
+
.to_return(body: { data: mock_item }.to_json)
|
161
|
+
expect(@object.deposit(amount: 10, currency: 'BTC')).to eq mock_item
|
162
|
+
end
|
163
|
+
|
164
|
+
it "commits deposit" do
|
165
|
+
stub_request(:post, /#{@object.resource_path}\/deposits\/test\/commit/)
|
166
|
+
.to_return(body: { data: mock_item }.to_json)
|
167
|
+
expect(@object.commit_deposit("test")).to eq mock_item
|
168
|
+
end
|
169
|
+
|
170
|
+
it "gets withdrawals" do
|
171
|
+
stub_request(:get, /#{@object.resource_path}\/withdrawals/)
|
172
|
+
.to_return(body: { data: mock_collection }.to_json)
|
173
|
+
expect(@object.list_withdrawals).to eq mock_collection
|
174
|
+
end
|
175
|
+
|
176
|
+
it "gets withdrawal" do
|
177
|
+
stub_request(:get, /#{@object.resource_path}\/withdrawals\/test/)
|
178
|
+
.to_return(body: { data: mock_item }.to_json)
|
179
|
+
expect(@object.list_withdrawal('test')).to eq mock_item
|
180
|
+
end
|
181
|
+
|
182
|
+
it "withdrawals bitcoin" do
|
183
|
+
stub_request(:post, /#{@object.resource_path}\/withdrawals/)
|
184
|
+
.to_return(body: { data: mock_item }.to_json)
|
185
|
+
expect(@object.withdraw(amount: 10, currency: 'BTC')).to eq mock_item
|
186
|
+
end
|
187
|
+
|
188
|
+
it "commits withdrawal" do
|
189
|
+
stub_request(:post, /#{@object.resource_path}\/withdrawals\/test\/commit/)
|
190
|
+
.to_return(body: { data: mock_item }.to_json)
|
191
|
+
expect(@object.commit_withdrawal("test")).to eq mock_item
|
192
|
+
end
|
193
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'timecop'
|
3
|
+
|
4
|
+
describe Coinbase::Wallet::Client do
|
5
|
+
let(:client) { Coinbase::Wallet::Client.new(api_key: 'api_key', api_secret: 'api_secret') }
|
6
|
+
|
7
|
+
it 'supplies correct headers' do
|
8
|
+
time = Time.utc(2015, 7, 1, 0, 0, 0)
|
9
|
+
timestamp = 1435708800
|
10
|
+
|
11
|
+
stub_request(:get, 'https://api.coinbase.com/v2/user')
|
12
|
+
.with('headers' => {
|
13
|
+
'CB-ACCESS-KEY' => 'api_key',
|
14
|
+
'CB-ACCESS-SIGN' => '9a413abc5a25a949932cd2b9963906d543f2df935c3a56159e24edb2095d78ee',
|
15
|
+
'CB-ACCESS-TIMESTAMP' => timestamp.to_s,
|
16
|
+
'CB-VERSION' => Coinbase::Wallet::API_VERSION,
|
17
|
+
})
|
18
|
+
.to_return(body: { data: mock_item }.to_json)
|
19
|
+
|
20
|
+
stub_request(:post, 'https://api.coinbase.com/v2/accounts')
|
21
|
+
.with('headers' => {
|
22
|
+
'CB-ACCESS-KEY' => 'api_key',
|
23
|
+
'CB-ACCESS-SIGN' => '3d4a73da32fc7fa55862865efd60c0cc994e5616d138a3c3b605a3ed504b235c',
|
24
|
+
'CB-ACCESS-TIMESTAMP' => timestamp,
|
25
|
+
'CB-VERSION' => Coinbase::Wallet::API_VERSION,
|
26
|
+
})
|
27
|
+
.to_return(body: { data: mock_item }.to_json)
|
28
|
+
|
29
|
+
Timecop.freeze(time) do
|
30
|
+
expect { client.current_user }.to_not raise_error
|
31
|
+
expect { client.create_account(name: "new wallet") }.to_not raise_error
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Coinbase::Wallet::OAuthClient do
|
4
|
+
let(:client) { Coinbase::Wallet::OAuthClient.new(access_token: 'access_token', refresh_token: 'refresh_token') }
|
5
|
+
|
6
|
+
it 'handles init with access token and refresh token' do
|
7
|
+
stub_request(:get, /.*/)
|
8
|
+
.with('headers' => {
|
9
|
+
'Authorization' => 'Bearer access_token',
|
10
|
+
'CB-VERSION' => Coinbase::Wallet::API_VERSION,
|
11
|
+
})
|
12
|
+
.to_return(body: { data: { id: 'id', resource: 'user',
|
13
|
+
resource_path: '/v2/user' } }.to_json,
|
14
|
+
status: 200)
|
15
|
+
|
16
|
+
expect { client.current_user }.to_not raise_error
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'handles init with access token' do
|
20
|
+
stub_request(:get, /.*/)
|
21
|
+
.to_return(body: { data: { id: 'id', resource: 'user',
|
22
|
+
resource_path: '/v2/user' } }.to_json,
|
23
|
+
status: 200)
|
24
|
+
|
25
|
+
client = Coinbase::Wallet::OAuthClient.new(access_token: 'access_token')
|
26
|
+
expect { client.current_user }.to_not raise_error
|
27
|
+
end
|
28
|
+
|
29
|
+
it '#refresh!' do
|
30
|
+
body = {
|
31
|
+
'access_token' => 'new_access_token',
|
32
|
+
'token_type'=> 'bearer',
|
33
|
+
'expires_in'=> 7200,
|
34
|
+
'refresh_token'=> 'new_refresh_token',
|
35
|
+
'scope'=> 'wallet:user:read'
|
36
|
+
}
|
37
|
+
|
38
|
+
stub_request(:post, 'https://api.coinbase.com/oauth/token')
|
39
|
+
.with(body: {
|
40
|
+
grant_type: 'refresh_token',
|
41
|
+
refresh_token: 'refresh_token'
|
42
|
+
})
|
43
|
+
.to_return(body: body.to_json, status: 200)
|
44
|
+
|
45
|
+
expect(client.refresh!).to eq body
|
46
|
+
expect(client.access_token).to eq 'new_access_token'
|
47
|
+
expect(client.refresh_token).to eq 'new_refresh_token'
|
48
|
+
end
|
49
|
+
|
50
|
+
it '#revoke!' do
|
51
|
+
stub_request(:post, "https://api.coinbase.com/oauth/revoke")
|
52
|
+
.with(body: { token: 'access_token' })
|
53
|
+
.to_return(body: mock_item.to_json)
|
54
|
+
expect(client.revoke!).to eq mock_item
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,352 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Coinbase::Wallet do
|
4
|
+
before :all do
|
5
|
+
@client = Coinbase::Wallet::Client.new(api_key: 'api_key', api_secret: 'api_secret')
|
6
|
+
end
|
7
|
+
|
8
|
+
#
|
9
|
+
# Data API
|
10
|
+
#
|
11
|
+
it "gets currencies" do
|
12
|
+
stub_request(:get, "https://api.coinbase.com/v2/currencies")
|
13
|
+
.to_return(body: { data: mock_collection }.to_json)
|
14
|
+
expect(@client.currencies).to eq mock_collection
|
15
|
+
end
|
16
|
+
|
17
|
+
it "gets exchange rates" do
|
18
|
+
stub_request(:get, "https://api.coinbase.com/v2/exchange-rates")
|
19
|
+
.to_return(body: { data: mock_collection }.to_json)
|
20
|
+
expect(@client.exchange_rates).to eq mock_collection
|
21
|
+
end
|
22
|
+
|
23
|
+
it "gets buy price" do
|
24
|
+
stub_request(:get, "https://api.coinbase.com/v2/prices/buy")
|
25
|
+
.to_return(body: { data: mock_item }.to_json)
|
26
|
+
expect(@client.buy_price).to eq mock_item
|
27
|
+
end
|
28
|
+
|
29
|
+
it "gets sell price" do
|
30
|
+
stub_request(:get, "https://api.coinbase.com/v2/prices/sell")
|
31
|
+
.to_return(body: { data: mock_item }.to_json)
|
32
|
+
expect(@client.sell_price).to eq mock_item
|
33
|
+
end
|
34
|
+
|
35
|
+
it "gets spot price" do
|
36
|
+
stub_request(:get, "https://api.coinbase.com/v2/prices/spot")
|
37
|
+
.to_return(body: { data: mock_item }.to_json)
|
38
|
+
expect(@client.spot_price).to eq mock_item
|
39
|
+
end
|
40
|
+
|
41
|
+
it "gets time" do
|
42
|
+
stub_request(:get, "https://api.coinbase.com/v2/time")
|
43
|
+
.to_return(body: { data: mock_item }.to_json)
|
44
|
+
expect(@client.time).to eq mock_item
|
45
|
+
end
|
46
|
+
|
47
|
+
#
|
48
|
+
# Wallet API
|
49
|
+
#
|
50
|
+
it "gets user" do
|
51
|
+
stub_request(:get, "https://api.coinbase.com/v2/users/test")
|
52
|
+
.to_return(body: { data: mock_item }.to_json)
|
53
|
+
expect(@client.user('test')).to eq mock_item
|
54
|
+
end
|
55
|
+
|
56
|
+
it "gets current user" do
|
57
|
+
stub_request(:get, "https://api.coinbase.com/v2/user")
|
58
|
+
.to_return(body: { data: mock_item }.to_json)
|
59
|
+
expect(@client.current_user).to eq mock_item
|
60
|
+
end
|
61
|
+
|
62
|
+
it "gets authorization info" do
|
63
|
+
stub_request(:get, "https://api.coinbase.com/v2/user/auth")
|
64
|
+
.to_return(body: { data: mock_item }.to_json)
|
65
|
+
expect(@client.auth_info).to eq mock_item
|
66
|
+
end
|
67
|
+
|
68
|
+
it "updates current user" do
|
69
|
+
stub_request(:put, "https://api.coinbase.com/v2/user")
|
70
|
+
.to_return(body: { data: mock_item }.to_json)
|
71
|
+
expect(@client.update_current_user(name: "test")).to eq mock_item
|
72
|
+
end
|
73
|
+
|
74
|
+
it "gets accounts" do
|
75
|
+
stub_request(:get, "https://api.coinbase.com/v2/accounts")
|
76
|
+
.to_return(body: { data: mock_collection }.to_json)
|
77
|
+
expect(@client.accounts).to eq mock_collection
|
78
|
+
end
|
79
|
+
|
80
|
+
it "gets account" do
|
81
|
+
stub_request(:get, "https://api.coinbase.com/v2/accounts/test")
|
82
|
+
.to_return(body: { data: mock_item }.to_json)
|
83
|
+
expect(@client.account("test")).to eq mock_item
|
84
|
+
end
|
85
|
+
|
86
|
+
it "gets account" do
|
87
|
+
stub_request(:get, "https://api.coinbase.com/v2/accounts/primary")
|
88
|
+
.to_return(body: { data: mock_item }.to_json)
|
89
|
+
expect(@client.primary_account).to eq mock_item
|
90
|
+
end
|
91
|
+
|
92
|
+
it "creates account" do
|
93
|
+
stub_request(:post, "https://api.coinbase.com/v2/accounts")
|
94
|
+
.to_return(body: { data: mock_item }.to_json)
|
95
|
+
expect(@client.create_account).to eq mock_item
|
96
|
+
end
|
97
|
+
|
98
|
+
it "changes primary account" do
|
99
|
+
stub_request(:post, "https://api.coinbase.com/v2/accounts/test/primary")
|
100
|
+
.to_return(body: { data: mock_item }.to_json)
|
101
|
+
expect(@client.set_primary_account("test")).to eq mock_item
|
102
|
+
end
|
103
|
+
|
104
|
+
it "updates accounts" do
|
105
|
+
stub_request(:put, "https://api.coinbase.com/v2/accounts/test")
|
106
|
+
.to_return(body: { data: mock_item }.to_json)
|
107
|
+
expect(@client.update_account("test", name: "new name")).to eq mock_item
|
108
|
+
end
|
109
|
+
|
110
|
+
it "deletes accounts" do
|
111
|
+
stub_request(:delete, "https://api.coinbase.com/v2/accounts/test")
|
112
|
+
.to_return(body: { data: mock_item }.to_json)
|
113
|
+
expect(@client.delete_account("test")).to eq mock_item
|
114
|
+
end
|
115
|
+
|
116
|
+
it "gets addresses" do
|
117
|
+
stub_request(:get, "https://api.coinbase.com/v2/accounts/test/addresses")
|
118
|
+
.to_return(body: { data: mock_collection }.to_json)
|
119
|
+
expect(@client.addresses("test")).to eq mock_collection
|
120
|
+
end
|
121
|
+
|
122
|
+
it "gets address" do
|
123
|
+
stub_request(:get, "https://api.coinbase.com/v2/accounts/test1/addresses/test2")
|
124
|
+
.to_return(body: { data: mock_item }.to_json)
|
125
|
+
expect(@client.address("test1", "test2")).to eq mock_item
|
126
|
+
end
|
127
|
+
|
128
|
+
it "gets address transactions" do
|
129
|
+
stub_request(:get, "https://api.coinbase.com/v2/accounts/test1/addresses/test2/transactions")
|
130
|
+
.to_return(body: { data: mock_collection }.to_json)
|
131
|
+
expect(@client.address_transactions("test1", "test2")).to eq mock_collection
|
132
|
+
end
|
133
|
+
|
134
|
+
it "creates address" do
|
135
|
+
stub_request(:post, "https://api.coinbase.com/v2/accounts/test1/addresses")
|
136
|
+
.to_return(body: { data: mock_item }.to_json)
|
137
|
+
expect(@client.create_address("test1")).to eq mock_item
|
138
|
+
end
|
139
|
+
|
140
|
+
it "gets transactions" do
|
141
|
+
stub_request(:get, "https://api.coinbase.com/v2/accounts/test/transactions")
|
142
|
+
.to_return(body: { data: mock_collection }.to_json)
|
143
|
+
expect(@client.transactions("test")).to eq mock_collection
|
144
|
+
end
|
145
|
+
|
146
|
+
it "gets transaction" do
|
147
|
+
stub_request(:get, "https://api.coinbase.com/v2/accounts/test1/transactions/test2")
|
148
|
+
.to_return(body: { data: mock_item }.to_json)
|
149
|
+
expect(@client.transaction("test1", "test2")).to eq mock_item
|
150
|
+
end
|
151
|
+
|
152
|
+
it "sends money" do
|
153
|
+
stub_request(:post, "https://api.coinbase.com/v2/accounts/test/transactions")
|
154
|
+
.to_return(body: { data: mock_item }.to_json)
|
155
|
+
expect(@client.send("test", amount: 10, to: 'example@coinbase.com')).to eq mock_item
|
156
|
+
end
|
157
|
+
|
158
|
+
it "transfers money" do
|
159
|
+
stub_request(:post, "https://api.coinbase.com/v2/accounts/test/transactions")
|
160
|
+
.to_return(body: { data: mock_item }.to_json)
|
161
|
+
expect(@client.transfer("test", amount: 10, to: 'example@coinbase.com')).to eq mock_item
|
162
|
+
end
|
163
|
+
|
164
|
+
it "requests money" do
|
165
|
+
stub_request(:post, "https://api.coinbase.com/v2/accounts/test/transactions")
|
166
|
+
.to_return(body: { data: mock_item }.to_json)
|
167
|
+
expect(@client.request("test", amount: 10, currency: 'BTC', to: 'example@coinbase.com')).to eq mock_item
|
168
|
+
end
|
169
|
+
|
170
|
+
it "completes request" do
|
171
|
+
stub_request(:post, "https://api.coinbase.com/v2/accounts/test1/transactions/test2/complete")
|
172
|
+
.to_return(body: { data: mock_item }.to_json)
|
173
|
+
expect(@client.complete_request("test1", "test2")).to eq mock_item
|
174
|
+
end
|
175
|
+
|
176
|
+
it "re-sends request" do
|
177
|
+
stub_request(:post, "https://api.coinbase.com/v2/accounts/test1/transactions/test2/resend")
|
178
|
+
.to_return(body: { data: mock_item }.to_json)
|
179
|
+
expect(@client.resend_request("test1", "test2")).to eq mock_item
|
180
|
+
end
|
181
|
+
|
182
|
+
it "cancels request" do
|
183
|
+
stub_request(:delete, "https://api.coinbase.com/v2/accounts/test1/transactions/test2")
|
184
|
+
.to_return(body: { data: mock_item }.to_json)
|
185
|
+
expect(@client.cancel_request("test1", "test2")).to eq mock_item
|
186
|
+
end
|
187
|
+
|
188
|
+
it "lists buys" do
|
189
|
+
stub_request(:get, "https://api.coinbase.com/v2/accounts/test/buys")
|
190
|
+
.to_return(body: { data: mock_collection }.to_json)
|
191
|
+
expect(@client.list_buys("test")).to eq mock_collection
|
192
|
+
end
|
193
|
+
|
194
|
+
it "lists buy" do
|
195
|
+
stub_request(:get, "https://api.coinbase.com/v2/accounts/test1/buys/test2")
|
196
|
+
.to_return(body: { data: mock_item }.to_json)
|
197
|
+
expect(@client.list_buy("test1", "test2")).to eq mock_item
|
198
|
+
end
|
199
|
+
|
200
|
+
it "buys bitcoin" do
|
201
|
+
stub_request(:post, "https://api.coinbase.com/v2/accounts/test/buys")
|
202
|
+
.to_return(body: { data: mock_item }.to_json)
|
203
|
+
expect(@client.buy("test", amount: 10, currency: 'BTC')).to eq mock_item
|
204
|
+
end
|
205
|
+
|
206
|
+
it "commits buy" do
|
207
|
+
stub_request(:post, "https://api.coinbase.com/v2/accounts/test1/buys/test2/commit")
|
208
|
+
.to_return(body: { data: mock_item }.to_json)
|
209
|
+
expect(@client.commit_buy("test1", "test2")).to eq mock_item
|
210
|
+
end
|
211
|
+
|
212
|
+
it "lists sells" do
|
213
|
+
stub_request(:get, "https://api.coinbase.com/v2/accounts/test/sells")
|
214
|
+
.to_return(body: { data: mock_collection }.to_json)
|
215
|
+
expect(@client.list_sells("test")).to eq mock_collection
|
216
|
+
end
|
217
|
+
|
218
|
+
it "lists sell" do
|
219
|
+
stub_request(:get, "https://api.coinbase.com/v2/accounts/test1/sells/test2")
|
220
|
+
.to_return(body: { data: mock_item }.to_json)
|
221
|
+
expect(@client.list_sell("test1", "test2")).to eq mock_item
|
222
|
+
end
|
223
|
+
|
224
|
+
it "sells bitcoin" do
|
225
|
+
stub_request(:post, "https://api.coinbase.com/v2/accounts/test/sells")
|
226
|
+
.to_return(body: { data: mock_item }.to_json)
|
227
|
+
expect(@client.sell("test", amount: 10, currency: 'BTC')).to eq mock_item
|
228
|
+
end
|
229
|
+
|
230
|
+
it "commits sell" do
|
231
|
+
stub_request(:post, "https://api.coinbase.com/v2/accounts/test1/sells/test2/commit")
|
232
|
+
.to_return(body: { data: mock_item }.to_json)
|
233
|
+
expect(@client.commit_sell("test1", "test2")).to eq mock_item
|
234
|
+
end
|
235
|
+
|
236
|
+
it "lists deposits" do
|
237
|
+
stub_request(:get, "https://api.coinbase.com/v2/accounts/test/deposits")
|
238
|
+
.to_return(body: { data: mock_collection }.to_json)
|
239
|
+
expect(@client.list_deposits("test")).to eq mock_collection
|
240
|
+
end
|
241
|
+
|
242
|
+
it "lists deposit" do
|
243
|
+
stub_request(:get, "https://api.coinbase.com/v2/accounts/test1/deposits/test2")
|
244
|
+
.to_return(body: { data: mock_item }.to_json)
|
245
|
+
expect(@client.list_deposit("test1", "test2")).to eq mock_item
|
246
|
+
end
|
247
|
+
|
248
|
+
it "deposits bitcoin" do
|
249
|
+
stub_request(:post, "https://api.coinbase.com/v2/accounts/test/deposits")
|
250
|
+
.to_return(body: { data: mock_item }.to_json)
|
251
|
+
expect(@client.deposit("test", amount: 10, currency: 'BTC')).to eq mock_item
|
252
|
+
end
|
253
|
+
|
254
|
+
it "commits deposit" do
|
255
|
+
stub_request(:post, "https://api.coinbase.com/v2/accounts/test1/deposits/test2/commit")
|
256
|
+
.to_return(body: { data: mock_item }.to_json)
|
257
|
+
expect(@client.commit_deposit("test1", "test2")).to eq mock_item
|
258
|
+
end
|
259
|
+
|
260
|
+
it "lists withdrawals" do
|
261
|
+
stub_request(:get, "https://api.coinbase.com/v2/accounts/test/withdrawals")
|
262
|
+
.to_return(body: { data: mock_collection }.to_json)
|
263
|
+
expect(@client.list_withdrawals("test")).to eq mock_collection
|
264
|
+
end
|
265
|
+
|
266
|
+
it "lists withdrawal" do
|
267
|
+
stub_request(:get, "https://api.coinbase.com/v2/accounts/test1/withdrawals/test2")
|
268
|
+
.to_return(body: { data: mock_item }.to_json)
|
269
|
+
expect(@client.list_withdrawal("test1", "test2")).to eq mock_item
|
270
|
+
end
|
271
|
+
|
272
|
+
it "withdrawals bitcoin" do
|
273
|
+
stub_request(:post, "https://api.coinbase.com/v2/accounts/test/withdrawals")
|
274
|
+
.to_return(body: { data: mock_item }.to_json)
|
275
|
+
expect(@client.withdraw("test", amount: 10, currency: 'BTC')).to eq mock_item
|
276
|
+
end
|
277
|
+
|
278
|
+
it "commits withdrawal" do
|
279
|
+
stub_request(:post, "https://api.coinbase.com/v2/accounts/test1/withdrawals/test2/commit")
|
280
|
+
.to_return(body: { data: mock_item }.to_json)
|
281
|
+
expect(@client.commit_withdrawal("test1", "test2")).to eq mock_item
|
282
|
+
end
|
283
|
+
|
284
|
+
it "gets payment methods" do
|
285
|
+
stub_request(:get, "https://api.coinbase.com/v2/payment-methods")
|
286
|
+
.to_return(body: { data: mock_collection }.to_json)
|
287
|
+
expect(@client.payment_methods).to eq mock_collection
|
288
|
+
end
|
289
|
+
|
290
|
+
#
|
291
|
+
# Merchant API
|
292
|
+
#
|
293
|
+
it "gets merchant" do
|
294
|
+
stub_request(:get, "https://api.coinbase.com/v2/merchants/test")
|
295
|
+
.to_return(body: { data: mock_item }.to_json)
|
296
|
+
expect(@client.merchant('test')).to eq mock_item
|
297
|
+
end
|
298
|
+
|
299
|
+
it "gets merchant orders" do
|
300
|
+
stub_request(:get, "https://api.coinbase.com/v2/orders")
|
301
|
+
.to_return(body: { data: mock_collection }.to_json)
|
302
|
+
expect(@client.orders).to eq mock_collection
|
303
|
+
end
|
304
|
+
|
305
|
+
it "gets merchant order" do
|
306
|
+
stub_request(:get, "https://api.coinbase.com/v2/orders/test")
|
307
|
+
.to_return(body: { data: mock_item }.to_json)
|
308
|
+
expect(@client.order("test")).to eq mock_item
|
309
|
+
end
|
310
|
+
|
311
|
+
it "creates an order" do
|
312
|
+
stub_request(:post, "https://api.coinbase.com/v2/orders")
|
313
|
+
.to_return(body: { data: mock_item }.to_json)
|
314
|
+
expect(@client.create_order(name: "test", amount: 10, currency: "BTC")).to eq mock_item
|
315
|
+
end
|
316
|
+
|
317
|
+
it "refunds merchant order" do
|
318
|
+
stub_request(:post, "https://api.coinbase.com/v2/orders/test/refund")
|
319
|
+
.to_return(body: { data: mock_item }.to_json)
|
320
|
+
expect(@client.refund_order("test", currency: "BTC")).to eq mock_item
|
321
|
+
end
|
322
|
+
|
323
|
+
it "gets checkouts" do
|
324
|
+
stub_request(:get, "https://api.coinbase.com/v2/checkouts")
|
325
|
+
.to_return(body: { data: mock_collection }.to_json)
|
326
|
+
expect(@client.checkouts).to eq mock_collection
|
327
|
+
end
|
328
|
+
|
329
|
+
it "gets checkout" do
|
330
|
+
stub_request(:get, "https://api.coinbase.com/v2/checkouts/test")
|
331
|
+
.to_return(body: { data: mock_item }.to_json)
|
332
|
+
expect(@client.checkout("test")).to eq mock_item
|
333
|
+
end
|
334
|
+
|
335
|
+
it "creates checkout" do
|
336
|
+
stub_request(:post, "https://api.coinbase.com/v2/checkouts")
|
337
|
+
.to_return(body: { data: mock_item }.to_json)
|
338
|
+
expect(@client.create_checkout(name: "test", amount: 10, currency: "BTC")).to eq mock_item
|
339
|
+
end
|
340
|
+
|
341
|
+
it "gets checkout orders" do
|
342
|
+
stub_request(:get, "https://api.coinbase.com/v2/checkouts/test/orders")
|
343
|
+
.to_return(body: { data: mock_collection }.to_json)
|
344
|
+
expect(@client.checkout_orders("test")).to eq mock_collection
|
345
|
+
end
|
346
|
+
|
347
|
+
it "creates checkout order" do
|
348
|
+
stub_request(:post, "https://api.coinbase.com/v2/checkouts/test/orders")
|
349
|
+
.to_return(body: { data: mock_item }.to_json)
|
350
|
+
expect(@client.create_checkout_order("test")).to eq mock_item
|
351
|
+
end
|
352
|
+
end
|