gds-api-adapters 11.0.0 → 11.1.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.
@@ -42,6 +42,11 @@ class GdsApi::Imminence < GdsApi::Base
42
42
  get_json(url)
43
43
  end
44
44
 
45
+ def areas_for_type(type)
46
+ url = "#{@endpoint}/areas/#{type}.json"
47
+ get_json(url)
48
+ end
49
+
45
50
  private
46
51
  def self.extract_location_hash(location)
47
52
  # Deal with all known location formats:
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '11.0.0'
2
+ VERSION = '11.1.0'
3
3
  end
@@ -187,4 +187,31 @@ EOS
187
187
  assert_equal "LBO", areas_from_response.first["type"]
188
188
  assert_equal 12, areas_from_response.first["id"]
189
189
  end
190
+
191
+ def test_areas_by_type
192
+ areas = [
193
+ { "id" => 122, "type" => "EUR", "name" => "Yorkshire and the Humber", "country_name" => "England" },
194
+ { "id" => 665, "type" => "EUR", "name" => "London", "country_name" => "England" }
195
+ ]
196
+ results = {
197
+ "_response_info" => {"status" => "ok"},
198
+ "total" => areas.size, "startIndex" => 1, "pageSize" => areas.size,
199
+ "currentPage" => 1, "pages" => 1, "results" => areas
200
+ }
201
+
202
+ stub_request(:get, "#{ROOT}/areas/EUR.json").
203
+ with(headers: GdsApi::JsonClient::DEFAULT_REQUEST_HEADERS).
204
+ to_return(status: 200, body: results.to_json )
205
+
206
+ response = api_client.areas_for_type("EUR")
207
+
208
+ assert_equal "ok", response["_response_info"]["status"]
209
+ areas_from_response = response["results"]
210
+ assert_equal 2, areas_from_response.size
211
+ assert_equal "EUR", areas_from_response.first["type"]
212
+ assert_equal "EUR", areas_from_response.last["type"]
213
+ assert_equal 122, areas_from_response.first["id"]
214
+ assert_equal 665, areas_from_response.last["id"]
215
+ end
216
+
190
217
  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: 11.0.0
4
+ version: 11.1.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-18 00:00:00.000000000 Z
12
+ date: 2014-06-19 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: -1694392773198955183
385
+ hash: 1088972631923026448
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: -1694392773198955183
394
+ hash: 1088972631923026448
395
395
  requirements: []
396
396
  rubyforge_project:
397
397
  rubygems_version: 1.8.23