gds-api-adapters 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gds_api/base.rb +2 -2
- data/lib/gds_api/content_api.rb +4 -0
- data/lib/gds_api/oauth2_client.rb +1 -1
- data/lib/gds_api/panopticon/registerer.rb +1 -1
- data/lib/gds_api/publisher.rb +14 -21
- data/lib/gds_api/test_helpers/content_api.rb +1 -1
- data/lib/gds_api/test_helpers/publisher.rb +1 -1
- data/lib/gds_api/version.rb +1 -1
- data/test/content_api_test.rb +12 -0
- metadata +32 -32
data/lib/gds_api/base.rb
CHANGED
data/lib/gds_api/content_api.rb
CHANGED
@@ -35,7 +35,7 @@ module GdsApi
|
|
35
35
|
hash
|
36
36
|
end
|
37
37
|
|
38
|
-
# record should respond to #slug and #title, or override #record_to_artefact
|
38
|
+
# record should respond to #slug and #title, or override #record_to_artefact
|
39
39
|
def register(record)
|
40
40
|
register_artefact(record_to_artefact(record))
|
41
41
|
end
|
data/lib/gds_api/publisher.rb
CHANGED
@@ -18,37 +18,30 @@ class GdsApi::Publisher < GdsApi::Base
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def council_for_slug(slug, snac_codes)
|
21
|
-
|
22
|
-
json
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
json = post_json(
|
22
|
+
"#{@endpoint}/local_transactions/#{slug}/verify_snac.json",
|
23
|
+
{'snac_codes' => snac_codes}
|
24
|
+
)
|
25
|
+
json['snac'] if json
|
26
26
|
end
|
27
27
|
|
28
28
|
def council_for_snac_code(snac)
|
29
|
-
|
30
|
-
|
31
|
-
else
|
32
|
-
nil
|
33
|
-
end
|
29
|
+
json = get_json("#{@endpoint}/local_transactions/find_by_snac?snac=#{snac}")
|
30
|
+
json.to_hash if json
|
34
31
|
end
|
35
32
|
|
36
33
|
def council_for_name(name)
|
37
34
|
name = URI.escape(name)
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
35
|
+
json = get_json(
|
36
|
+
"#{@endpoint}/local_transactions/find_by_council_name?name=#{name}"
|
37
|
+
)
|
38
|
+
json.to_hash if json
|
43
39
|
end
|
44
40
|
|
45
41
|
def licences_for_ids(ids)
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
else
|
50
|
-
nil
|
51
|
-
end
|
42
|
+
ids = ids.map(&:to_s).sort.join(',')
|
43
|
+
response = get_json("#{@endpoint}/licences.json?ids=#{ids}")
|
44
|
+
response.to_ostruct if response
|
52
45
|
end
|
53
46
|
|
54
47
|
private
|
@@ -33,7 +33,7 @@ module GdsApi
|
|
33
33
|
json = JSON.dump(output_details)
|
34
34
|
slug = input_details.delete('slug')
|
35
35
|
uri = "#{PUBLISHER_ENDPOINT}/local_transactions/#{slug}/verify_snac.json"
|
36
|
-
stub_request(:post, uri).with(:body => JSON.dump(input_details),
|
36
|
+
stub_request(:post, uri).with(:body => JSON.dump(input_details),
|
37
37
|
:headers => GdsApi::JsonClient::REQUEST_HEADERS).
|
38
38
|
to_return(:body => json, :status => 200)
|
39
39
|
end
|
data/lib/gds_api/version.rb
CHANGED
data/test/content_api_test.rb
CHANGED
@@ -15,4 +15,16 @@ class ContentApiTest < MiniTest::Unit::TestCase
|
|
15
15
|
first_section = response["results"][0]
|
16
16
|
assert_equal "http://contentapi.test.gov.uk/tags/crime.json", first_section["id"]
|
17
17
|
end
|
18
|
+
|
19
|
+
def test_with_tag
|
20
|
+
tag = "crime-and-justice"
|
21
|
+
api_url = "https://contentapi.test.alphagov.co.uk/with_tag.json?tag=#{tag}"
|
22
|
+
json = {
|
23
|
+
results: [{title: "Complain about a claims company"}]
|
24
|
+
}.to_json
|
25
|
+
stub_request(:get, api_url).to_return(:status => 200, :body => json)
|
26
|
+
response = api.with_tag("crime-and-justice")
|
27
|
+
subsection = response["results"][0]
|
28
|
+
assert_equal "Complain about a claims company", subsection["title"]
|
29
|
+
end
|
18
30
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: gds-api-adapters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.
|
5
|
+
version: 1.7.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- James Stewart
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-09-
|
13
|
+
date: 2012-09-06 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: plek
|
@@ -154,42 +154,42 @@ extensions: []
|
|
154
154
|
extra_rdoc_files: []
|
155
155
|
|
156
156
|
files:
|
157
|
+
- lib/gds_api/version.rb
|
158
|
+
- lib/gds_api/publisher.rb
|
159
|
+
- lib/gds_api/panopticon/registerer.rb
|
160
|
+
- lib/gds_api/typhoeus_client.rb
|
157
161
|
- lib/gds_api/content_api.rb
|
158
|
-
- lib/gds_api/
|
162
|
+
- lib/gds_api/imminence.rb
|
163
|
+
- lib/gds_api/contactotron.rb
|
164
|
+
- lib/gds_api/test_helpers/publisher.rb
|
159
165
|
- lib/gds_api/test_helpers/content_api.rb
|
166
|
+
- lib/gds_api/test_helpers/imminence.rb
|
160
167
|
- lib/gds_api/test_helpers/contactotron.rb
|
161
|
-
- lib/gds_api/test_helpers/json_client_helper.rb
|
162
|
-
- lib/gds_api/test_helpers/publisher.rb
|
163
168
|
- lib/gds_api/test_helpers/panopticon.rb
|
164
|
-
- lib/gds_api/test_helpers/
|
165
|
-
- lib/gds_api/
|
166
|
-
- lib/gds_api/
|
167
|
-
- lib/gds_api/typhoeus_client.rb
|
169
|
+
- lib/gds_api/test_helpers/json_client_helper.rb
|
170
|
+
- lib/gds_api/licence_application.rb
|
171
|
+
- lib/gds_api/base.rb
|
168
172
|
- lib/gds_api/json_client.rb
|
169
|
-
- lib/gds_api/contactotron.rb
|
170
|
-
- lib/gds_api/oauth2_client.rb
|
171
173
|
- lib/gds_api/response.rb
|
172
|
-
- lib/gds_api/panopticon/registerer.rb
|
173
|
-
- lib/gds_api/publisher.rb
|
174
|
-
- lib/gds_api/exceptions.rb
|
175
|
-
- lib/gds_api/version.rb
|
176
|
-
- lib/gds_api/helpers.rb
|
177
|
-
- lib/gds_api/base.rb
|
178
174
|
- lib/gds_api/panopticon.rb
|
179
175
|
- lib/gds_api/core-ext/openstruct.rb
|
180
|
-
- lib/gds_api/
|
176
|
+
- lib/gds_api/oauth2_client.rb
|
177
|
+
- lib/gds_api/part_methods.rb
|
178
|
+
- lib/gds_api/needotron.rb
|
179
|
+
- lib/gds_api/exceptions.rb
|
180
|
+
- lib/gds_api/helpers.rb
|
181
181
|
- README.md
|
182
182
|
- Rakefile
|
183
|
-
- test/imminence_api_test.rb
|
184
183
|
- test/contactotron_api_test.rb
|
185
|
-
- test/
|
186
|
-
- test/json_client_test.rb
|
184
|
+
- test/panopticon_api_test.rb
|
187
185
|
- test/publisher_api_test.rb
|
186
|
+
- test/imminence_api_test.rb
|
188
187
|
- test/panopticon_registerer_test.rb
|
189
|
-
- test/panopticon_api_test.rb
|
190
|
-
- test/test_helper.rb
|
191
|
-
- test/gds_api_base_test.rb
|
192
188
|
- test/content_api_test.rb
|
189
|
+
- test/json_client_test.rb
|
190
|
+
- test/gds_api_base_test.rb
|
191
|
+
- test/licence_application_api_test.rb
|
192
|
+
- test/test_helper.rb
|
193
193
|
homepage: http://github.com/alphagov/gds-api-adapters
|
194
194
|
licenses: []
|
195
195
|
|
@@ -203,7 +203,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
203
203
|
requirements:
|
204
204
|
- - ">="
|
205
205
|
- !ruby/object:Gem::Version
|
206
|
-
hash: -
|
206
|
+
hash: -2941031205011421741
|
207
207
|
segments:
|
208
208
|
- 0
|
209
209
|
version: "0"
|
@@ -212,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
212
212
|
requirements:
|
213
213
|
- - ">="
|
214
214
|
- !ruby/object:Gem::Version
|
215
|
-
hash: -
|
215
|
+
hash: -2941031205011421741
|
216
216
|
segments:
|
217
217
|
- 0
|
218
218
|
version: "0"
|
@@ -224,13 +224,13 @@ signing_key:
|
|
224
224
|
specification_version: 3
|
225
225
|
summary: Adapters to work with GDS APIs
|
226
226
|
test_files:
|
227
|
-
- test/imminence_api_test.rb
|
228
227
|
- test/contactotron_api_test.rb
|
229
|
-
- test/
|
230
|
-
- test/json_client_test.rb
|
228
|
+
- test/panopticon_api_test.rb
|
231
229
|
- test/publisher_api_test.rb
|
230
|
+
- test/imminence_api_test.rb
|
232
231
|
- test/panopticon_registerer_test.rb
|
233
|
-
- test/panopticon_api_test.rb
|
234
|
-
- test/test_helper.rb
|
235
|
-
- test/gds_api_base_test.rb
|
236
232
|
- test/content_api_test.rb
|
233
|
+
- test/json_client_test.rb
|
234
|
+
- test/gds_api_base_test.rb
|
235
|
+
- test/licence_application_api_test.rb
|
236
|
+
- test/test_helper.rb
|