zooppa_api_v3 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zooppa_api_v3.rb +11 -1
- data/spec/zooppa_api_v3_spec.rb +12 -3
- data/zooppa_api_v3.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7345c4ee14742397e9b2e360d9369611a8c2f6be
|
4
|
+
data.tar.gz: f9cd8bd20e615e27ff996b8e17f93c3fac6aabc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a08bf3c395208585bd4ca2d878d3401e2ae7285ca583c1e9decb9eca9cbd89d49ceba9990eedd923fb3f6a8e1b73abe2b3d22f7887e9d6f5d931d2268a6a667e
|
7
|
+
data.tar.gz: a520200634a829b91eca360435646ecd9aa7cf0ae97c8c95bc6359b8d6fbfd8299acac21dca3c165d473a8fea2fcf569a00a499ecb9163642f78cba24862ec67
|
data/lib/zooppa_api_v3.rb
CHANGED
@@ -29,6 +29,8 @@ class ZooppaApiV3
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def method_missing(method,*args,&block)
|
32
|
+
puts "Params #{@params}"
|
33
|
+
puts "Filter params: #{@filter_params }"
|
32
34
|
eigenclass = class << self; self; end
|
33
35
|
eigenclass.class_eval do
|
34
36
|
define_method(method) do
|
@@ -101,8 +103,15 @@ class ZooppaApiV3
|
|
101
103
|
end
|
102
104
|
end
|
103
105
|
|
106
|
+
# TODO: find a better solution for that
|
107
|
+
def clean_up
|
108
|
+
@filter_params = nil
|
109
|
+
end
|
110
|
+
|
104
111
|
# Builds the URL (adds an id of provided)
|
105
112
|
def build_url
|
113
|
+
puts "Complete params: #{complete_parameters(query_params, pagination_params)}"
|
114
|
+
puts "Complete params: #{complete_parameters(query_params, pagination_params)}"
|
106
115
|
url = @api_host + 'api/' + @version + '/' + @resource
|
107
116
|
url += '/' + @id if @id
|
108
117
|
url += '.json'
|
@@ -110,6 +119,7 @@ class ZooppaApiV3
|
|
110
119
|
@params = complete_parameters(query_params, pagination_params) if [:delete, :get].include?(@method)
|
111
120
|
url += '?' + @params unless @params == ''
|
112
121
|
end
|
122
|
+
clean_up
|
113
123
|
url
|
114
124
|
end
|
115
125
|
|
@@ -126,6 +136,7 @@ class ZooppaApiV3
|
|
126
136
|
end
|
127
137
|
|
128
138
|
def query_params
|
139
|
+
puts "query params: execute"
|
129
140
|
query_params = ''
|
130
141
|
if @filter_params
|
131
142
|
query_params += @filter_params
|
@@ -151,7 +162,6 @@ class ZooppaApiV3
|
|
151
162
|
return pagination_params
|
152
163
|
end
|
153
164
|
|
154
|
-
|
155
165
|
def prepare_request(resource, **args)
|
156
166
|
@resource = resource
|
157
167
|
@method = args.fetch(:method) { :get }
|
data/spec/zooppa_api_v3_spec.rb
CHANGED
@@ -5,7 +5,6 @@ require 'json'
|
|
5
5
|
puts ZooppaApiV3
|
6
6
|
|
7
7
|
describe ZooppaApiV3 do
|
8
|
-
|
9
8
|
context '#new' do
|
10
9
|
subject(:zooppa_api) { ZooppaApiV3 }
|
11
10
|
|
@@ -30,7 +29,6 @@ describe ZooppaApiV3 do
|
|
30
29
|
end
|
31
30
|
end
|
32
31
|
|
33
|
-
|
34
32
|
context '#build_url' do
|
35
33
|
subject(:zooppa_api) { ZooppaApiV3.new }
|
36
34
|
|
@@ -87,6 +85,18 @@ describe ZooppaApiV3 do
|
|
87
85
|
expect(zooppa_api.ads.page(1).per_page(10).where('contest_id,=,1', 'resource_type,=,video').sort('title ASC').build_url).to eq 'http://localhost:3000/api/v3/ads.json?filters[filter_0]=contest_id,=,1&filters[filter_1]=resource_type,=,video&sort_by=title+ASC&page=1&per_page=10'
|
88
86
|
end
|
89
87
|
end
|
88
|
+
|
89
|
+
context 'Given .where is called' do
|
90
|
+
before do
|
91
|
+
zooppa_api.ads.where('contest_id,=,1', 'resource_type,=,video').build_url
|
92
|
+
end
|
93
|
+
|
94
|
+
context 'and a subsequent .ads (index) call without a .where method' do
|
95
|
+
it 'returns correct url' do
|
96
|
+
expect(zooppa_api.ads.build_url).to eq 'http://localhost:3000/api/v3/ads.json'
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
90
100
|
end
|
91
101
|
|
92
102
|
context '#execute' do
|
@@ -106,7 +116,6 @@ describe ZooppaApiV3 do
|
|
106
116
|
end
|
107
117
|
end
|
108
118
|
|
109
|
-
|
110
119
|
context 'Given .where("contest_id,=,1") is called' do
|
111
120
|
it 'it calls Restclient.send with :get as method and correct url' do
|
112
121
|
expect(RestClient).to receive(:send).with(:get, 'http://localhost:3000/api/v3/ads.json?filters[filter_0]=contest_id,=,1').and_return({}.to_json)
|
data/zooppa_api_v3.gemspec
CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "zooppa_api_v3"
|
8
|
-
spec.version = '0.0.
|
8
|
+
spec.version = '0.0.2'
|
9
9
|
spec.authors = ["Ulrich Soeffing"]
|
10
10
|
spec.email = ["ulrich_soeffing@gmx.de"]
|
11
11
|
spec.description = "Wrapper for the Zooppa api v3"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zooppa_api_v3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ulrich Soeffing
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|