bitfex 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile.lock +2 -2
- data/lib/bitfex/api.rb +14 -2
- data/lib/bitfex/version.rb +1 -1
- data/test/test_bitfex.rb +6 -6
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a830e2f527b5de4456a1469cfc9bee9f36f8c8e1b8498dbbd8600dd485af5e35
|
4
|
+
data.tar.gz: 204ae8dc2394a689920f29b2fedd7c33662661de5f43d4bbb2eba8689677e6b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1a3ffa111c05e0a68832aaa77e858b90e653e83f3229ab9cccd07ad8407284bdb5fab264aba258273653e85dbcb26b3c2298444f32a40b0c60b3427c8644c64
|
7
|
+
data.tar.gz: 614f6d40384b812c38c2bca832243dd8d35d46826a057000315e3eb92fbc45708d3c593c3d492743dab99fbaf1b578d2062bc932f8db94b0de7d3e63652f9866
|
data/Gemfile.lock
CHANGED
data/lib/bitfex/api.rb
CHANGED
@@ -6,8 +6,10 @@ module Bitfex
|
|
6
6
|
attr_accessor :token
|
7
7
|
|
8
8
|
# @param server_url [String] URL of the main server
|
9
|
-
|
9
|
+
# @param auth_server_url [String] URL of the auth server
|
10
|
+
def initialize(server_url: 'https://bitfex.trade', auth_server_url: 'https://auth.bitfex.trade')
|
10
11
|
@_server_url = server_url
|
12
|
+
@_auth_server_url = auth_server_url
|
11
13
|
end
|
12
14
|
|
13
15
|
# @return [String] server url
|
@@ -15,11 +17,21 @@ module Bitfex
|
|
15
17
|
@_server_url
|
16
18
|
end
|
17
19
|
|
20
|
+
# @return [String] auth server url
|
21
|
+
def auth_server_url
|
22
|
+
@_auth_server_url
|
23
|
+
end
|
24
|
+
|
18
25
|
# @param url [String] set URL of the server
|
19
26
|
def server_url=(url)
|
20
27
|
@_server_url = url
|
21
28
|
end
|
22
29
|
|
30
|
+
# @param url [String] set URL of the auth server
|
31
|
+
def auth_server_url=(url)
|
32
|
+
@_auth_server_url = url
|
33
|
+
end
|
34
|
+
|
23
35
|
# Get token for API operations
|
24
36
|
# @param email [String] email
|
25
37
|
# @param password [String] password
|
@@ -100,7 +112,7 @@ module Bitfex
|
|
100
112
|
end
|
101
113
|
|
102
114
|
def request(endpoint, klass, body = nil)
|
103
|
-
url = @_server_url + endpoint
|
115
|
+
url = (body && body.has_key?(:auth) ? @_auth_server_url : @_server_url) + endpoint
|
104
116
|
uri = URI.parse(url)
|
105
117
|
http = Net::HTTP.new(uri.host, uri.port)
|
106
118
|
http.use_ssl = uri.port == 443
|
data/lib/bitfex/version.rb
CHANGED
data/test/test_bitfex.rb
CHANGED
@@ -20,7 +20,7 @@ class BitfexTest < Minitest::Test
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def test_auth_success
|
23
|
-
stub_request(:post, 'https://bitfex.trade/auth')
|
23
|
+
stub_request(:post, 'https://auth.bitfex.trade/auth')
|
24
24
|
.with(body: '{"auth":{"email":"user@example.com","password":"123"}}')
|
25
25
|
.to_return(status: 200, body: '{"jwt":"token"}')
|
26
26
|
|
@@ -29,7 +29,7 @@ class BitfexTest < Minitest::Test
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_auth_failure
|
32
|
-
stub_request(:post, 'https://bitfex.trade/auth')
|
32
|
+
stub_request(:post, 'https://auth.bitfex.trade/auth')
|
33
33
|
.with(body: '{"auth":{"email":"user@example.com","password":"123"}}')
|
34
34
|
.to_return(status: 404, body: '{}')
|
35
35
|
|
@@ -62,24 +62,24 @@ class BitfexTest < Minitest::Test
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def test_orders_list_success
|
65
|
-
stub_request(:get, "https://bitfex.trade/api/v1/orders")
|
65
|
+
stub_request(:get, "https://bitfex.trade/api/v1/orders?pair=BTC_RUR")
|
66
66
|
.with(headers: { 'Authorization' => 'Bearer 123' })
|
67
67
|
.to_return(status: 200, body: '{"success":true,"orders":[{"id":1}]}')
|
68
68
|
|
69
69
|
client = Bitfex::Api.new
|
70
70
|
client.token = '123'
|
71
|
-
assert_equal([{'id' => 1}], client.orders_list)
|
71
|
+
assert_equal([{'id' => 1}], client.orders_list('BTC_RUR'))
|
72
72
|
end
|
73
73
|
|
74
74
|
def test_orders_list_faulure
|
75
|
-
stub_request(:get, "https://bitfex.trade/api/v1/orders")
|
75
|
+
stub_request(:get, "https://bitfex.trade/api/v1/orders?pair=BTC_RUR")
|
76
76
|
.with(headers: { 'Authorization' => 'Bearer 123' })
|
77
77
|
.to_return(status: 403, body: '{"success":false,"errors":["TEST"]}')
|
78
78
|
|
79
79
|
assert_raises Bitfex::ApiError do
|
80
80
|
client = Bitfex::Api.new
|
81
81
|
client.token = '123'
|
82
|
-
client.orders_list
|
82
|
+
client.orders_list('BTC_RUR')
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitfex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- BitFex.Trade
|
@@ -79,8 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: '0'
|
81
81
|
requirements: []
|
82
|
-
|
83
|
-
rubygems_version: 2.5.2.1
|
82
|
+
rubygems_version: 3.0.3
|
84
83
|
signing_key:
|
85
84
|
specification_version: 4
|
86
85
|
summary: API wrapper for BitFex.Trade
|