diff --git a/src/Geocoder/Provider/GeoIP2.php b/src/Geocoder/Provider/GeoIP2.php index 15e9daa9c..f6f7c6d70 100644 --- a/src/Geocoder/Provider/GeoIP2.php +++ b/src/Geocoder/Provider/GeoIP2.php @@ -71,7 +71,7 @@ public function geocode($address) 'latitude' => (isset($result->location->latitude) ? $result->location->latitude : null), 'longitude' => (isset($result->location->longitude) ? $result->location->longitude : null), 'timezone' => (isset($result->location->time_zone) ? $result->location->time_zone : null), - 'postalCode' => (isset($result->location->postal_code) ? $result->location->postal_code : null), + 'postalCode' => (isset($result->postal->code) ? $result->postal->code : null), 'adminLevels' => $adminLevels, ))) ]); diff --git a/tests/Geocoder/Tests/Provider/GeoIP2Test.php b/tests/Geocoder/Tests/Provider/GeoIP2Test.php index f15a7358a..f9bebb1f6 100644 --- a/tests/Geocoder/Tests/Provider/GeoIP2Test.php +++ b/tests/Geocoder/Tests/Provider/GeoIP2Test.php @@ -76,7 +76,7 @@ public static function provideDataForRetrievingGeodata() $testdata = array( 'Response with data' => array( '74.200.247.59', - '{"city":{"geoname_id":2911298,"names":{"de":"Hamburg","en":"Hamburg","es":"Hamburgo","fr":"Hambourg","ja":"\u30cf\u30f3\u30d6\u30eb\u30af","pt-BR":"Hamburgo","ru":"\u0413\u0430\u043c\u0431\u0443\u0440\u0433","zh-CN":"\u6c49\u5821\u5e02"}},"continent":{"code":"EU","geoname_id":6255148,"names":{"de":"Europa","en":"Europe","es":"Europa","fr":"Europe","ja":"\u30e8\u30fc\u30ed\u30c3\u30d1","pt-BR":"Europa","ru":"\u0415\u0432\u0440\u043e\u043f\u0430","zh-CN":"\u6b27\u6d32"}},"country":{"geoname_id":2921044,"iso_code":"DE","names":{"de":"Deutschland","en":"Germany","es":"Alemania","fr":"Allemagne","ja":"\u30c9\u30a4\u30c4\u9023\u90a6\u5171\u548c\u56fd","pt-BR":"Alemanha","ru":"\u0413\u0435\u0440\u043c\u0430\u043d\u0438\u044f","zh-CN":"\u5fb7\u56fd"}},"location":{"latitude":53.55,"longitude":10,"time_zone":"Europe\/Berlin"},"registered_country":{"geoname_id":2921044,"iso_code":"DE","names":{"de":"Deutschland","en":"Germany","es":"Alemania","fr":"Allemagne","ja":"\u30c9\u30a4\u30c4\u9023\u90a6\u5171\u548c\u56fd","pt-BR":"Alemanha","ru":"\u0413\u0435\u0440\u043c\u0430\u043d\u0438\u044f","zh-CN":"\u5fb7\u56fd"}},"subdivisions":[{"geoname_id":2911297,"iso_code":"HH","names":{"de":"Hamburg","en":"Hamburg","es":"Hamburgo","fr":"Hambourg"}}],"traits":{"ip_address":"74.200.247.59"}}', + '{"city":{"geoname_id":2911298,"names":{"de":"Hamburg","en":"Hamburg","es":"Hamburgo","fr":"Hambourg","ja":"\u30cf\u30f3\u30d6\u30eb\u30af","pt-BR":"Hamburgo","ru":"\u0413\u0430\u043c\u0431\u0443\u0440\u0433","zh-CN":"\u6c49\u5821\u5e02"}},"continent":{"code":"EU","geoname_id":6255148,"names":{"de":"Europa","en":"Europe","es":"Europa","fr":"Europe","ja":"\u30e8\u30fc\u30ed\u30c3\u30d1","pt-BR":"Europa","ru":"\u0415\u0432\u0440\u043e\u043f\u0430","zh-CN":"\u6b27\u6d32"}},"country":{"geoname_id":2921044,"iso_code":"DE","names":{"de":"Deutschland","en":"Germany","es":"Alemania","fr":"Allemagne","ja":"\u30c9\u30a4\u30c4\u9023\u90a6\u5171\u548c\u56fd","pt-BR":"Alemanha","ru":"\u0413\u0435\u0440\u043c\u0430\u043d\u0438\u044f","zh-CN":"\u5fb7\u56fd"}},"location":{"latitude":53.55,"longitude":10,"time_zone":"Europe\/Berlin"},"registered_country":{"geoname_id":2921044,"iso_code":"DE","names":{"de":"Deutschland","en":"Germany","es":"Alemania","fr":"Allemagne","ja":"\u30c9\u30a4\u30c4\u9023\u90a6\u5171\u548c\u56fd","pt-BR":"Alemanha","ru":"\u0413\u0435\u0440\u043c\u0430\u043d\u0438\u044f","zh-CN":"\u5fb7\u56fd"}},"subdivisions":[{"geoname_id":2911297,"iso_code":"HH","names":{"de":"Hamburg","en":"Hamburg","es":"Hamburgo","fr":"Hambourg"}}],"traits":{"ip_address":"74.200.247.59"},"postal":{"code":"EC4N"}}', array( 'latitude' => 53.55, 'longitude' => 10, @@ -85,7 +85,7 @@ public static function provideDataForRetrievingGeodata() 'streetName' => null, 'locality' => 'Hamburg', 'subLocality' => null, - 'postalCode' => null, + 'postalCode' => 'EC4N', 'adminLevels' => [1 => [ 'name' => 'Hamburg', 'code' => 'HH', @@ -106,7 +106,7 @@ public static function provideDataForRetrievingGeodata() 'streetName' => null, 'locality' => 'Monza', 'subLocality' => null, - 'postalCode' => null, + 'postalCode' => '20900', 'adminLevels' => [ 1 => [ 'name' => 'Lombardy',