coinbase 0.0.1 → 4.0.7
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.
- 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
data/spec/error_spec.rb
ADDED
@@ -0,0 +1,137 @@
|
|
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
|
+
it "passes" do
|
9
|
+
expect(1).to eq(1)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "handles param_required" do
|
13
|
+
stub_request(:get, /.*/)
|
14
|
+
.to_return(body: { errors: [{ id: 'param_required', message: 'test' }] }.to_json,
|
15
|
+
status: 400)
|
16
|
+
expect { @client.primary_account }.to raise_error Coinbase::Wallet::ParamRequiredError
|
17
|
+
end
|
18
|
+
|
19
|
+
it "handles invalid_request" do
|
20
|
+
stub_request(:get, /.*/)
|
21
|
+
.to_return(body: { errors: [{ id: 'invalid_request', message: 'test' }] }.to_json,
|
22
|
+
status: 400)
|
23
|
+
expect { @client.primary_account }.to raise_error Coinbase::Wallet::InvalidRequestError
|
24
|
+
end
|
25
|
+
|
26
|
+
it "handles personal_details_required" do
|
27
|
+
stub_request(:get, /.*/)
|
28
|
+
.to_return(body: { errors: [{ id: 'personal_details_required', message: 'test' }] }.to_json,
|
29
|
+
status: 400)
|
30
|
+
expect { @client.primary_account }.to raise_error Coinbase::Wallet::PersonalDetailsRequiredError
|
31
|
+
end
|
32
|
+
|
33
|
+
it "handles obscure 400" do
|
34
|
+
stub_request(:get, /.*/)
|
35
|
+
.to_return(body: { errors: [{ id: 'obscure_400', message: 'test' }] }.to_json,
|
36
|
+
status: 400)
|
37
|
+
expect { @client.primary_account }.to raise_error Coinbase::Wallet::BadRequestError
|
38
|
+
end
|
39
|
+
|
40
|
+
it "handles authentication_error" do
|
41
|
+
stub_request(:get, /.*/)
|
42
|
+
.to_return(body: { errors: [{ id: 'authentication_error', message: 'test' }] }.to_json,
|
43
|
+
status: 401)
|
44
|
+
expect { @client.primary_account }.to raise_error Coinbase::Wallet::AuthenticationError
|
45
|
+
end
|
46
|
+
|
47
|
+
it "handles unverified_email" do
|
48
|
+
stub_request(:get, /.*/)
|
49
|
+
.to_return(body: { errors: [{ id: 'unverified_email', message: 'test' }] }.to_json,
|
50
|
+
status: 401)
|
51
|
+
expect { @client.primary_account }.to raise_error Coinbase::Wallet::UnverifiedEmailError
|
52
|
+
end
|
53
|
+
|
54
|
+
it "handles invalid_token" do
|
55
|
+
stub_request(:get, /.*/)
|
56
|
+
.to_return(body: { errors: [{ id: 'invalid_token', message: 'test' }] }.to_json,
|
57
|
+
status: 401)
|
58
|
+
expect { @client.primary_account }.to raise_error Coinbase::Wallet::InvalidTokenError
|
59
|
+
end
|
60
|
+
|
61
|
+
it "handles revoked_token" do
|
62
|
+
stub_request(:get, /.*/)
|
63
|
+
.to_return(body: { errors: [{ id: 'revoked_token', message: 'test' }] }.to_json,
|
64
|
+
status: 401)
|
65
|
+
expect { @client.primary_account }.to raise_error Coinbase::Wallet::RevokedTokenError
|
66
|
+
end
|
67
|
+
|
68
|
+
it "handles expired_token" do
|
69
|
+
stub_request(:get, /.*/)
|
70
|
+
.to_return(body: { errors: [{ id: 'expired_token', message: 'test' }] }.to_json,
|
71
|
+
status: 401)
|
72
|
+
expect { @client.primary_account }.to raise_error Coinbase::Wallet::ExpiredTokenError
|
73
|
+
end
|
74
|
+
|
75
|
+
it "handles obscure 401" do
|
76
|
+
stub_request(:get, /.*/)
|
77
|
+
.to_return(body: { errors: [{ id: 'obscure_401', message: 'test' }] }.to_json,
|
78
|
+
status: 401)
|
79
|
+
expect { @client.primary_account }.to raise_error Coinbase::Wallet::AuthenticationError
|
80
|
+
end
|
81
|
+
|
82
|
+
it "handles 402" do
|
83
|
+
stub_request(:get, /.*/)
|
84
|
+
.to_return(body: { errors: [{ id: '402', message: 'test' }] }.to_json,
|
85
|
+
status: 402)
|
86
|
+
expect { @client.primary_account }.to raise_error Coinbase::Wallet::TwoFactorRequiredError
|
87
|
+
end
|
88
|
+
|
89
|
+
it "handles 403" do
|
90
|
+
stub_request(:get, /.*/)
|
91
|
+
.to_return(body: { errors: [{ id: '403', message: 'test' }] }.to_json,
|
92
|
+
status: 403)
|
93
|
+
expect { @client.primary_account }.to raise_error Coinbase::Wallet::InvalidScopeError
|
94
|
+
end
|
95
|
+
|
96
|
+
it "handles 404" do
|
97
|
+
stub_request(:get, /.*/)
|
98
|
+
.to_return(body: { errors: [{ id: '404', message: 'test' }] }.to_json,
|
99
|
+
status: 404)
|
100
|
+
expect { @client.primary_account }.to raise_error Coinbase::Wallet::NotFoundError
|
101
|
+
end
|
102
|
+
|
103
|
+
it "handles 422" do
|
104
|
+
stub_request(:get, /.*/)
|
105
|
+
.to_return(body: { errors: [{ id: '422', message: 'test' }] }.to_json,
|
106
|
+
status: 422)
|
107
|
+
expect { @client.primary_account }.to raise_error Coinbase::Wallet::ValidationError
|
108
|
+
end
|
109
|
+
|
110
|
+
it "handles 429" do
|
111
|
+
stub_request(:get, /.*/)
|
112
|
+
.to_return(body: { errors: [{ id: '429', message: 'test' }] }.to_json,
|
113
|
+
status: 429)
|
114
|
+
expect { @client.primary_account }.to raise_error Coinbase::Wallet::RateLimitError
|
115
|
+
end
|
116
|
+
|
117
|
+
it "handles 500" do
|
118
|
+
stub_request(:get, /.*/)
|
119
|
+
.to_return(body: { errors: [{ id: '500', message: 'test' }] }.to_json,
|
120
|
+
status: 500)
|
121
|
+
expect { @client.primary_account }.to raise_error Coinbase::Wallet::InternalServerError
|
122
|
+
end
|
123
|
+
|
124
|
+
it "handles 503" do
|
125
|
+
stub_request(:get, /.*/)
|
126
|
+
.to_return(body: { errors: [{ id: '503', message: 'test' }] }.to_json,
|
127
|
+
status: 503)
|
128
|
+
expect { @client.primary_account }.to raise_error Coinbase::Wallet::ServiceUnavailableError
|
129
|
+
end
|
130
|
+
|
131
|
+
it "handles oauth exception" do
|
132
|
+
stub_request(:get, /.*/)
|
133
|
+
.to_return(body: { error: "invalid_request", error_description: "test"}.to_json,
|
134
|
+
status: 401)
|
135
|
+
expect { @client.primary_account }.to raise_error Coinbase::Wallet::APIError
|
136
|
+
end
|
137
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Coinbase::Wallet::Address do
|
4
|
+
before :all do
|
5
|
+
@object_data = {
|
6
|
+
'id' => 'dd3183eb-af1d-5f5d-a90d-cbff946435ff',
|
7
|
+
'address' => 'mswUGcPHp1YnkLCgF1TtoryqSc5E9Q8xFa',
|
8
|
+
'name' => 'One off payment',
|
9
|
+
'created_at' => '2015-01-31T20:49:02Z',
|
10
|
+
'updated_at' => '2015-03-31T17:25:29-07:00',
|
11
|
+
'resource' => 'address',
|
12
|
+
'resource_path' => '/v2/accounts/2bbf394c-193b-5b2a-9155-3b4732659ede/addresses/dd3183eb-af1d-5f5d-a90d-cbff946435ff'
|
13
|
+
}
|
14
|
+
|
15
|
+
@client = Coinbase::Wallet::Client.new(api_key: 'api_key', api_secret: 'api_secret')
|
16
|
+
@object = Coinbase::Wallet::Address.new(@client, @object_data)
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#transactions' do
|
20
|
+
it 'should get latest transactions for address' do
|
21
|
+
stub_request(:get, 'https://api.coinbase.com' + @object_data['resource_path'] + '/transactions')
|
22
|
+
.to_return(body: { data: [mock_item] }.to_json)
|
23
|
+
expect(@object.transactions).to eq [mock_item]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Coinbase::Wallet::APIObject 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::APIObject.new(@client, @object_data)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should access attributes' do
|
30
|
+
expect(@object.id).to eq @object_data['id']
|
31
|
+
expect(@object.balance.currency).to eq @object_data['balance']['currency']
|
32
|
+
expect(@object.primary).to eq @object_data['primary']
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should convert hashes to APIObjects' do
|
36
|
+
expect(@object.balance.class).to eq Coinbase::Wallet::APIObject
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should convert amounts to BigDecimal' do
|
40
|
+
expect(@object.balance.amount.class).to eq BigDecimal
|
41
|
+
expect(@object.native_balance.amount.to_f).to eq 395.90
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should convert timestamps to Time' do
|
45
|
+
expect(@object.created_at.class).to eq Time
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#update' do
|
49
|
+
it 'should update object' do
|
50
|
+
@object.update({'id' => '1234'})
|
51
|
+
expect(@object.id).to eq '1234'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#refresh!' do
|
56
|
+
it 'should fetch new data for object' do
|
57
|
+
stub_request(:get, 'https://api.coinbase.com' + @object_data['resource_path'])
|
58
|
+
.to_return(body: { data: { id: 'new_id' } }.to_json)
|
59
|
+
@object.refresh!
|
60
|
+
expect(@object.id).to eq 'new_id'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Coinbase::Wallet::Checkout do
|
4
|
+
before :all do
|
5
|
+
@object_data = {
|
6
|
+
'id' => 'ffc93ba1-874d-5c55-853c-53c9c4814b1e',
|
7
|
+
'embed_code' => 'af0b52802ad7b36806e307b2d294e3b4',
|
8
|
+
'type' => 'order',
|
9
|
+
'name' => 'My Checkout',
|
10
|
+
'description' => nil,
|
11
|
+
'amount' => {
|
12
|
+
'amount' => '99.00000000',
|
13
|
+
'currency' => 'BTC'
|
14
|
+
},
|
15
|
+
'style' => 'buy_now_large',
|
16
|
+
'customer_defined_amount' => false,
|
17
|
+
'amount_presets' => [],
|
18
|
+
'success_url' => nil,
|
19
|
+
'cancel_url' => nil,
|
20
|
+
'info_url' => nil,
|
21
|
+
'auto_redirect' => false,
|
22
|
+
'collect_shipping_address' => false,
|
23
|
+
'collect_email' => false,
|
24
|
+
'collect_phone_number' => false,
|
25
|
+
'collect_country' => false,
|
26
|
+
'metadata' => {},
|
27
|
+
'created_at' => '2015-01-31T20:49:02Z',
|
28
|
+
'updated_at' => '2015-01-31T20:49:02Z',
|
29
|
+
'resource' => 'checkout',
|
30
|
+
'resource_path' => '/v2/checkouts/ffc93ba1-874d-5c55-853c-53c9c4814b1e'
|
31
|
+
}
|
32
|
+
|
33
|
+
@client = Coinbase::Wallet::Client.new(api_key: 'api_key', api_secret: 'api_secret')
|
34
|
+
@object = Coinbase::Wallet::Checkout.new(@client, @object_data)
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#orders' do
|
38
|
+
it 'should get latest order' do
|
39
|
+
stub_request(:get, 'https://api.coinbase.com' + @object_data['resource_path'] + '/orders')
|
40
|
+
.to_return(body: { data: [mock_item] }.to_json)
|
41
|
+
expect(@object.orders).to eq [mock_item]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#create_order' do
|
46
|
+
it 'should create a new order' do
|
47
|
+
stub_request(:post, 'https://api.coinbase.com' + @object_data['resource_path'] + '/orders')
|
48
|
+
.to_return(body: { data: mock_item }.to_json)
|
49
|
+
expect(@object.create_order).to eq mock_item
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Coinbase::Wallet::CurrentUser do
|
4
|
+
before :all do
|
5
|
+
@user_data = {
|
6
|
+
'id' => '9da7a204-544e-5fd1-9a12-61176c5d4cd8',
|
7
|
+
'name' => 'User One',
|
8
|
+
'username' => 'user1',
|
9
|
+
'profile_location' => nil,
|
10
|
+
'profile_bio' => nil,
|
11
|
+
'profile_url' => 'https://coinbase.com/user1',
|
12
|
+
'avatar_url' => 'https://images.coinbase.com/avatar?h=vR%2FY8igBoPwuwGren5JMwvDNGpURAY%2F0nRIOgH%2FY2Qh%2BQ6nomR3qusA%2Bh6o2%0Af9rH&s=128',
|
13
|
+
'resource' => 'user',
|
14
|
+
'resource_path' => '/v2/user'
|
15
|
+
}
|
16
|
+
|
17
|
+
@client = Coinbase::Wallet::Client.new(api_key: 'api_key', api_secret: 'api_secret')
|
18
|
+
@user = Coinbase::Wallet::CurrentUser.new(@client, @user_data)
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#update!' do
|
22
|
+
it 'should update new data for object' do
|
23
|
+
stub_request(:put, 'https://api.coinbase.com' + @user_data['resource_path'])
|
24
|
+
.to_return(body: { data: { name: 'james smith' } }.to_json)
|
25
|
+
@user.update!(name: 'james smith')
|
26
|
+
expect(@user.name).to eq 'james smith'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Coinbase::Wallet::Order do
|
4
|
+
before :all do
|
5
|
+
@object_data = {
|
6
|
+
'id' => '0fdfb26e-bd26-5e1c-b055-7b935e57fa33',
|
7
|
+
'code' => '66BEOV2A',
|
8
|
+
'status' => 'paid',
|
9
|
+
'type' => 'order',
|
10
|
+
'name' => 'Order #123',
|
11
|
+
'description' => 'Sample order',
|
12
|
+
'amount' => {
|
13
|
+
'amount' => '10.00',
|
14
|
+
'currency' => 'USD'
|
15
|
+
},
|
16
|
+
'payout_amount' => nil,
|
17
|
+
'bitcoin_address' => 'mymZkiXhQNd6VWWG7VGSVdDX9bKmviti3U',
|
18
|
+
'bitcoin_amount' => {
|
19
|
+
'amount' => '1.00000000',
|
20
|
+
'currency' => 'BTC'
|
21
|
+
},
|
22
|
+
'bitcoin_uri' => 'bitcoin:mrNo5ntJfWP8BGjR2MkAxEgoE8NDu4CM3g?amount=1.00&r=https://www.coinbase.com/r/555b9570a54d75860e00041d',
|
23
|
+
'receipt_url' => 'https://www.coinbase.com/orders/d5d3e516dae19ca5b444fe56405ee917/receipt',
|
24
|
+
'expires_at' => '2015-01-31T20:49:02Z',
|
25
|
+
'mispaid_at' => nil,
|
26
|
+
'paid_at' => '2015-01-31T20:49:02Z',
|
27
|
+
'refund_address' => 'n3z9tkPHcMcUwGBbyjipT1RxJ3qXK4CKNQ',
|
28
|
+
'transaction' => {
|
29
|
+
'id' => 'aee1de26-9d08-56bf-8c51-7f8e6a23e046',
|
30
|
+
'resource' => 'transaction'
|
31
|
+
},
|
32
|
+
'refunds' => [],
|
33
|
+
'mispayments' => [],
|
34
|
+
'metadata' => {},
|
35
|
+
'created_at' => '2015-01-31T20:49:02Z',
|
36
|
+
'updated_at' => '2015-01-31T20:49:02Z',
|
37
|
+
'resource' => 'order',
|
38
|
+
'resource_path' => '/v2/orders/0fdfb26e-bd26-5e1c-b055-7b935e57fa33'
|
39
|
+
}
|
40
|
+
|
41
|
+
@client = Coinbase::Wallet::Client.new(api_key: 'api_key', api_secret: 'api_secret')
|
42
|
+
@object = Coinbase::Wallet::Order.new(@client, @object_data)
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#refund!' do
|
46
|
+
it 'should refund an order' do
|
47
|
+
stub_request(:post, 'https://api.coinbase.com' + @object_data['resource_path'] + '/refund')
|
48
|
+
.to_return(body: { data: mock_item }.to_json)
|
49
|
+
expect(@object.refund!).to eq mock_item
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Coinbase::Wallet::Request do
|
4
|
+
before :all do
|
5
|
+
@object_data = {
|
6
|
+
"id" => "2e9f48cd-0b05-5f7c-9056-17a8acb408ad",
|
7
|
+
"type" => "request",
|
8
|
+
"status" => "pending",
|
9
|
+
"amount" => {
|
10
|
+
"amount" => "1.00000000",
|
11
|
+
"currency" => "BTC"
|
12
|
+
},
|
13
|
+
"native_amount" => {
|
14
|
+
"amount" => "10.00",
|
15
|
+
"currency" => "USD"
|
16
|
+
},
|
17
|
+
"description" => nil,
|
18
|
+
"created_at" => "2015-04-01T10:37:11-07:00",
|
19
|
+
"updated_at" => "2015-04-01T10:37:11-07:00",
|
20
|
+
"resource" => "transaction",
|
21
|
+
"resource_path" => "/v2/accounts/2bbf394c-193b-5b2a-9155-3b4732659ede/transactions/2e9f48cd-0b05-5f7c-9056-17a8acb408ad",
|
22
|
+
"to" => {
|
23
|
+
"resource" => "email",
|
24
|
+
"email" => "email@example.com"
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
@client = Coinbase::Wallet::Client.new(api_key: 'api_key', api_secret: 'api_secret')
|
29
|
+
@object = Coinbase::Wallet::Request.new(@client, @object_data)
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#resend!' do
|
33
|
+
it 'should resend an order' do
|
34
|
+
stub_request(:post, 'https://api.coinbase.com' + @object_data['resource_path'] + '/resend')
|
35
|
+
.to_return(body: { data: mock_item }.to_json)
|
36
|
+
expect(@object.resend!).to eq mock_item
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#cancel!' do
|
41
|
+
it 'should cancel an order' do
|
42
|
+
stub_request(:delete, 'https://api.coinbase.com' + @object_data['resource_path'])
|
43
|
+
.to_return(body: { data: mock_item }.to_json)
|
44
|
+
expect(@object.cancel!).to eq mock_item
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Coinbase::Wallet::Transfer do
|
4
|
+
before :all do
|
5
|
+
@object_data = {
|
6
|
+
'id' => '67e0eaec-07d7-54c4-a72c-2e92826897df',
|
7
|
+
'status' => 'pending',
|
8
|
+
'payment_method' => {
|
9
|
+
'id' => '83562370-3e5c-51db-87da-752af5ab9559',
|
10
|
+
'resource' => 'payment_method'
|
11
|
+
},
|
12
|
+
'transaction' => {
|
13
|
+
'id' => '441b9494-b3f0-5b98-b9b0-4d82c21c252a',
|
14
|
+
'resource' => 'transaction'
|
15
|
+
},
|
16
|
+
'amount' => {
|
17
|
+
'amount' => '1.00000000',
|
18
|
+
'currency' => 'BTC'
|
19
|
+
},
|
20
|
+
'total' => {
|
21
|
+
'amount' => '10.25',
|
22
|
+
'currency' => 'USD'
|
23
|
+
},
|
24
|
+
'subtotal' => {
|
25
|
+
'amount' => '10.10',
|
26
|
+
'currency' => 'USD'
|
27
|
+
},
|
28
|
+
'created_at' => '2015-01-31T20:49:02Z',
|
29
|
+
'updated_at' => '2015-01-31T20:49:02Z',
|
30
|
+
'resource' => 'buy',
|
31
|
+
'resource_path' => '/v2/accounts/2bbf394c-193b-5b2a-9155-3b4732659ede/buys/67e0eaec-07d7-54c4-a72c-2e92826897df',
|
32
|
+
'committed' => false,
|
33
|
+
'instant' => false,
|
34
|
+
'fees' => [
|
35
|
+
{
|
36
|
+
'type' => 'coinbase',
|
37
|
+
'amount' => {
|
38
|
+
'amount' => '0.00',
|
39
|
+
'currency' => 'USD'
|
40
|
+
}
|
41
|
+
},
|
42
|
+
{
|
43
|
+
'type' => 'bank',
|
44
|
+
'amount' => {
|
45
|
+
'amount' => '0.15',
|
46
|
+
'currency' => 'USD'
|
47
|
+
}
|
48
|
+
}
|
49
|
+
],
|
50
|
+
'payout_at' => '2015-02-18T16 =>54 =>00-08 =>00'
|
51
|
+
}
|
52
|
+
|
53
|
+
@client = Coinbase::Wallet::Client.new(api_key: 'api_key', api_secret: 'api_secret')
|
54
|
+
@object = Coinbase::Wallet::Transfer.new(@client, @object_data)
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#commit!' do
|
58
|
+
it 'should commit an transfer (buy/sell/deposit/withdrawal)' do
|
59
|
+
stub_request(:post, 'https://api.coinbase.com' + @object_data['resource_path'] + '/commit')
|
60
|
+
.to_return(body: { data: mock_item }.to_json)
|
61
|
+
expect(@object.commit!).to eq mock_item
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Coinbase::Wallet::User do
|
4
|
+
before :all do
|
5
|
+
@user_data = {
|
6
|
+
'id' => '9da7a204-544e-5fd1-9a12-61176c5d4cd8',
|
7
|
+
'name' => 'User One',
|
8
|
+
'username' => 'user1',
|
9
|
+
'profile_location' => nil,
|
10
|
+
'profile_bio' => nil,
|
11
|
+
'profile_url' => 'https://coinbase.com/user1',
|
12
|
+
'avatar_url' => 'https://images.coinbase.com/avatar?h=vR%2FY8igBoPwuwGren5JMwvDNGpURAY%2F0nRIOgH%2FY2Qh%2BQ6nomR3qusA%2Bh6o2%0Af9rH&s=128',
|
13
|
+
'resource' => 'user',
|
14
|
+
'resource_path' => '/v2/user/9da7a204-544e-5fd1-9a12-61176c5d4cd8'
|
15
|
+
}
|
16
|
+
|
17
|
+
@client = Coinbase::Wallet::Client.new(api_key: 'api_key', api_secret: 'api_secret')
|
18
|
+
@user = Coinbase::Wallet::User.new(@client, @user_data)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should access attributes' do
|
22
|
+
expect(@user.id).to eq @user_data['id']
|
23
|
+
end
|
24
|
+
end
|