Skip to content

Commit

Permalink
Merge pull request #1419 from cultuurnet/hotfix/geopunt_url
Browse files Browse the repository at this point in the history
The URL https://loc.geopunt.be has been removed and replaced by https://geo.api.vlaanderen.be/geolocation
  • Loading branch information
willaerk authored Jul 17, 2023
2 parents 317519c + 8818b29 commit 5b747a4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/Address/GeopuntAddressParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class GeopuntAddressParser implements AddressParser, LoggerAwareInterface

public function __construct(
?ClientInterface $httpClient = null,
?string $apiUrlV4 = 'https://loc.geopunt.be/v4'
?string $apiUrlV4 = 'https://geo.api.vlaanderen.be/geolocation/v4'
) {
$this->httpClient = $httpClient ?? new Client();
$this->apiUrlV4 = new Uri(rtrim($apiUrlV4, '/'));
Expand Down
36 changes: 18 additions & 18 deletions tests/Address/GeopuntAddressParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function it_looks_up_the_given_address_in_the_geopunt_api_and_returns_a_p

$expectedRequest = new Request(
'GET',
'https://loc.geopunt.be/v4/Location?q=Martelarenplein%201,%203000%20Leuven,%20BE'
'https://geo.api.vlaanderen.be/geolocation/v4/Location?q=Martelarenplein%201,%203000%20Leuven,%20BE'
);

$mockResponseData = [
Expand All @@ -67,7 +67,7 @@ public function it_looks_up_the_given_address_in_the_geopunt_api_and_returns_a_p
'Leuven'
);

$this->expectedLogs->info('GET https://loc.geopunt.be/v4/Location?q=Martelarenplein%201,%203000%20Leuven,%20BE responded with status code 200 and body {"LocationResult":[{"Municipality":"Leuven","Zipcode":"3000","Thoroughfarename":"Martelarenplein","Housenumber":"12"}]}');
$this->expectedLogs->info('GET https://geo.api.vlaanderen.be/geolocation/v4/Location?q=Martelarenplein%201,%203000%20Leuven,%20BE responded with status code 200 and body {"LocationResult":[{"Municipality":"Leuven","Zipcode":"3000","Thoroughfarename":"Martelarenplein","Housenumber":"12"}]}');
$this->expectedLogs->info('Successfully parsed response body.');

$actualParsedAddress = $this->geopuntAddressParser->parse($address);
Expand All @@ -85,7 +85,7 @@ public function it_can_handle_housenumber_being_null(): void

$expectedRequest = new Request(
'GET',
'https://loc.geopunt.be/v4/Location?q=Martelarenplein%201,%203000%20Leuven,%20BE'
'https://geo.api.vlaanderen.be/geolocation/v4/Location?q=Martelarenplein%201,%203000%20Leuven,%20BE'
);

$mockResponseData = [
Expand All @@ -112,7 +112,7 @@ public function it_can_handle_housenumber_being_null(): void
'Leuven'
);

$this->expectedLogs->info('GET https://loc.geopunt.be/v4/Location?q=Martelarenplein%201,%203000%20Leuven,%20BE responded with status code 200 and body {"LocationResult":[{"Municipality":"Leuven","Zipcode":"3000","Thoroughfarename":"Martelarenplein","Housenumber":null}]}');
$this->expectedLogs->info('GET https://geo.api.vlaanderen.be/geolocation/v4/Location?q=Martelarenplein%201,%203000%20Leuven,%20BE responded with status code 200 and body {"LocationResult":[{"Municipality":"Leuven","Zipcode":"3000","Thoroughfarename":"Martelarenplein","Housenumber":null}]}');
$this->expectedLogs->info('Successfully parsed response body.');

$actualParsedAddress = $this->geopuntAddressParser->parse($address);
Expand All @@ -130,7 +130,7 @@ public function it_can_handle_json_syntax_errors(): void

$expectedRequest = new Request(
'GET',
'https://loc.geopunt.be/v4/Location?q=Martelarenplein%201,%203000%20Leuven,%20BE'
'https://geo.api.vlaanderen.be/geolocation/v4/Location?q=Martelarenplein%201,%203000%20Leuven,%20BE'
);

$mockResponse = new Response(200, [], '{{}');
Expand All @@ -140,7 +140,7 @@ public function it_can_handle_json_syntax_errors(): void
->with($expectedRequest)
->willReturn($mockResponse);

$this->expectedLogs->info('GET https://loc.geopunt.be/v4/Location?q=Martelarenplein%201,%203000%20Leuven,%20BE responded with status code 200 and body {{}');
$this->expectedLogs->info('GET https://geo.api.vlaanderen.be/geolocation/v4/Location?q=Martelarenplein%201,%203000%20Leuven,%20BE responded with status code 200 and body {{}');
$this->expectedLogs->error('Caught \JsonException while decoding response body.', ['message' => 'Syntax error']);

$actualParsedAddress = $this->geopuntAddressParser->parse($address);
Expand All @@ -158,7 +158,7 @@ public function it_can_handle_missing_LocationResult_property(): void

$expectedRequest = new Request(
'GET',
'https://loc.geopunt.be/v4/Location?q=Martelarenplein%201,%203000%20Leuven,%20BE'
'https://geo.api.vlaanderen.be/geolocation/v4/Location?q=Martelarenplein%201,%203000%20Leuven,%20BE'
);

$mockResponse = new Response(200, [], '{}');
Expand All @@ -168,7 +168,7 @@ public function it_can_handle_missing_LocationResult_property(): void
->with($expectedRequest)
->willReturn($mockResponse);

$this->expectedLogs->info('GET https://loc.geopunt.be/v4/Location?q=Martelarenplein%201,%203000%20Leuven,%20BE responded with status code 200 and body {}');
$this->expectedLogs->info('GET https://geo.api.vlaanderen.be/geolocation/v4/Location?q=Martelarenplein%201,%203000%20Leuven,%20BE responded with status code 200 and body {}');
$this->expectedLogs->error(
'Response body did not match the expected JSON schema. Did the API introduce a breaking change?',
[
Expand All @@ -195,7 +195,7 @@ public function it_can_handle_missing_properties_inside_LocationResult(): void

$expectedRequest = new Request(
'GET',
'https://loc.geopunt.be/v4/Location?q=Martelarenplein%201,%203000%20Leuven,%20BE'
'https://geo.api.vlaanderen.be/geolocation/v4/Location?q=Martelarenplein%201,%203000%20Leuven,%20BE'
);

$mockResponseData = [
Expand All @@ -210,7 +210,7 @@ public function it_can_handle_missing_properties_inside_LocationResult(): void
->with($expectedRequest)
->willReturn($mockResponse);

$this->expectedLogs->info('GET https://loc.geopunt.be/v4/Location?q=Martelarenplein%201,%203000%20Leuven,%20BE responded with status code 200 and body {"LocationResult":[{}]}');
$this->expectedLogs->info('GET https://geo.api.vlaanderen.be/geolocation/v4/Location?q=Martelarenplein%201,%203000%20Leuven,%20BE responded with status code 200 and body {"LocationResult":[{}]}');
$this->expectedLogs->error(
'Response body did not match the expected JSON schema. Did the API introduce a breaking change?',
[
Expand All @@ -237,7 +237,7 @@ public function it_can_handle_incorrect_property_values_inside_LocationResult():

$expectedRequest = new Request(
'GET',
'https://loc.geopunt.be/v4/Location?q=Martelarenplein%201,%203000%20Leuven,%20BE'
'https://geo.api.vlaanderen.be/geolocation/v4/Location?q=Martelarenplein%201,%203000%20Leuven,%20BE'
);

$mockResponseData = [
Expand All @@ -257,7 +257,7 @@ public function it_can_handle_incorrect_property_values_inside_LocationResult():
->with($expectedRequest)
->willReturn($mockResponse);

$this->expectedLogs->info('GET https://loc.geopunt.be/v4/Location?q=Martelarenplein%201,%203000%20Leuven,%20BE responded with status code 200 and body {"LocationResult":[{"Municipality":8,"Zipcode":null,"Thoroughfarename":false,"Housenumber":[]}]}');
$this->expectedLogs->info('GET https://geo.api.vlaanderen.be/geolocation/v4/Location?q=Martelarenplein%201,%203000%20Leuven,%20BE responded with status code 200 and body {"LocationResult":[{"Municipality":8,"Zipcode":null,"Thoroughfarename":false,"Housenumber":[]}]}');
$this->expectedLogs->error(
'Response body did not match the expected JSON schema. Did the API introduce a breaking change?',
[
Expand Down Expand Up @@ -292,7 +292,7 @@ public function it_can_handle_an_empty_LocationResult(): void

$expectedRequest = new Request(
'GET',
'https://loc.geopunt.be/v4/Location?q=Martelarenplein%201,%203000%20Leuven,%20BE'
'https://geo.api.vlaanderen.be/geolocation/v4/Location?q=Martelarenplein%201,%203000%20Leuven,%20BE'
);

$mockResponseData = [
Expand All @@ -305,7 +305,7 @@ public function it_can_handle_an_empty_LocationResult(): void
->with($expectedRequest)
->willReturn($mockResponse);

$this->expectedLogs->info('GET https://loc.geopunt.be/v4/Location?q=Martelarenplein%201,%203000%20Leuven,%20BE responded with status code 200 and body {"LocationResult":[]}');
$this->expectedLogs->info('GET https://geo.api.vlaanderen.be/geolocation/v4/Location?q=Martelarenplein%201,%203000%20Leuven,%20BE responded with status code 200 and body {"LocationResult":[]}');
$this->expectedLogs->info('Response body did not contain any array items inside "LocationResult" property. Either the address is not located in Belgium, or it is not recognized as an official address.');

$actualParsedAddress = $this->geopuntAddressParser->parse($address);
Expand All @@ -323,7 +323,7 @@ public function it_can_handle_an_empty_zipcode(): void

$expectedRequest = new Request(
'GET',
'https://loc.geopunt.be/v4/Location?q=Marguerite%20Durassquare,%201000%20Brussel,%20BE'
'https://geo.api.vlaanderen.be/geolocation/v4/Location?q=Marguerite%20Durassquare,%201000%20Brussel,%20BE'
);

$mockResponseData = [
Expand All @@ -344,7 +344,7 @@ public function it_can_handle_an_empty_zipcode(): void
->with($expectedRequest)
->willReturn($mockResponse);

$this->expectedLogs->info('GET https://loc.geopunt.be/v4/Location?q=Marguerite%20Durassquare,%201000%20Brussel,%20BE responded with status code 200 and body {"LocationResult":[{"Municipality":"Bruxelles","Zipcode":null,"Thoroughfarename":"Marguerite Durassquare","Housenumber":null}]}');
$this->expectedLogs->info('GET https://geo.api.vlaanderen.be/geolocation/v4/Location?q=Marguerite%20Durassquare,%201000%20Brussel,%20BE responded with status code 200 and body {"LocationResult":[{"Municipality":"Bruxelles","Zipcode":null,"Thoroughfarename":"Marguerite Durassquare","Housenumber":null}]}');
$this->expectedLogs->info('Successfully parsed response body.');

$expectedParsedAddress = new ParsedAddress(
Expand All @@ -369,7 +369,7 @@ public function it_can_handle_an_empty_thoroughfare(): void

$expectedRequest = new Request(
'GET',
'https://loc.geopunt.be/v4/Location?q=Marguerite%20Durassquare,%201000%20Brussel,%20BE'
'https://geo.api.vlaanderen.be/geolocation/v4/Location?q=Marguerite%20Durassquare,%201000%20Brussel,%20BE'
);

$mockResponseData = [
Expand All @@ -390,7 +390,7 @@ public function it_can_handle_an_empty_thoroughfare(): void
->with($expectedRequest)
->willReturn($mockResponse);

$this->expectedLogs->info('GET https://loc.geopunt.be/v4/Location?q=Marguerite%20Durassquare,%201000%20Brussel,%20BE responded with status code 200 and body {"LocationResult":[{"Municipality":"Bruxelles","Zipcode":"1000","Thoroughfarename":null,"Housenumber":null}]}');
$this->expectedLogs->info('GET https://geo.api.vlaanderen.be/geolocation/v4/Location?q=Marguerite%20Durassquare,%201000%20Brussel,%20BE responded with status code 200 and body {"LocationResult":[{"Municipality":"Bruxelles","Zipcode":"1000","Thoroughfarename":null,"Housenumber":null}]}');
$this->expectedLogs->info('Successfully parsed response body.');

$expectedParsedAddress = new ParsedAddress(
Expand Down

0 comments on commit 5b747a4

Please sign in to comment.