bitget.rb 0.4.0 → 0.6.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.
- checksums.yaml +4 -4
- data/README.md +59 -0
- data/bitget.rb.gemspec +1 -1
- data/lib/Bitget/Configuration.rb +32 -0
- data/lib/Bitget/Error.rb +33 -1
- data/lib/Bitget/V2/Client.rb +1812 -48
- data/lib/Bitget/{VERSION.rb → VERSiON.rb} +1 -1
- data/lib/{bitget.rb → Bitget.rb} +2 -0
- data/test/Configuration_test.rb +87 -0
- data/test/V2/client_test.rb +1066 -44
- data/test/helper.rb +16 -2
- data/test/test_all.rb +2 -2
- metadata +7 -10
- data/lib/Bitget/V2/Client2.rb +0 -500
- data/lib/Hash/to_parameter_string.rb +0 -26
- data/lib/Hash/x_www_form_urlencode.rb +0 -7
- data/lib/Thoran/Hash/XWwwFormUrlencode/x_www_form_urlencode.rb +0 -26
- data/test/client_test.rb +0 -109
data/test/client_test.rb
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
require_relative './helper'
|
|
2
|
-
require_relative '../lib/Bitget/Client'
|
|
3
|
-
|
|
4
|
-
describe Bitget::Client do
|
|
5
|
-
let(:client) do
|
|
6
|
-
Bitget::Client.new(
|
|
7
|
-
api_key: ENV.fetch('BITGET_API_KEY', '<API_KEY>'),
|
|
8
|
-
api_secret: ENV.fetch('BITGET_API_SECRET', '<API_SECRET>'),
|
|
9
|
-
api_passphrase: ENV.fetch('BITGET_API_PASSPHRASE', '<API_PASSPHRASE>')
|
|
10
|
-
)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
describe "#spot_public_coins" do
|
|
14
|
-
context "when a coin is NOT supplied" do
|
|
15
|
-
it "retrieves a list of all coins" do
|
|
16
|
-
VCR.use_cassette('v2/spot/public/coins-when_coin_is_not_supplied') do
|
|
17
|
-
response = client.spot_public_coins
|
|
18
|
-
_(response).must_include('data')
|
|
19
|
-
_(response['data'].first).must_include('coinId')
|
|
20
|
-
_(response['data'].first).must_include('coin')
|
|
21
|
-
assert_operator response['data'].count, :>, 1500
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
context "when a coin IS supplied" do
|
|
27
|
-
it "retrieves one coin" do
|
|
28
|
-
VCR.use_cassette('v2/spot/public/coins-when_coin_is_supplied') do
|
|
29
|
-
response = client.spot_public_coins(coin: 'BTC')
|
|
30
|
-
_(response).must_include('data')
|
|
31
|
-
_(response['data'].first).must_include('coinId')
|
|
32
|
-
_(response['data'].first).must_include('coin')
|
|
33
|
-
_(response['data'].count).must_equal(1)
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
context "when an error occurs" do
|
|
39
|
-
it "logs then raises an error" do
|
|
40
|
-
VCR.use_cassette('v2/spot/public/coins-when_an_error_occurs') do
|
|
41
|
-
assert_raises(Bitget::Error) do
|
|
42
|
-
mocked_method = Minitest::Mock.new
|
|
43
|
-
mocked_method.expect(:call, nil, [], code: '418', message: "I'm a teapot", body: '')
|
|
44
|
-
client.stub(:log_error, mocked_method) do
|
|
45
|
-
client.spot_public_coins
|
|
46
|
-
end
|
|
47
|
-
mocked_method.verify
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
describe "#spot_account_info" do
|
|
55
|
-
it "retrieves account information" do
|
|
56
|
-
VCR.use_cassette('v2/spot/account/info') do
|
|
57
|
-
response = client.spot_account_info
|
|
58
|
-
_(response).must_include('data')
|
|
59
|
-
_(response['data']).must_include('userId')
|
|
60
|
-
_(response['data']).must_include('channelCode')
|
|
61
|
-
_(response['data']).must_include('authorities')
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
context "when an error occurs" do
|
|
66
|
-
it "logs then raises an error" do
|
|
67
|
-
VCR.use_cassette('v2/spot/account/info-when_an_error_occurs') do
|
|
68
|
-
assert_raises(Bitget::Error) do
|
|
69
|
-
mocked_method = Minitest::Mock.new
|
|
70
|
-
mocked_method.expect(:call, nil, [], code: '418', message: "I'm a teapot", body: '')
|
|
71
|
-
client.stub(:log_error, mocked_method) do
|
|
72
|
-
client.spot_account_info
|
|
73
|
-
end
|
|
74
|
-
mocked_method.verify
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
describe "#spot_account_assets" do
|
|
82
|
-
it "retrieves account assets" do
|
|
83
|
-
VCR.use_cassette('v2/spot/account/assets') do
|
|
84
|
-
response = client.spot_account_assets
|
|
85
|
-
_(response).must_include('data')
|
|
86
|
-
_(response['data'].first).must_include('coin')
|
|
87
|
-
_(response['data'].first).must_include('available')
|
|
88
|
-
_(response['data'].first).must_include('frozen')
|
|
89
|
-
_(response['data'].first).must_include('locked')
|
|
90
|
-
_(response['data'].first).must_include('uTime')
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
context "when an error occurs" do
|
|
95
|
-
it "logs then raises an error" do
|
|
96
|
-
VCR.use_cassette('v2/spot/account/assets-when_an_error_occurs') do
|
|
97
|
-
assert_raises(Bitget::Error) do
|
|
98
|
-
mocked_method = Minitest::Mock.new
|
|
99
|
-
mocked_method.expect(:call, nil, [], code: '418', message: "I'm a teapot", body: '')
|
|
100
|
-
client.stub(:log_error, mocked_method) do
|
|
101
|
-
client.spot_account_assets
|
|
102
|
-
end
|
|
103
|
-
mocked_method.verify
|
|
104
|
-
end
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
end
|