quadrigacx 0.2.0 → 0.3.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/lib/quadrigacx/client/private.rb +7 -0
- data/lib/quadrigacx/request.rb +16 -8
- data/lib/quadrigacx/version.rb +1 -1
- data/spec/client_spec.rb +12 -0
- data/spec/fixtures/vcr_cassettes/open_orders.yml +55 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc8881657cf901eefb21ed54c54106ffddf60564
|
4
|
+
data.tar.gz: f5ebdac616ec2f58aeae685fa3c97ba9569a3d49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f34f6662e7b5b554d63ba7230f8aa7071981f4806897fa412f720b49ff56b501ee1577ea32b2dd2374c41858f206f0d03d213254dd6e3fd1db291877fc7f2df
|
7
|
+
data.tar.gz: da33fb780b5b17e8e8bb8f64975844e84866edd3df8ec717b9f4670de4afdfa3a8215bc3952f3f48e5a028bfbd5313d403453a4029521f9413f4d3677e26815c
|
@@ -48,5 +48,12 @@ module QuadrigaCX
|
|
48
48
|
def withdraw params={}
|
49
49
|
request(:post, '/bitcoin_withdrawal', params)
|
50
50
|
end
|
51
|
+
|
52
|
+
# Returns a JSON list of open orders
|
53
|
+
#
|
54
|
+
# book - optional, if not specified, will default to btc_cad
|
55
|
+
def open_orders params={}
|
56
|
+
request(:post, '/open_orders', params)
|
57
|
+
end
|
51
58
|
end
|
52
59
|
end
|
data/lib/quadrigacx/request.rb
CHANGED
@@ -12,24 +12,21 @@ module QuadrigaCX
|
|
12
12
|
|
13
13
|
protected
|
14
14
|
|
15
|
-
def request
|
15
|
+
def request *args
|
16
16
|
resp = @use_hmac ? self.hmac_request(*args) : self.oauth_request(*args)
|
17
17
|
|
18
18
|
begin
|
19
|
-
|
19
|
+
json = JSON.parse(resp.body)
|
20
20
|
|
21
21
|
# The `/cancel_order` route returns `"true"` instead of valid JSON.
|
22
22
|
rescue JSON::ParserError
|
23
23
|
return resp.body
|
24
24
|
end
|
25
25
|
|
26
|
-
|
27
|
-
raise Error.new(hash.errors.join(',')) if hash.errors
|
28
|
-
|
29
|
-
hash
|
26
|
+
json.kind_of?(Array) ? json.map { |i| to_hashie(i) } : to_hashie(json)
|
30
27
|
end
|
31
28
|
|
32
|
-
def hmac_request
|
29
|
+
def hmac_request http_method, path, body={}
|
33
30
|
raise 'API key, API secret and client ID required!' unless @api_key && @api_secret && @client_id
|
34
31
|
|
35
32
|
secret = Digest::MD5.hexdigest(@api_secret)
|
@@ -64,7 +61,18 @@ module QuadrigaCX
|
|
64
61
|
# body - Parameters for requests - GET and POST
|
65
62
|
#
|
66
63
|
# TODO(maros): Implement this when QuadrigaCX supports it.
|
67
|
-
def oauth_request
|
64
|
+
def oauth_request http_method, path, body={}
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def to_hashie json
|
70
|
+
hash = Hashie::Mash.new(json)
|
71
|
+
|
72
|
+
raise Error.new(hash.error) if hash.error
|
73
|
+
raise Error.new(hash.errors.join(',')) if hash.errors
|
74
|
+
|
75
|
+
hash
|
68
76
|
end
|
69
77
|
end
|
70
78
|
end
|
data/lib/quadrigacx/version.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -93,5 +93,17 @@ describe QuadrigaCX::Client do
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
end
|
96
|
+
|
97
|
+
describe '#open_orders' do
|
98
|
+
it 'lists open orders' do
|
99
|
+
VCR.use_cassette('open_orders') do
|
100
|
+
response = client.open_orders
|
101
|
+
|
102
|
+
expect(response.first.datetime).not_to be_nil
|
103
|
+
expect(response.first.price).not_to be_nil
|
104
|
+
expect(response.first.type).not_to be_nil
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
96
108
|
end
|
97
109
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://api.quadrigacx.com/v2/open_orders
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"key":"kOnVDjfPPh","nonce":"1421786664595","signature":"ee6b7b9dc80c3f3c95f02930472eb937d0ae05eda4ab218a52c81a7b6f90a56c"}'
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/json
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
Content-Type:
|
15
|
+
- application/json
|
16
|
+
Content-Length:
|
17
|
+
- '123'
|
18
|
+
User-Agent:
|
19
|
+
- Ruby
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Server:
|
26
|
+
- cloudflare-nginx
|
27
|
+
Date:
|
28
|
+
- Tue, 20 Jan 2015 20:44:25 GMT
|
29
|
+
Content-Type:
|
30
|
+
- application/json; charset=utf-8
|
31
|
+
Transfer-Encoding:
|
32
|
+
- chunked
|
33
|
+
Connection:
|
34
|
+
- keep-alive
|
35
|
+
Set-Cookie:
|
36
|
+
- __cfduid=dba0826eb668158f88deccccf4be4da081421786665; expires=Wed, 20-Jan-16
|
37
|
+
20:44:25 GMT; path=/; domain=.quadrigacx.com; HttpOnly
|
38
|
+
- ci_session=ADkFMQdjVG4FKlskA2YFNFczBDsAIgMlVTABdgYkAjwAMwc4AF4PaQE9Un4DaVEiD2FcYwNuUGpQJgU0DGhSMFcxBGMDN1cyWzBVZlU2ADgAYAVtBzRUNQVlW2cDbwU8V2cEMQA2AzBVZgE2BjYCYwBpBzIANQ9lAThSfgNpUSIPYVxhA2xQalAmBWkMfFJYVzYEZAM2V3JbYlV3VScALQBjBXgHbFRlBWJbbQN%2BBTRXNAQ5AC4DYFVmASsGZgJhAHIHZAAwDzYBe1JnAyFRaw9qXGADZlByUHEFcwxpUnVXCARhAzVXZVtpVXBVdgA0ACsFMQdiVG4Fc1sFAykFZ1d6BCMAOwMlVW8BNAZkAm8Afgc6AGAPcwEtUgMDM1EyDy9cOQMqUDlQcAV5DC5SPFc%2BBDoDY1c0WzVVNVVjADcAbgU9B2BUYQVqWyQDZgU8VzkEIwB1AyVVMAF3BggCMQA9ByIAYA8iAWJSLwNoUWEPYVxyA35Qa1B5;
|
39
|
+
expires=Tue, 20-Jan-2015 22:44:25 GMT; Max-Age=7200; path=/
|
40
|
+
X-Frame-Options:
|
41
|
+
- SAMEORIGIN
|
42
|
+
Cf-Ray:
|
43
|
+
- 1abe1c2481ea0534-YYZ
|
44
|
+
Content-Encoding:
|
45
|
+
- gzip
|
46
|
+
body:
|
47
|
+
encoding: ASCII-8BIT
|
48
|
+
string: !binary |-
|
49
|
+
H4sIAAAAAAAAAxyOyw6CMBQFf8WcNZDbFrrorxgXpbwqVoq9UI3x3w2c7Uwy
|
50
|
+
5/qFDcv2ZBhQRYLOoUBnuWcfehhIEk1JopR0kcLUtZGH4DsYDL6eaNljmPZR
|
51
|
+
uXdotc7CqUeenNxtajkzz/Gu9RBsmrNaFaVBdW5e+5F02lAgvrw7K42qznJi
|
52
|
+
y1s6/qAAf+IBCb/bHwAA//8DAFwvkRirAAAA
|
53
|
+
http_version:
|
54
|
+
recorded_at: Tue, 20 Jan 2015 20:44:24 GMT
|
55
|
+
recorded_with: VCR 2.9.3
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quadrigacx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maros Hluska
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -135,6 +135,7 @@ files:
|
|
135
135
|
- spec/fixtures/vcr_cassettes/limit_buy.yml
|
136
136
|
- spec/fixtures/vcr_cassettes/limit_sell.yml
|
137
137
|
- spec/fixtures/vcr_cassettes/market_buy.yml
|
138
|
+
- spec/fixtures/vcr_cassettes/open_orders.yml
|
138
139
|
- spec/fixtures/vcr_cassettes/order_book.yml
|
139
140
|
- spec/fixtures/vcr_cassettes/withdraw.yml
|
140
141
|
- spec/spec_helper.rb
|
@@ -169,6 +170,7 @@ test_files:
|
|
169
170
|
- spec/fixtures/vcr_cassettes/limit_buy.yml
|
170
171
|
- spec/fixtures/vcr_cassettes/limit_sell.yml
|
171
172
|
- spec/fixtures/vcr_cassettes/market_buy.yml
|
173
|
+
- spec/fixtures/vcr_cassettes/open_orders.yml
|
172
174
|
- spec/fixtures/vcr_cassettes/order_book.yml
|
173
175
|
- spec/fixtures/vcr_cassettes/withdraw.yml
|
174
176
|
- spec/spec_helper.rb
|