Skip to content

Commit

Permalink
Update bpost.php
Browse files Browse the repository at this point in the history
Enable "full adress" geocoding
  • Loading branch information
jbelien committed Jan 4, 2018
1 parent bb96dec commit faabe42
Showing 1 changed file with 36 additions and 19 deletions.
55 changes: 36 additions & 19 deletions bpost.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,29 +58,46 @@ public function geocodeQuery(GeocodeQuery $query): Collection
throw new InvalidArgument('Address cannot be empty.');
}

$request = [];
$request['ValidateAddressesRequest'] = [
'AddressToValidateList' => [
'AddressToValidate' => [
[
'@id' => 1,
'PostalAddress' => [
'DeliveryPointLocation' => [
'StructuredDeliveryPointLocation' => [
'StreetName' => $query->getData('streetName'),
'StreetNumber' => $query->getData('streetNumber'),
],
$address = $query->getText();
$streetName = $query->getData('streetName');
$streetNumber = $query->getData('streetNumber');

if (!is_null($streetName) && !is_null($streetNumber)) {
$addressToValidate = [
'@id' => 1,
'PostalAddress' => [
'DeliveryPointLocation' => [
'StructuredDeliveryPointLocation' => [
'StreetName' => $query->getData('streetName'),
'StreetNumber' => $query->getData('streetNumber'),
],
'PostalCodeMunicipality' => [
'StructuredPostalCodeMunicipality' => [
'PostalCode' => $query->getData('postalCode', ''),
'MunicipalityName' => $query->getData('locality', ''),
],
],
'PostalCodeMunicipality' => [
'StructuredPostalCodeMunicipality' => [
'PostalCode' => $query->getData('postalCode', ''),
'MunicipalityName' => $query->getData('locality', ''),
],
],
'DeliveringCountryISOCode' => 'BE',
'DispatchingCountryISOCode' => 'BE',
],
'DeliveringCountryISOCode' => 'BE',
'DispatchingCountryISOCode' => 'BE',
];
} else {
$addressToValidate = [
'@id' => 1,
'AddressBlockLines' => [
'UnstructuredAddressLine' => $address
],
'DeliveringCountryISOCode' => 'BE',
'DispatchingCountryISOCode' => 'BE',
];
}

$request = [];
$request['ValidateAddressesRequest'] = [
'AddressToValidateList' => [
'AddressToValidate' => [
$addressToValidate,
],
],
'ValidateAddressOptions' => [
Expand Down

0 comments on commit faabe42

Please sign in to comment.