gds-api-adapters 0.0.51 → 0.0.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/gds_api/publisher.rb +17 -0
- data/lib/gds_api/version.rb +1 -1
- data/test/publisher_api_test.rb +43 -0
- metadata +26 -26
data/lib/gds_api/publisher.rb
CHANGED
@@ -25,6 +25,23 @@ class GdsApi::Publisher < GdsApi::Base
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
def council_for_snac_code(snac)
|
29
|
+
if json = get_json("#{@endpoint}/local_transactions/find_by_snac?snac=#{snac}")
|
30
|
+
json.to_hash
|
31
|
+
else
|
32
|
+
nil
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def council_for_name(name)
|
37
|
+
name = URI.escape(name)
|
38
|
+
if json = get_json("#{@endpoint}/local_transactions/find_by_council_name?name=#{name}")
|
39
|
+
json.to_hash
|
40
|
+
else
|
41
|
+
nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
28
45
|
def licences_for_ids(ids)
|
29
46
|
response = get_json("#{@endpoint}/licences.json?ids=#{ids.map(&:to_s).sort.join(',')}")
|
30
47
|
if response
|
data/lib/gds_api/version.rb
CHANGED
data/test/publisher_api_test.rb
CHANGED
@@ -138,5 +138,48 @@ describe GdsApi::Publisher do
|
|
138
138
|
|
139
139
|
assert_equal nil, api.licences_for_ids([123,124])
|
140
140
|
end
|
141
|
+
|
142
|
+
it "should return nil if a council snac code is not found" do
|
143
|
+
stub_request(:get, "#{PUBLISHER_ENDPOINT}/local_transactions/find_by_snac?snac=bloop").
|
144
|
+
with(:headers => GdsApi::JsonClient::REQUEST_HEADERS).
|
145
|
+
to_return(:status => 404, :body => " ", :headers => {})
|
146
|
+
|
147
|
+
assert_equal nil, api.council_for_snac_code("bloop")
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should return a council hash for a snac code" do
|
151
|
+
stub_request(:get, "#{PUBLISHER_ENDPOINT}/local_transactions/find_by_snac?snac=AA00").
|
152
|
+
with(:headers => GdsApi::JsonClient::REQUEST_HEADERS).
|
153
|
+
to_return(:status => 200, :body => '{"name": "Some Council", "snac": "AA00"}', :headers => {})
|
154
|
+
|
155
|
+
expected = {"name" => "Some Council", "snac" => "AA00"}
|
156
|
+
assert_equal expected, api.council_for_snac_code("AA00")
|
157
|
+
end
|
158
|
+
|
159
|
+
it "should return nil if a council name is not found" do
|
160
|
+
stub_request(:get, "#{PUBLISHER_ENDPOINT}/local_transactions/find_by_council_name?name=bloop").
|
161
|
+
with(:headers => GdsApi::JsonClient::REQUEST_HEADERS).
|
162
|
+
to_return(:status => 404, :body => " ", :headers => {})
|
163
|
+
|
164
|
+
assert_equal nil, api.council_for_name("bloop")
|
165
|
+
end
|
166
|
+
|
167
|
+
it "should return a council hash for a mixed case council name" do
|
168
|
+
stub_request(:get, "#{PUBLISHER_ENDPOINT}/local_transactions/find_by_council_name?name=Some%20Council").
|
169
|
+
with(:headers => GdsApi::JsonClient::REQUEST_HEADERS).
|
170
|
+
to_return(:status => 200, :body => '{"name": "Some Council", "snac": "AA00"}', :headers => {})
|
171
|
+
|
172
|
+
expected = {"name" => "Some Council", "snac" => "AA00"}
|
173
|
+
assert_equal expected, api.council_for_name("Some Council")
|
174
|
+
end
|
175
|
+
|
176
|
+
it "should return a council hash for a lowercase council name" do
|
177
|
+
stub_request(:get, "#{PUBLISHER_ENDPOINT}/local_transactions/find_by_council_name?name=some%20council").
|
178
|
+
with(:headers => GdsApi::JsonClient::REQUEST_HEADERS).
|
179
|
+
to_return(:status => 200, :body => '{"name": "Some Council", "snac": "AA00"}', :headers => {})
|
180
|
+
|
181
|
+
expected = {"name" => "Some Council", "snac" => "AA00"}
|
182
|
+
assert_equal expected, api.council_for_name("some council")
|
183
|
+
end
|
141
184
|
end
|
142
185
|
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: 0.0.
|
5
|
+
version: 0.0.52
|
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-07-
|
13
|
+
date: 2012-07-18 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: plek
|
@@ -143,34 +143,34 @@ extensions: []
|
|
143
143
|
extra_rdoc_files: []
|
144
144
|
|
145
145
|
files:
|
146
|
-
- lib/gds_api/
|
147
|
-
- lib/gds_api/
|
148
|
-
- lib/gds_api/
|
149
|
-
- lib/gds_api/
|
150
|
-
- lib/gds_api/helpers.rb
|
146
|
+
- lib/gds_api/version.rb
|
147
|
+
- lib/gds_api/publisher.rb
|
148
|
+
- lib/gds_api/panopticon/registerer.rb
|
149
|
+
- lib/gds_api/typhoeus_client.rb
|
151
150
|
- lib/gds_api/imminence.rb
|
151
|
+
- lib/gds_api/contactotron.rb
|
152
|
+
- lib/gds_api/test_helpers/publisher.rb
|
153
|
+
- lib/gds_api/test_helpers/imminence.rb
|
154
|
+
- lib/gds_api/test_helpers/contactotron.rb
|
155
|
+
- lib/gds_api/test_helpers/panopticon.rb
|
156
|
+
- lib/gds_api/test_helpers/json_client_helper.rb
|
157
|
+
- lib/gds_api/base.rb
|
152
158
|
- lib/gds_api/json_client.rb
|
153
|
-
- lib/gds_api/
|
154
|
-
- lib/gds_api/oauth2_client.rb
|
155
|
-
- lib/gds_api/panopticon/registerer.rb
|
159
|
+
- lib/gds_api/response.rb
|
156
160
|
- lib/gds_api/panopticon.rb
|
161
|
+
- lib/gds_api/core-ext/openstruct.rb
|
162
|
+
- lib/gds_api/oauth2_client.rb
|
157
163
|
- lib/gds_api/part_methods.rb
|
158
|
-
- lib/gds_api/
|
159
|
-
- lib/gds_api/
|
160
|
-
- lib/gds_api/
|
161
|
-
- lib/gds_api/test_helpers/imminence.rb
|
162
|
-
- lib/gds_api/test_helpers/json_client_helper.rb
|
163
|
-
- lib/gds_api/test_helpers/panopticon.rb
|
164
|
-
- lib/gds_api/test_helpers/publisher.rb
|
165
|
-
- lib/gds_api/typhoeus_client.rb
|
166
|
-
- lib/gds_api/version.rb
|
164
|
+
- lib/gds_api/needotron.rb
|
165
|
+
- lib/gds_api/exceptions.rb
|
166
|
+
- lib/gds_api/helpers.rb
|
167
167
|
- README.md
|
168
168
|
- Rakefile
|
169
169
|
- test/contactotron_api_test.rb
|
170
|
-
- test/gds_api_base_test.rb
|
171
|
-
- test/json_client_test.rb
|
172
170
|
- test/panopticon_api_test.rb
|
173
171
|
- test/publisher_api_test.rb
|
172
|
+
- test/json_client_test.rb
|
173
|
+
- test/gds_api_base_test.rb
|
174
174
|
- test/test_helper.rb
|
175
175
|
homepage: http://github.com/alphagov/gds-api-adapters
|
176
176
|
licenses: []
|
@@ -185,7 +185,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
185
185
|
requirements:
|
186
186
|
- - ">="
|
187
187
|
- !ruby/object:Gem::Version
|
188
|
-
hash:
|
188
|
+
hash: 2947988208479081559
|
189
189
|
segments:
|
190
190
|
- 0
|
191
191
|
version: "0"
|
@@ -194,21 +194,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
194
|
requirements:
|
195
195
|
- - ">="
|
196
196
|
- !ruby/object:Gem::Version
|
197
|
-
hash:
|
197
|
+
hash: 2947988208479081559
|
198
198
|
segments:
|
199
199
|
- 0
|
200
200
|
version: "0"
|
201
201
|
requirements: []
|
202
202
|
|
203
203
|
rubyforge_project:
|
204
|
-
rubygems_version: 1.8.
|
204
|
+
rubygems_version: 1.8.24
|
205
205
|
signing_key:
|
206
206
|
specification_version: 3
|
207
207
|
summary: Adapters to work with GDS APIs
|
208
208
|
test_files:
|
209
209
|
- test/contactotron_api_test.rb
|
210
|
-
- test/gds_api_base_test.rb
|
211
|
-
- test/json_client_test.rb
|
212
210
|
- test/panopticon_api_test.rb
|
213
211
|
- test/publisher_api_test.rb
|
212
|
+
- test/json_client_test.rb
|
213
|
+
- test/gds_api_base_test.rb
|
214
214
|
- test/test_helper.rb
|