service_api 0.0.2 → 0.0.3
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 +5 -3
- data/lib/service_api/version.rb +1 -1
- data/spec/functionals/base_faraday_spec.rb +32 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f227193b6f0739cab72692b0a226fad6d1f96e01
|
4
|
+
data.tar.gz: be73b894f91df18fab63a968d6f2abbb0c7276b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59d9bb2a9ac24515f10e0bf6be68d133ff3f8cae3973d431b09d4c51f84663bf8de2ecb1fa45cb6a239108544f2de8d451d86e8798da8fa87cf86756dd169712
|
7
|
+
data.tar.gz: 5105f1d3dcb9bb51accd9679709a8434fb8d4ba0dac8b959c7ea4d9efbaeb807ba273093e8f11075905bd6e98cb9c7e6ca6eb0873ae9220f16aaa28d11c2b3ba
|
@@ -24,8 +24,6 @@ module ServiceApi
|
|
24
24
|
def initialize(client)
|
25
25
|
@client = client
|
26
26
|
@params = {}
|
27
|
-
@mandatory_params = {}
|
28
|
-
@optional_params = {}
|
29
27
|
end
|
30
28
|
|
31
29
|
protected
|
@@ -88,7 +86,7 @@ module ServiceApi
|
|
88
86
|
|
89
87
|
def uri_tokens(uri = nil)
|
90
88
|
if uri
|
91
|
-
@uri_tokens = ServiceApi::UriTokens.new(uri)
|
89
|
+
@uri_tokens = ServiceApi::UriTokens.new(uri_kind, uri)
|
92
90
|
else
|
93
91
|
@uri_tokens
|
94
92
|
end
|
@@ -102,6 +100,10 @@ module ServiceApi
|
|
102
100
|
@params.reject{ |request_params| token?(request_params) }
|
103
101
|
end
|
104
102
|
|
103
|
+
def uri_kind
|
104
|
+
:default
|
105
|
+
end
|
106
|
+
|
105
107
|
def base_url
|
106
108
|
raise NotImplementedError
|
107
109
|
end
|
data/lib/service_api/version.rb
CHANGED
@@ -24,7 +24,7 @@ end
|
|
24
24
|
|
25
25
|
class SampleApi < MyApi
|
26
26
|
def find
|
27
|
-
path('/test/request').params(sample: true, api_key: 'abcd').get
|
27
|
+
path('/test/{request}').params(sample: true, api_key: 'abcd', request: 'request').get
|
28
28
|
end
|
29
29
|
|
30
30
|
def find_url
|
@@ -32,15 +32,42 @@ class SampleApi < MyApi
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
class Sample2Api < MyApi
|
36
|
+
def find
|
37
|
+
path('/test/:request').params(sample: true, api_key: 'abcd', request: 'request').get
|
38
|
+
end
|
39
|
+
|
40
|
+
def find_url
|
41
|
+
path('/test/request').params(sample: true, api_key: 'abcd').url
|
42
|
+
end
|
43
|
+
|
44
|
+
def uri_kind
|
45
|
+
:colon
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
35
49
|
describe ServiceApi::BaseFaraday do
|
36
50
|
let(:client) { Client.new }
|
37
51
|
let(:model) { SampleApi.new(client) }
|
52
|
+
let(:model2) { Sample2Api.new(client) }
|
53
|
+
|
54
|
+
describe 'model' do
|
55
|
+
it 'should return string' do
|
56
|
+
model.find.body.should == 'OK'
|
57
|
+
end
|
38
58
|
|
39
|
-
|
40
|
-
|
59
|
+
it 'should return full url' do
|
60
|
+
model.find_url.should == 'http://example.com/test/request'
|
61
|
+
end
|
41
62
|
end
|
42
63
|
|
43
|
-
|
44
|
-
|
64
|
+
describe 'model2' do
|
65
|
+
it 'should return string' do
|
66
|
+
model2.find.body.should == 'OK'
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should return full url' do
|
70
|
+
model2.find_url.should == 'http://example.com/test/request'
|
71
|
+
end
|
45
72
|
end
|
46
73
|
end
|