callApi(['key' => $this->api_key, 'address' => $this->address]); if($response->successful()) return $response->json(); if($this->postal_code) { $response = $this->callApi(['key' => $this->api_key, 'address' => $this->postal_code]); if($response->successful()) return $response->json(); } $response->throw(); } /** * callApi * * @param array $parameters * @return Response */ private function callApi(array $parameters): Response { $response = Http::retry(3, 1000)->withHeaders([])->get($this->endpoint, $parameters); return $response; } }