|
|
@@ -189,6 +189,9 @@ class ZipCodeCoordinatesService
|
|
|
'elapsed_ms' => isset($startedAt) ? round((microtime(true) - $startedAt) * 1000, 2) : null,
|
|
|
'found' => $coordinates !== null,
|
|
|
'coordinates' => $coordinates,
|
|
|
+ 'body' => $coordinates === null && $response instanceof Response
|
|
|
+ ? $response->json()
|
|
|
+ : null,
|
|
|
]);
|
|
|
|
|
|
$this->remember($zipCode, $coordinates);
|
|
|
@@ -285,6 +288,7 @@ class ZipCodeCoordinatesService
|
|
|
'elapsed_ms' => round((microtime(true) - $startedAt) * 1000, 2),
|
|
|
'found' => $coordinates !== null,
|
|
|
'coordinates' => $coordinates,
|
|
|
+ 'body' => $coordinates === null ? $response->json() : null,
|
|
|
]);
|
|
|
|
|
|
return $coordinates;
|
|
|
@@ -323,8 +327,10 @@ class ZipCodeCoordinatesService
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- $latitude = $response->json('location.coordinates.latitude');
|
|
|
- $longitude = $response->json('location.coordinates.longitude');
|
|
|
+ $coordinates = $response->json('location.coordinates');
|
|
|
+
|
|
|
+ $latitude = is_array($coordinates) ? ($coordinates['latitude'] ?? $coordinates[1] ?? null) : null;
|
|
|
+ $longitude = is_array($coordinates) ? ($coordinates['longitude'] ?? $coordinates[0] ?? null) : null;
|
|
|
|
|
|
if (! is_numeric($latitude) || ! is_numeric($longitude)) {
|
|
|
return null;
|