Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename Imminence to PlacesManager #1253

Merged
merged 2 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
with:
pact_artifact: pacts

imminence_pact:
places_manager_pact:
needs: generate_pacts
uses: alphagov/imminence/.github/workflows/pact-verify.yml@main
with:
Expand Down Expand Up @@ -129,7 +129,7 @@ jobs:
- collections_pact
- email_alert_api_pact
- frontend_pact
- imminence_pact
- places_manager_pact
- link_checker_api_pact
- locations_api_pact
- publishing_api_pact
Expand Down
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Unreleased
# UNRELEASED

* BREAKING: Rename imminence endpoints to places_manager [PR](https://github.com/alphagov/gds-api-adapters/pull/1253)
* Note: This is used in Frontend only, so for other apps should not be breaking in practice.

# 96.0.0
* BREAKING: Drop support for email-alert-api's bulk migrate endpoint

# 95.1.0
Expand Down
10 changes: 5 additions & 5 deletions lib/gds_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
require "gds_api/calendars"
require "gds_api/content_store"
require "gds_api/email_alert_api"
require "gds_api/imminence"
require "gds_api/places_manager"
require "gds_api/licence_application"
require "gds_api/link_checker_api"
require "gds_api/local_links_manager"
Expand Down Expand Up @@ -82,11 +82,11 @@ def self.email_alert_api(options = {})
)
end

# Creates a GdsApi::Imminence adapter
# Creates a GdsApi::PlacesManager adapter
#
# @return [GdsApi::Imminence]
def self.imminence(options = {})
GdsApi::Imminence.new(Plek.find("imminence"), options)
# @return [GdsApi::PlacesManager]
def self.places_manager(options = {})
GdsApi::PlacesManager.new(Plek.find("places-manager"), options)
end

# Creates a GdsApi::LicenceApplication
Expand Down
2 changes: 1 addition & 1 deletion lib/gds_api/imminence.rb → lib/gds_api/places_manager.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require_relative "base"

class GdsApi::Imminence < GdsApi::Base
class GdsApi::PlacesManager < GdsApi::Base
def api_url(type, params)
vals = %i[limit lat lng postcode local_authority_slug].select { |p| params.include? p }
querystring = URI.encode_www_form(vals.map { |p| [p, params[p]] })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,44 @@

module GdsApi
module TestHelpers
module Imminence
module PlacesManager
# Generally true. If you are initializing the client differently,
# you could redefine/override the constant or stub directly.
IMMINENCE_API_ENDPOINT = Plek.find("imminence")
PLACES_MANAGER_API_ENDPOINT = Plek.find("places-manager")

def stub_imminence_has_places(latitude, longitude, details)
def stub_places_manager_has_places(latitude, longitude, details)
query_hash = { "lat" => latitude, "lng" => longitude, "limit" => "5" }
response_data = {
status: "ok",
content: "places",
places: details["details"],
}
stub_imminence_places_request(details["slug"], query_hash, response_data)
stub_places_manager_places_request(details["slug"], query_hash, response_data)
end

def stub_imminence_has_multiple_authorities_for_postcode(addresses, slug, postcode, limit)
def stub_places_manager_has_multiple_authorities_for_postcode(addresses, slug, postcode, limit)
query_hash = { "postcode" => postcode, "limit" => limit }
response_data = {
status: "address-information-required",
content: "addresses",
addresses:,
}
stub_imminence_places_request(slug, query_hash, response_data)
stub_places_manager_places_request(slug, query_hash, response_data)
end

def stub_imminence_has_places_for_postcode(places, slug, postcode, limit, local_authority_slug)
def stub_places_manager_has_places_for_postcode(places, slug, postcode, limit, local_authority_slug)
query_hash = { "postcode" => postcode, "limit" => limit }
query_hash.merge!(local_authority_slug:) if local_authority_slug
response_data = {
status: "ok",
content: "places",
places:,
}
stub_imminence_places_request(slug, query_hash, response_data)
stub_places_manager_places_request(slug, query_hash, response_data)
end

def stub_imminence_places_request(slug, query_hash, return_data, status_code = 200)
stub_request(:get, "#{IMMINENCE_API_ENDPOINT}/places/#{slug}.json")
def stub_places_manager_places_request(slug, query_hash, return_data, status_code = 200)
stub_request(:get, "#{PLACES_MANAGER_API_ENDPOINT}/places/#{slug}.json")
.with(query: query_hash)
.to_return(status: status_code, body: return_data.to_json, headers: {})
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
require "test_helper"
require "gds_api/imminence"
require "gds_api/places_manager"

describe "GdsApi::Imminence pact tests" do
describe "GdsApi::PlacesManager pact tests" do
include PactTest

describe "#places" do
let(:api_client) { GdsApi::Imminence.new(imminence_api_host) }
let(:api_client) { GdsApi::PlacesManager.new(places_manager_api_host) }

it "responds with all responses for the given dataset" do
imminence_api
places_manager_api
.given("a service exists called number-plate-supplier with places")
.upon_receiving("the request to retrieve relevant places for the current dataset for a lat/lon")
.with(
Expand Down Expand Up @@ -56,7 +56,7 @@
end

it "responds with a choice of addresses for disambiguation of split postcodes" do
imminence_api
places_manager_api
.given("a service exists called register office exists with places, and CH25 9BJ is a split postcode")
.upon_receiving("the request to retrieve relevant places for the current dataset for CH25 9BJ")
.with(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
require "test_helper"
require "gds_api/imminence"
require "gds_api/places_manager"

class ImminenceApiTest < Minitest::Test
ROOT = Plek.find("imminence")
class PlacesManagerApiTest < Minitest::Test
ROOT = Plek.find("places-manager")
LATITUDE = 52.1327584352089
LONGITUDE = -0.4702813074674147

def api_client
GdsApi::Imminence.new(ROOT)
GdsApi::PlacesManager.new(ROOT)
end

def dummy_place
Expand Down
12 changes: 6 additions & 6 deletions test/support/pact_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
BANK_HOLIDAYS_API_PORT = 3003
ACCOUNT_API_PORT = 3004
LINK_CHECKER_API_PORT = 3005
IMMINENCE_API_PORT = 3006
PLACES_MANAGER_API_PORT = 3006
LOCATIONS_API_PORT = 3008
ASSET_MANAGER_API_PORT = 3009
EMAIL_ALERT_API_PORT = 3010
Expand All @@ -30,8 +30,8 @@ def link_checker_api_host
"http://localhost:#{LINK_CHECKER_API_PORT}"
end

def imminence_api_host
"http://localhost:#{IMMINENCE_API_PORT}"
def places_manager_api_host
"http://localhost:#{PLACES_MANAGER_API_PORT}"
end

def locations_api_host
Expand Down Expand Up @@ -77,9 +77,9 @@ def email_alert_api_host
end
end

has_pact_with "Imminence API" do
mock_service :imminence_api do
port IMMINENCE_API_PORT
has_pact_with "PlacesManager API" do
mock_service :places_manager_api do
port PLACES_MANAGER_API_PORT
end
end

Expand Down