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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f227193b6f0739cab72692b0a226fad6d1f96e01
4
- data.tar.gz: be73b894f91df18fab63a968d6f2abbb0c7276b1
3
+ metadata.gz: 17d0157549889eafc0a06c5a154157f06e386daf
4
+ data.tar.gz: ffea55d1004c3be0a232495b0bffa9ce27c81dae
5
5
  SHA512:
6
- metadata.gz: 59d9bb2a9ac24515f10e0bf6be68d133ff3f8cae3973d431b09d4c51f84663bf8de2ecb1fa45cb6a239108544f2de8d451d86e8798da8fa87cf86756dd169712
7
- data.tar.gz: 5105f1d3dcb9bb51accd9679709a8434fb8d4ba0dac8b959c7ea4d9efbaeb807ba273093e8f11075905bd6e98cb9c7e6ca6eb0873ae9220f16aaa28d11c2b3ba
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
@@ -1,3 +1,3 @@
1
1
  module ServiceApi
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
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(sample: true, api_key: 'abcd', request: 'request').get
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(sample: true, api_key: 'abcd').url
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(sample: true, api_key: 'abcd', request: 'request').get
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(sample: true, api_key: 'abcd').url
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.3
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