gds-api-adapters 10.15.1 → 10.16.0

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.
@@ -37,6 +37,11 @@ class GdsApi::Imminence < GdsApi::Base
37
37
  get_json!("#{@endpoint}/business_support_schemes.json#{query}")
38
38
  end
39
39
 
40
+ def areas_for_postcode(postcode)
41
+ url = "#{@endpoint}/areas/#{URI.encode(postcode)}.json"
42
+ get_json(url)
43
+ end
44
+
40
45
  private
41
46
  def self.extract_location_hash(location)
42
47
  # Deal with all known location formats:
@@ -41,6 +41,17 @@ module GdsApi
41
41
  stub_request(:get, %r{\A#{IMMINENCE_API_ENDPOINT}/business_support_schemes\.json}).
42
42
  to_return(:body => empty_results.to_json)
43
43
  end
44
+
45
+ def imminence_has_areas_for_postcode(postcode, areas)
46
+ results = {
47
+ "_response_info" => {"status" => "ok"},
48
+ "total" => areas.size, "startIndex" => 1, "pageSize" => areas.size,
49
+ "currentPage" => 1, "pages" => 1, "results" => areas
50
+ }
51
+
52
+ stub_request(:get, %r{\A#{IMMINENCE_API_ENDPOINT}/areas/#{postcode}\.json}).
53
+ to_return(:body => results.to_json)
54
+ end
44
55
  end
45
56
  end
46
57
  end
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '10.15.1'
2
+ VERSION = '10.16.0'
3
3
  end
@@ -163,4 +163,28 @@ EOS
163
163
  response_body = api_client.places_kml("test")
164
164
  assert_equal kml_body, response_body
165
165
  end
166
+
167
+ def test_areas_for_postcode
168
+ areas = [
169
+ { "id" => 12, "type" => "LBO", "name" => "Westminster City Council", "country_name" => "England" },
170
+ { "id" => 66, "type" => "EUR", "name" => "London", "country_name" => "England" }
171
+ ]
172
+ results = {
173
+ "_response_info" => {"status" => "ok"},
174
+ "total" => areas.size, "startIndex" => 1, "pageSize" => areas.size,
175
+ "currentPage" => 1, "pages" => 1, "results" => areas
176
+ }
177
+
178
+ stub_request(:get, "#{ROOT}/areas/WC2B%206SE.json").
179
+ with(headers: GdsApi::JsonClient::DEFAULT_REQUEST_HEADERS).
180
+ to_return(status: 200, body: results.to_json )
181
+
182
+ response = api_client.areas_for_postcode("WC2B 6SE")
183
+
184
+ assert_equal "ok", response["_response_info"]["status"]
185
+ areas_from_response = response["results"]
186
+ assert_equal 2, areas_from_response.size
187
+ assert_equal "LBO", areas_from_response.first["type"]
188
+ assert_equal 12, areas_from_response.first["id"]
189
+ end
166
190
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gds-api-adapters
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.15.1
4
+ version: 10.16.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-06-06 00:00:00.000000000 Z
12
+ date: 2014-06-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: plek
@@ -382,7 +382,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
382
382
  version: '0'
383
383
  segments:
384
384
  - 0
385
- hash: -1755748041123917011
385
+ hash: -1543517987799295868
386
386
  required_rubygems_version: !ruby/object:Gem::Requirement
387
387
  none: false
388
388
  requirements:
@@ -391,7 +391,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
391
391
  version: '0'
392
392
  segments:
393
393
  - 0
394
- hash: -1755748041123917011
394
+ hash: -1543517987799295868
395
395
  requirements: []
396
396
  rubyforge_project:
397
397
  rubygems_version: 1.8.23