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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b2b6eac7fb141cc4c7dc62499f707640d17e4320
4
- data.tar.gz: c7107b3bb7f5f892c1f4c8e75965a4d4a5c27e83
3
+ metadata.gz: 398cce62ff51e5d66813740023fe251d1c5facdc
4
+ data.tar.gz: e129102cd9c3df882b2a586716a0ad8ecb559514
5
5
  SHA512:
6
- metadata.gz: f8b1ce1b75ad54337024a86c272853296b6d465f2a84667b6b370529a21090a20a7f4e5e95a6298e9ed0988e072be88207e4b727f780a112f3a7186dfa8fc7c7
7
- data.tar.gz: 3c222fa0a62b9b51399ee562b43cbb323ed0a1887d697e8cb1c4500753571c9a5141e73705e1dbb932edeaf894ef3d1a74d51f0f9c450e76aaca8aa626ffa8e1
6
+ metadata.gz: 839329cd6df5ed129db2c97afb94b8771155a45bf11a993117d4181cab20c09f5697bb8135770db629f0a926e5a6c7a2b683fc3273848068bb4227a2f0c8dbba
7
+ data.tar.gz: 000b8cab076fd0ae5b988471b2246868845eaf3520f8aff402eec8177464fbc6190be876613dc74641377802c90de763ad9654613e179b9a63274b1de2cc3388
@@ -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.
@@ -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
- request = build_http_request(config.endpoint, method, path, params)
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 build_http_request(endpoint, method, path, params)
28
- request = case method
29
- when :get
30
- Net::HTTP::Get
31
- when :post
32
- Net::HTTP::Post
33
- when :put
34
- Net::HTTP::Put
35
- when :delete
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 { parse_response(transport.request(request), format) }
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, method, params)
64
- if method == :get
65
- request.uri.query = URI.encode_www_form(params)
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 parse_response(response, format)
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/
@@ -1,3 +1,3 @@
1
1
  module Quovo
2
- VERSION = '1.0.2'.freeze
2
+ VERSION = '1.0.3'.freeze
3
3
  end
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.2
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-04 00:00:00.000000000 Z
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