gds-api-adapters 85.0.1 → 86.0.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.
- checksums.yaml +4 -4
- data/Rakefile +7 -9
- data/lib/gds_api/imminence.rb +7 -38
- data/lib/gds_api/test_helpers/imminence.rb +24 -3
- data/lib/gds_api/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 214ed40ae7affc00a9d2c5f1b7452ba6d7ed4a94583ca8aa86e02db9ed3df756
|
4
|
+
data.tar.gz: ddfd3ab91c870bea25ae2d8c8b0f1a27b20e72ea3c5f663ba94d331474627e89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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"
|
data/lib/gds_api/imminence.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
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
|
20
|
+
def stub_imminence_has_multiple_authorities_for_postcode(addresses, slug, postcode, limit)
|
16
21
|
query_hash = { "postcode" => postcode, "limit" => limit }
|
17
|
-
|
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)
|
data/lib/gds_api/version.rb
CHANGED
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:
|
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-
|
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.
|
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.
|
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.
|
420
|
+
rubygems_version: 3.4.7
|
421
421
|
signing_key:
|
422
422
|
specification_version: 4
|
423
423
|
summary: Adapters to work with GDS APIs
|