parliament-ruby 0.7.9.pre2 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/parliament/request/base_request.rb +5 -2
- data/lib/parliament/request/url_request.rb +13 -1
- data/lib/parliament/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71b2aff3f66eac37947e60b3fc36da0038d3baf0
|
4
|
+
data.tar.gz: 9fe948ddf162be2e0b6bd9002ebd7d9e34a98238
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d78f43df180a15d88dd1d834d118638be588e39239d055d15ee66eae895fa9730365103768987cc1636f6a5a8341228c9c7111c49be1f1bc317295a624327a3d
|
7
|
+
data.tar.gz: d8fcbff4dd593b324498fdf6a93105b812595d3ec6b718bd4a203f95cc65f9f27a33c697a9e799e2c7a4306311aaa77e69d6443f012d326f20e0194392bc6dc4
|
@@ -7,7 +7,7 @@ module Parliament
|
|
7
7
|
# @attr_reader [String] base_url the base url of our api. (expected: http://example.com - without the trailing slash).
|
8
8
|
# @attr_reader [Hash] headers the headers being sent in the request.
|
9
9
|
class BaseRequest
|
10
|
-
attr_reader :base_url, :headers
|
10
|
+
attr_reader :base_url, :headers, :query_params
|
11
11
|
# Creates a new instance of Parliament::Request::BaseRequest.
|
12
12
|
#
|
13
13
|
# An interesting note for #initialize is that setting base_url on the class, or using the environment variable
|
@@ -59,6 +59,7 @@ module Parliament
|
|
59
59
|
@headers = headers || self.class.headers || {}
|
60
60
|
@builder = builder || Parliament::Builder::BaseResponseBuilder
|
61
61
|
@decorators = decorators
|
62
|
+
@query_params = {}
|
62
63
|
end
|
63
64
|
|
64
65
|
# Makes an HTTP GET request and process results into a response.
|
@@ -85,8 +86,10 @@ module Parliament
|
|
85
86
|
#
|
86
87
|
# @return [Parliament::Response::BaseResponse] a Parliament::Response::BaseResponse object containing all of the data returned from the URL.
|
87
88
|
def get(params: nil)
|
89
|
+
@query_params = @query_params.merge(params) unless params.nil?
|
90
|
+
|
88
91
|
endpoint_uri = URI.parse(query_url)
|
89
|
-
endpoint_uri.query = URI.encode_www_form(
|
92
|
+
endpoint_uri.query = URI.encode_www_form(@query_params.to_a) unless @query_params.empty?
|
90
93
|
|
91
94
|
http = Net::HTTP.new(endpoint_uri.host, endpoint_uri.port)
|
92
95
|
http.use_ssl = true if endpoint_uri.scheme == 'https'
|
@@ -69,7 +69,19 @@ module Parliament
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def query_url
|
72
|
-
[@base_url, @endpoint_parts].join('/')
|
72
|
+
uri_string = [@base_url, @endpoint_parts].join('/').gsub(' ', '%20')
|
73
|
+
|
74
|
+
uri = URI.parse(uri_string)
|
75
|
+
uri.query = URI.encode_www_form(@query_params) unless @query_params.empty?
|
76
|
+
|
77
|
+
uri.to_s
|
78
|
+
end
|
79
|
+
|
80
|
+
# @return [Parliament::Request::UrlRequest] self (this is to allow method chaining).
|
81
|
+
def set_url_params(params)
|
82
|
+
@query_params = @query_params.merge(params)
|
83
|
+
|
84
|
+
self
|
73
85
|
end
|
74
86
|
end
|
75
87
|
end
|
data/lib/parliament/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parliament-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Rayner
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -186,9 +186,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
186
186
|
version: '0'
|
187
187
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
188
|
requirements:
|
189
|
-
- - "
|
189
|
+
- - ">="
|
190
190
|
- !ruby/object:Gem::Version
|
191
|
-
version:
|
191
|
+
version: '0'
|
192
192
|
requirements: []
|
193
193
|
rubyforge_project:
|
194
194
|
rubygems_version: 2.6.8
|