You are here

public function Avatax::__construct in Drupal Commerce Connector for AvaTax 7.5

Initializes the API credential properties and cURL handle.

Parameters

string $apiKey: The API key defined that is used to authenticate against the API.

string $apiMode: The API mode (dev|prod), used to determine the endpoint to call.

string $logger: A callable used to log API request / response messages. Leave empty if logging is not needed.

array $headers: Allow specifying additional HTTP headers that are going to be sent.

File

lib/Avatax.php, line 50
Defines a class for consuming the Avatax API.

Class

Avatax
Defines the Avatax class.

Code

public function __construct($apiKey, $apiMode = 'dev', $logger = NULL, $headers = array()) {

  // Initialize the API credential properties.
  $this->apiKey = $apiKey;
  $this->apiMode = $apiMode;
  $this->logger = $logger;
  $this->headers = array_merge($headers, array(
    'Authorization' => 'Basic ' . $apiKey,
    'Content-Type' => 'application/json',
    'x-Avalara-UID' => 'a0o33000003waOC',
  ));

  // Initialize the cURL handle.
  $this->ch = curl_init();
  $this
    ->setDefaultCurlOptions();
}