public function AvataxLib::resolveAddress in Drupal Commerce Connector for AvaTax 8
Retrieve geolocation information for a specified address.
Parameters
array $address: The address item.
Return value
array Return AvaTax formatted response.
Overrides AvataxLibInterface::resolveAddress
1 call to AvataxLib::resolveAddress()
- AvataxLib::validateAddress in src/
AvataxLib.php - Validate the give address from Drupal upon AvaTax resolved address.
1 method overrides AvataxLib::resolveAddress()
- AvataxLibTest::resolveAddress in tests/
modules/ commerce_avatax_test/ src/ AvataxLibTest.php - Retrieve geolocation information for a specified address.
File
- src/
AvataxLib.php, line 328
Class
- AvataxLib
- The AvaTax integration library.
Namespace
Drupal\commerce_avataxCode
public function resolveAddress(array $address) {
$request_data = [
'line1' => $address['address_line1'],
'line2' => $address['address_line2'],
'city' => $address['locality'],
'region' => $address['administrative_area'],
'country' => $address['country_code'],
'postalCode' => $address['postal_code'],
];
// Generate cid for cache.
$cid = base64_encode(trim(serialize($request_data)));
if ($cache = $this->cache
->get($cid)) {
return $cache->data;
}
// Set to mixed check.
$request_data['textCase'] = 'Mixed';
$response_body = $this
->doRequest('POST', 'api/v2/addresses/resolve', [
'json' => $request_data,
]);
// Cache the request + the response for 24 hours.
$this->cache
->set($cid, $response_body, time() + 86400);
return $response_body;
}