service_api 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/service_api/base_faraday.rb +7 -1
- data/lib/service_api/version.rb +1 -1
- data/service_api.gemspec +1 -0
- data/spec/functionals/base_faraday_spec.rb +6 -6
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17d0157549889eafc0a06c5a154157f06e386daf
|
4
|
+
data.tar.gz: ffea55d1004c3be0a232495b0bffa9ce27c81dae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7962f428ede59c30b397374042389a03302decdce4418d02bc70b641a6abe9f82af097e0bc40e3d1d504c8bf0b84b44d528673ce3160cab827d1f39c2260237
|
7
|
+
data.tar.gz: e0ced0bd45724356fdfdf74f51c4a7eb74cd9778ef4b30487ea08ffbc92fe3423969fe8b1f1924fa05da02bff363ab55794084df5adc3ce9d6e7732c2dba5134
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'faraday'
|
2
2
|
require 'faraday_middleware'
|
3
3
|
require 'uri_template'
|
4
|
+
require 'queryparams'
|
4
5
|
|
5
6
|
module ServiceApi
|
6
7
|
# BaseFaraday is module for Faraday api which should be included in own base Api class.
|
@@ -62,7 +63,7 @@ module ServiceApi
|
|
62
63
|
# path('/test/request').params(sample: true, api_key: 'abcd').url
|
63
64
|
#
|
64
65
|
def url
|
65
|
-
"#{base_url}#{uri}"
|
66
|
+
"#{base_url}#{uri}#{query_params_formatted}"
|
66
67
|
end
|
67
68
|
|
68
69
|
private
|
@@ -100,6 +101,11 @@ module ServiceApi
|
|
100
101
|
@params.reject{ |request_params| token?(request_params) }
|
101
102
|
end
|
102
103
|
|
104
|
+
def query_params_formatted
|
105
|
+
params = query_params
|
106
|
+
params.empty? ? '' : "?#{QueryParams.encode(params)}"
|
107
|
+
end
|
108
|
+
|
103
109
|
def uri_kind
|
104
110
|
:default
|
105
111
|
end
|
data/lib/service_api/version.rb
CHANGED
data/service_api.gemspec
CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_runtime_dependency 'faraday', '~> 0.9.0'
|
22
22
|
spec.add_runtime_dependency 'uri_template', '~> 0.7.0'
|
23
|
+
spec.add_runtime_dependency 'queryparams', '~> 0.0.3'
|
23
24
|
spec.add_runtime_dependency 'faraday_middleware', '~> 0.9.1'
|
24
25
|
spec.add_runtime_dependency 'multi_xml', '~> 0.5.5'
|
25
26
|
|
@@ -24,21 +24,21 @@ end
|
|
24
24
|
|
25
25
|
class SampleApi < MyApi
|
26
26
|
def find
|
27
|
-
path('/test/{request}').params(
|
27
|
+
path('/test/{request}').params(api_key: 'abcd', sample: true, request: 'request').get
|
28
28
|
end
|
29
29
|
|
30
30
|
def find_url
|
31
|
-
path('/test/request').params(
|
31
|
+
path('/test/request').params(api_key: 'abcd', sample: true).url
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
class Sample2Api < MyApi
|
36
36
|
def find
|
37
|
-
path('/test/:request').params(
|
37
|
+
path('/test/:request').params(api_key: 'abcd', sample: true, request: 'request').get
|
38
38
|
end
|
39
39
|
|
40
40
|
def find_url
|
41
|
-
path('/test/request').params(
|
41
|
+
path('/test/request').params(api_key: 'abcd', sample: true).url
|
42
42
|
end
|
43
43
|
|
44
44
|
def uri_kind
|
@@ -57,7 +57,7 @@ describe ServiceApi::BaseFaraday do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'should return full url' do
|
60
|
-
model.find_url.should == 'http://example.com/test/request'
|
60
|
+
model.find_url.should == 'http://example.com/test/request?api_key=abcd&sample=true'
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
@@ -67,7 +67,7 @@ describe ServiceApi::BaseFaraday do
|
|
67
67
|
end
|
68
68
|
|
69
69
|
it 'should return full url' do
|
70
|
-
model2.find_url.should == 'http://example.com/test/request'
|
70
|
+
model2.find_url.should == 'http://example.com/test/request?api_key=abcd&sample=true'
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: service_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Krzysztof Wawer
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.7.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: queryparams
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.0.3
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.0.3
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: faraday_middleware
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|