gds-api-adapters 85.0.1 → 86.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b0dc3a7a3430d48165ca6e1b8720675dc9a1e5a94e8180d881d10f55af0c3a1
4
- data.tar.gz: d12927fcfda065d8f8e9a51fbf01bcca3a4a8dd9e8b77550ed7cba34cb3b5145
3
+ metadata.gz: 214ed40ae7affc00a9d2c5f1b7452ba6d7ed4a94583ca8aa86e02db9ed3df756
4
+ data.tar.gz: ddfd3ab91c870bea25ae2d8c8b0f1a27b20e72ea3c5f663ba94d331474627e89
5
5
  SHA512:
6
- metadata.gz: 7d3833134e981234ae2b3a9abc1c433b1f7e51c96fbc0b733f0e0ec325b515dea0513ae9fabcb7767c9a4a93117066429061aecd1a25a4d3ff50777655bfdaf7
7
- data.tar.gz: d0774cdaa3d94aa927aa54c451434eb6036e2c4973864ee770186943f7fb106bbbf21e98756f11a274147c5e7568f22193781263fa20423876a3fb680ec983bd
6
+ metadata.gz: a149aed8a9ad8e8f29b266a3e040b5c85bb46f15a50fbe5ca1f55937eb2f386f875bb94f0cb833d32c9a86cef35f5e920061ed8d4f32266c1e6f83090c7a0f8d
7
+ data.tar.gz: 4bd054db26f96aaa3a4f00667728aa195fc35022ed0774fadc42debc0be20cad0b6a2375e56588438e6a50674af31e22866d8c62b02aa7064a53896366f48e77
data/Rakefile CHANGED
@@ -22,16 +22,14 @@ task default: %i[lint test]
22
22
 
23
23
  require "pact_broker/client/tasks"
24
24
 
25
- def configure_pact_broker_location(task)
25
+ PactBroker::Client::PublicationTask.new do |task|
26
+ task.consumer_version = ENV.fetch("PACT_CONSUMER_VERSION")
26
27
  task.pact_broker_base_url = ENV.fetch("PACT_BROKER_BASE_URL")
27
- if ENV["PACT_BROKER_USERNAME"]
28
- task.pact_broker_basic_auth = { username: ENV["PACT_BROKER_USERNAME"], password: ENV["PACT_BROKER_PASSWORD"] }
29
- end
30
- end
31
-
32
- PactBroker::Client::PublicationTask.new("branch") do |task|
33
- task.consumer_version = ENV.fetch("PACT_TARGET_BRANCH")
34
- configure_pact_broker_location(task)
28
+ task.pact_broker_basic_auth = {
29
+ username: ENV.fetch("PACT_BROKER_USERNAME"),
30
+ password: ENV.fetch("PACT_BROKER_PASSWORD"),
31
+ }
32
+ task.pattern = ENV["PACT_PATTERN"] if ENV["PACT_PATTERN"]
35
33
  end
36
34
 
37
35
  desc "Run the linter against changed files"
@@ -2,55 +2,24 @@ require_relative "base"
2
2
 
3
3
  class GdsApi::Imminence < GdsApi::Base
4
4
  def api_url(type, params)
5
- vals = %i[limit lat lng postcode].select { |p| params.include? p }
5
+ vals = %i[limit lat lng postcode local_authority_slug].select { |p| params.include? p }
6
6
  querystring = URI.encode_www_form(vals.map { |p| [p, params[p]] })
7
7
  "#{@endpoint}/places/#{type}.json?#{querystring}"
8
8
  end
9
9
 
10
10
  def places(type, lat, lon, limit = 5)
11
11
  url = api_url(type, lat: lat, lng: lon, limit: limit)
12
- places = get_json(url) || []
13
- places.map { |p| self.class.parse_place_hash(p) }
12
+ get_json(url)
14
13
  end
15
14
 
16
- def places_for_postcode(type, postcode, limit = 5)
17
- url = api_url(type, postcode: postcode, limit: limit)
18
- places = get_json(url) || []
19
- places.map { |p| self.class.parse_place_hash(p) }
20
- end
21
-
22
- def self.parse_place_hash(place_hash)
23
- location = extract_location_hash(place_hash["location"])
24
- address = extract_address_hash(place_hash)
25
-
26
- place_hash.merge(location).merge(address)
15
+ def places_for_postcode(type, postcode, limit = 5, local_authority_slug = nil)
16
+ options = { postcode: postcode, limit: limit }
17
+ options.merge!(local_authority_slug: local_authority_slug) if local_authority_slug
18
+ url = api_url(type, options)
19
+ get_json(url) || []
27
20
  end
28
21
 
29
22
  def places_kml(type)
30
23
  get_raw("#{@endpoint}/places/#{type}.kml").body
31
24
  end
32
-
33
- # @private
34
- def self.extract_location_hash(location)
35
- # Deal with all known location formats:
36
- # Old style: [latitude, longitude]; empty array for no location
37
- # New style: hash with keys "longitude", "latitude"; nil for no location
38
- case location
39
- when Array
40
- { "latitude" => location[0], "longitude" => location[1] }
41
- when Hash
42
- location
43
- when nil
44
- { "latitude" => nil, "longitude" => nil }
45
- end
46
- end
47
-
48
- # @private
49
- def self.extract_address_hash(place_hash)
50
- address_fields = [
51
- place_hash["address1"],
52
- place_hash["address2"],
53
- ].reject { |a| a.nil? || a == "" }
54
- { "address" => address_fields.map(&:strip).join(", ") }
55
- end
56
25
  end
@@ -9,12 +9,33 @@ module GdsApi
9
9
 
10
10
  def stub_imminence_has_places(latitude, longitude, details)
11
11
  query_hash = { "lat" => latitude, "lng" => longitude, "limit" => "5" }
12
- stub_imminence_places_request(details["slug"], query_hash, details["details"])
12
+ response_data = {
13
+ status: "ok",
14
+ content: "places",
15
+ places: details["details"],
16
+ }
17
+ stub_imminence_places_request(details["slug"], query_hash, response_data)
13
18
  end
14
19
 
15
- def stub_imminence_has_places_for_postcode(places, slug, postcode, limit)
20
+ def stub_imminence_has_multiple_authorities_for_postcode(addresses, slug, postcode, limit)
16
21
  query_hash = { "postcode" => postcode, "limit" => limit }
17
- stub_imminence_places_request(slug, query_hash, places)
22
+ response_data = {
23
+ status: "address-information-required",
24
+ content: "addresses",
25
+ addresses: addresses,
26
+ }
27
+ stub_imminence_places_request(slug, query_hash, response_data)
28
+ end
29
+
30
+ def stub_imminence_has_places_for_postcode(places, slug, postcode, limit, local_authority_slug)
31
+ query_hash = { "postcode" => postcode, "limit" => limit }
32
+ query_hash.merge!(local_authority_slug: local_authority_slug) if local_authority_slug
33
+ response_data = {
34
+ status: "ok",
35
+ content: "places",
36
+ places: places,
37
+ }
38
+ stub_imminence_places_request(slug, query_hash, response_data)
18
39
  end
19
40
 
20
41
  def stub_imminence_places_request(slug, query_hash, return_data, status_code = 200)
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = "85.0.1".freeze
2
+ VERSION = "86.0.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gds-api-adapters
3
3
  version: !ruby/object:Gem::Version
4
- version: 85.0.1
4
+ version: 86.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-30 00:00:00.000000000 Z
11
+ date: 2023-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -268,14 +268,14 @@ dependencies:
268
268
  requirements:
269
269
  - - '='
270
270
  - !ruby/object:Gem::Version
271
- version: 4.9.0
271
+ version: 4.10.0
272
272
  type: :development
273
273
  prerelease: false
274
274
  version_requirements: !ruby/object:Gem::Requirement
275
275
  requirements:
276
276
  - - '='
277
277
  - !ruby/object:Gem::Version
278
- version: 4.9.0
278
+ version: 4.10.0
279
279
  - !ruby/object:Gem::Dependency
280
280
  name: simplecov
281
281
  requirement: !ruby/object:Gem::Requirement
@@ -417,7 +417,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
417
417
  - !ruby/object:Gem::Version
418
418
  version: '0'
419
419
  requirements: []
420
- rubygems_version: 3.4.5
420
+ rubygems_version: 3.4.7
421
421
  signing_key:
422
422
  specification_version: 4
423
423
  summary: Adapters to work with GDS APIs