quovo 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/quovo/request.rb +16 -25
- data/lib/quovo/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 398cce62ff51e5d66813740023fe251d1c5facdc
|
4
|
+
data.tar.gz: e129102cd9c3df882b2a586716a0ad8ecb559514
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 839329cd6df5ed129db2c97afb94b8771155a45bf11a993117d4181cab20c09f5697bb8135770db629f0a926e5a6c7a2b683fc3273848068bb4227a2f0c8dbba
|
7
|
+
data.tar.gz: 000b8cab076fd0ae5b988471b2246868845eaf3520f8aff402eec8177464fbc6190be876613dc74641377802c90de763ad9654613e179b9a63274b1de2cc3388
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
### v1.0.3
|
2
|
+
[FIX] Pass params to url for api GET requests.
|
3
|
+
|
4
|
+
### v1.0.2
|
5
|
+
[FIX] Do not process body (convert to json) if HTTP status is bad.
|
6
|
+
|
7
|
+
### v1.0.1
|
8
|
+
[FEATURE] First release includes bindings for users, brokerages, accounts, challenges, portfolios, positions and history apis.
|
data/lib/quovo/request.rb
CHANGED
@@ -5,7 +5,8 @@ module Quovo
|
|
5
5
|
def request(method, path, params = {}, format = :plain, config = Quovo.config)
|
6
6
|
return fake_request(method, path, params, &Proc.new) if Quovo.fake?
|
7
7
|
|
8
|
-
|
8
|
+
uri = build_uri(config.endpoint, method, path, params)
|
9
|
+
request = build_http_request(uri, method, params)
|
9
10
|
|
10
11
|
yield(request) if block_given?
|
11
12
|
|
@@ -24,21 +25,15 @@ module Quovo
|
|
24
25
|
|
25
26
|
protected
|
26
27
|
|
27
|
-
def
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
Net::HTTP::Delete
|
37
|
-
else
|
38
|
-
raise Quovo::HttpError, 'unsupported method'
|
39
|
-
end.new(URI(endpoint + path))
|
40
|
-
|
41
|
-
inject_http_params(request, method, params) if params.any?
|
28
|
+
def build_uri(endpoint, method, path, params)
|
29
|
+
get_params = '?' + URI.encode_www_form(params) if method == :get && params.any?
|
30
|
+
URI(endpoint + path + (get_params || ''))
|
31
|
+
end
|
32
|
+
|
33
|
+
def build_http_request(uri, method, params)
|
34
|
+
raise Quovo::HttpError, 'unsupported method' unless [:get, :post, :put, :delete].include?(method)
|
35
|
+
request = Kernel.const_get("Net::HTTP::#{method.to_s.capitalize}").new(uri)
|
36
|
+
inject_http_params(request, params) if method != :get && params.any?
|
42
37
|
request
|
43
38
|
end
|
44
39
|
|
@@ -55,21 +50,17 @@ module Quovo
|
|
55
50
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
56
51
|
|
57
52
|
http.start do |transport|
|
58
|
-
(status_code, payload), elapsed = with_timing {
|
53
|
+
(status_code, payload), elapsed = with_timing { parse_http_response(transport.request(request), format) }
|
59
54
|
yield(status_code, payload, elapsed)
|
60
55
|
end
|
61
56
|
end
|
62
57
|
|
63
|
-
def inject_http_params(request,
|
64
|
-
|
65
|
-
|
66
|
-
else
|
67
|
-
request.body = params.to_json
|
68
|
-
request['Content-Type'] = 'application/json'
|
69
|
-
end
|
58
|
+
def inject_http_params(request, params)
|
59
|
+
request.body = params.to_json
|
60
|
+
request['Content-Type'] = 'application/json'
|
70
61
|
end
|
71
62
|
|
72
|
-
def
|
63
|
+
def parse_http_response(response, format)
|
73
64
|
status_code = response.code
|
74
65
|
body = response.body
|
75
66
|
raise Quovo::NotFoundError, body if status_code =~ /404/
|
data/lib/quovo/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quovo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Gorkunov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-07-
|
12
|
+
date: 2016-07-07 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Quovo RESTful API client, configurable, thread-safe and well-tested
|
15
15
|
email:
|
@@ -19,6 +19,7 @@ executables: []
|
|
19
19
|
extensions: []
|
20
20
|
extra_rdoc_files: []
|
21
21
|
files:
|
22
|
+
- CHANGELOG.md
|
22
23
|
- Gemfile
|
23
24
|
- LICENSE
|
24
25
|
- README.md
|