@@ -54,7 +54,7 @@ public function getAddress($postcode, $houseNumber)
5454 }
5555
5656 $ header = ['X-Api-Key ' => $ this ->apiKey ];
57- $ url = sprintf ('https://postcode- api.apiwise.nl/v2/addresses/?postcode=%s&number= %d ' , $ postcode , (int ) $ houseNumber );
57+ $ url = sprintf ('https://api.postcodeapi.nu/v3/lookup/%s/ %d ' , $ postcode , (int ) $ houseNumber );
5858 $ request = new Request ('GET ' , $ url , $ header );
5959
6060 try {
@@ -66,20 +66,18 @@ public function getAddress($postcode, $houseNumber)
6666
6767 $ data = json_decode ($ response ->getBody ()->getContents (), true );
6868
69- if (false === isset ($ data ['_embedded ' ][ ' addresses ' ][0 ])) {
69+ if (false === isset ($ data ['street ' ][0 ])) {
7070 throw new InvalidApiResponseException ('Address cannot be set from API data ' );
7171 }
7272
73- $ address = $ data ['_embedded ' ]['addresses ' ][0 ];
74-
75- $ city = $ address ['city ' ]['label ' ];
76- $ municipality = $ address ['municipality ' ]['label ' ];
77- $ street = $ address ['street ' ];
78- $ province = $ address ['province ' ]['label ' ];
73+ $ city = $ data ['city ' ];
74+ $ municipality = $ data ['municipality ' ];
75+ $ street = $ data ['street ' ];
76+ $ province = $ data ['province ' ];
7977
8078 $ geoLocation = [
81- 'longitude ' => isset ($ address [ ' geo ' ]['center ' ][ ' wgs84 ' ][ ' coordinates ' ][1 ]) ? $ address [ ' geo ' ][ ' center ' ][ ' wgs84 ' ]['coordinates ' ][0 ] : null ,
82- 'latitude ' => isset ($ address [ ' geo ' ]['center ' ][ ' wgs84 ' ][ ' coordinates ' ][0 ]) ? $ address [ ' geo ' ][ ' center ' ][ ' wgs84 ' ]['coordinates ' ][1 ] : null ,
79+ 'longitude ' => isset ($ data [ ' location ' ]['coordinates ' ][1 ]) ? $ data [ ' location ' ]['coordinates ' ][0 ] : null ,
80+ 'latitude ' => isset ($ data [ ' location ' ]['coordinates ' ][0 ]) ? $ data [ ' location ' ]['coordinates ' ][1 ] : null ,
8381 ];
8482
8583 $ address = new Address ($ street , $ postcode , $ city , $ houseNumber , $ province , $ municipality );
0 commit comments