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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3011d5900d368b5667436e94dea95a0e5d185ab8
4
- data.tar.gz: b5f2d3a2731f8b87233467105227aa52db36705e
3
+ metadata.gz: f227193b6f0739cab72692b0a226fad6d1f96e01
4
+ data.tar.gz: be73b894f91df18fab63a968d6f2abbb0c7276b1
5
5
  SHA512:
6
- metadata.gz: 04e57921b787ac37766f34cb9c06e2cfb8731e265deaa5bbf6c31d31b264f26bb44e46e6c6032bb4b8e42f727f71350040ebcc4c0047c13a3cae3c41b48f0e8d
7
- data.tar.gz: a4240168d0795b24c5cd40be56fdbb54ca4947307bd426d549fe3d9bb53156fcc5af1c609013c36bc359233f9f76637ab765b442ef7c9da37adffa05b557d722
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
@@ -1,3 +1,3 @@
1
1
  module ServiceApi
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -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
- it 'should return string' do
40
- model.find.body.should == 'OK'
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
- it 'should return full url' do
44
- model.find_url.should == 'http://example.com/test/request'
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
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.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Krzysztof Wawer