$address_string, 'auth-id' => $this->setting->get('smarty_streets_auth_id'), 'auth-token' => $this->setting->get('smarty_streets_auth_token') ]); } else { $url = 'https://international-street.api.smartystreets.com/verify'; $url .= '?' . http_build_query([ 'freeform' => $address_string, 'country' => $country, 'geocode' => 'true', 'auth-id' => $this->setting->get('smarty_streets_auth_id'), 'auth-token' => $this->setting->get('smarty_streets_auth_token') ]); } $curl_response = $this->curl([ 'url' => $url ]); $response = json_decode($curl_response, true); if ($response === null) { throw new Exception('Invalid JSON'); } if (count($response) === 0) { return null; } else { // Smarty doesn't return this but I want it. if($country === 'USA') { $response[0]['components']['country_iso_3'] = 'USA'; } return $response[0]; } } /** * Generate a cache key from a URL. Just hashes it. * * @param array $arguments * * @return string */ protected function generate_cache_key($arguments) { return sha1($arguments['url']); } /** * Determine whether or not a request should be cached. For this, just cache * everything. * * @param array $arguments * * @return boolean */ protected function should_cache($arguments) { return true; } }