API for evaluating transactions against direct-to-consumer Beverage Alcohol shipping regulations.
This API is currently in beta.
PHP 7.3 and later. Should also work with PHP 8.0 but has not been tested.
To install the bindings via Composer, add the following to composer.json
:
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/GIT_USER_ID/GIT_REPO_ID.git"
}
],
"require": {
"GIT_USER_ID/GIT_REPO_ID": "*@dev"
}
}
Then run composer install
Download the files and include autoload.php
:
<?php
require_once('/path/to/OpenAPIClient-php/vendor/autoload.php');
Please follow the installation procedure and then run the following:
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure HTTP OAUTH2 Access Token and other config options
$config = new \Avalara\SDK\Configuration();
$config->setBearerToken('YOUR_JWT_ACCESS_TOKEN');
$config->setAppName('YOUR_APP_NAME');
$config->setEnvironment('sandbox');
$config->setMachineName('YOUR_MACHINE_NAME');
$config->setAppVersion('YOUR_APP_VERSION');
$client = new \Avalara\SDK\ApiClient($config);
$apiInstance = new Avalara\\SDK\Api\AddressesApi($client);
$x_avalara_client = 'Swagger UI; 22.7.0; Custom; 1.0'; // string | Identifies the software you are using to call this API. For more information on the client header, see [Client Headers](https://developer.avalara.com/avatax/client-headers/) .
$body = new \Avalara\\SDK\Model\\Avatax\AddressValidationInfo(); // \Avalara\\SDK\Model\\Avatax\AddressValidationInfo | The address to resolve
try {
$result = $apiInstance->resolveAddressPost($x_avalara_client, $body);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling AddressesApi->resolveAddressPost: ', $e->getMessage(), PHP_EOL;
}
Authentication schemes defined for the API:
- Type: OAuth
- Flow: client_credentials
- Scopes:
- avatax_api: avatax_api scope.
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure HTTP OAUTH2 Client Credentials Flow and other config options
$config = new \Avalara\SDK\Configuration();
$config->setClientId('YOUR_CLIENT_ID');
$config->setClientSecret('YOUR_CLIENT_SECRET');
$config->setAppName('YOUR_APP_NAME');
$config->setEnvironment('sandbox');
$config->setMachineName('YOUR_MACHINE_NAME');
$config->setAppVersion('YOUR_APP_VERSION');
$client = new \Avalara\SDK\ApiClient($config);
$apiInstance = new Avalara\\SDK\Api\AddressesApi($client);
$x_avalara_client = 'Swagger UI; 22.7.0; Custom; 1.0'; // string | Identifies the software you are using to call this API. For more information on the client header, see [Client Headers](https://developer.avalara.com/avatax/client-headers/) .
$body = new \Avalara\\SDK\Model\\Avatax\AddressValidationInfo(); // \Avalara\\SDK\Model\\Avatax\AddressValidationInfo | The address to resolve
try {
$result = $apiInstance->resolveAddressPost($x_avalara_client, $body);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling AddressesApi->resolveAddressPost: ', $e->getMessage(), PHP_EOL;
}
- Type: OAuth
- Flow: device_code
- Scopes:
- avatax_api: avatax_api scope.
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure HTTP OAUTH2 Device Code Flow and other config options
$config = new \Avalara\SDK\Configuration();
$config->setClientId('YOUR_CLIENT_ID');
$config->setAppName('YOUR_APP_NAME');
$config->setEnvironment('sandbox');
$config->setMachineName('YOUR_MACHINE_NAME');
$config->setAppVersion('YOUR_APP_VERSION');
// Fetch Device Code
$result = \Avalara\SDK\Auth\OAuthHelper::initiateDeviceAuthorizationFlow('avatax_api', $config);
// User Interaction needs to happen here - some polling logic is needed to wait for offline user to authenticate to verification_uri through browser
$tokenResult = \Avalara\SDK\Auth\OAuthHelper::getAccessTokenForDeviceFlow($result->deviceCode, $config);
// Once user authenticates, tokenResult will contain Bearer token.
$config->setBearerToken($tokenResult->accessToken);
$client = new \Avalara\SDK\ApiClient($config);
$apiInstance = new Avalara\\SDK\Api\AddressesApi($client);
$x_avalara_client = 'Swagger UI; 22.7.0; Custom; 1.0'; // string | Identifies the software you are using to call this API. For more information on the client header, see [Client Headers](https://developer.avalara.com/avatax/client-headers/) .
$body = new \Avalara\\SDK\Model\\Avatax\AddressValidationInfo(); // \Avalara\\SDK\Model\\Avatax\AddressValidationInfo | The address to resolve
try {
$result = $apiInstance->resolveAddressPost($x_avalara_client, $body);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling AddressesApi->resolveAddressPost: ', $e->getMessage(), PHP_EOL;
}
To run the tests, use:
composer install
vendor/bin/phpunit
All PSR-3 compatible loggers are supported by the SDK.
Declare whichever PSR-3 logger that you desire and pass it in via the configuration object. The example below uses Monolog
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
$config = new \Avalara\SDK\Configuration();
// Configure logger
$logger = new Logger('AddressLogger');
$logger->pushHandler(new StreamHandler(__DIR__ . '/../../app.log', Logger::DEBUG));
// Setup log options , first parameter is logRequestAndResponseBody, which can be true|false. Second parameter is the PSR-3 compatible logger.
$logOptions = new \Avalara\SDK\Utils\LogOptions(true, $logger);
$config->setLogOptions($logOptions);
$client = new \Avalara\SDK\ApiClient($config);
This PHP package is automatically generated by the OpenAPI Generator project:
- API version:
v2
- Package version:
2.5.0
- Package version:
- Build package:
org.openapitools.codegen.languages.PhpClientCodegen
Class | Method | HTTP request | Description |
---|---|---|---|
DataInputFieldsApi | getDataInputFields | GET /data-input-fields | Returns the mandatory and conditional invoice or creditnote input fields for different country mandates |
DocumentsApi | downloadDocument | GET /documents/{documentId}/$download | Returns a copy of the document |
DocumentsApi | getDocumentList | GET /documents | Returns a summary of documents for a date range |
DocumentsApi | getDocumentStatus | GET /document/{documentId}/status | Checks the status of a document |
DocumentsApi | submitDocument | POST /documents | Submits a document to Avalara E-Invoicing API |
MandatesApi | getMandates | GET /mandates | List country mandates that are supported by the Avalara E-Invoicing platform |
- Avalara\SDK\Model\EInvoicing\V1\BadDownloadRequest
- Avalara\SDK\Model\EInvoicing\V1\BadRequest
- Avalara\SDK\Model\EInvoicing\V1\ConditionalForField
- Avalara\SDK\Model\EInvoicing\V1\DataInputField
- Avalara\SDK\Model\EInvoicing\V1\DataInputFieldNotUsedFor
- Avalara\SDK\Model\EInvoicing\V1\DataInputFieldOptionalFor
- Avalara\SDK\Model\EInvoicing\V1\DataInputFieldRequiredFor
- Avalara\SDK\Model\EInvoicing\V1\DataInputFieldsResponse
- Avalara\SDK\Model\EInvoicing\V1\DocumentListResponse
- Avalara\SDK\Model\EInvoicing\V1\DocumentStatusResponse
- Avalara\SDK\Model\EInvoicing\V1\DocumentSubmissionError
- Avalara\SDK\Model\EInvoicing\V1\DocumentSubmitResponse
- Avalara\SDK\Model\EInvoicing\V1\DocumentSummary
- Avalara\SDK\Model\EInvoicing\V1\ForbiddenError
- Avalara\SDK\Model\EInvoicing\V1\InputDataFormats
- Avalara\SDK\Model\EInvoicing\V1\InternalServerError
- Avalara\SDK\Model\EInvoicing\V1\Mandate
- Avalara\SDK\Model\EInvoicing\V1\MandatesResponse
- Avalara\SDK\Model\EInvoicing\V1\NotFoundError
- Avalara\SDK\Model\EInvoicing\V1\NotUsedForField
- Avalara\SDK\Model\EInvoicing\V1\RequiredWhenField
- Avalara\SDK\Model\EInvoicing\V1\StatusEvent
- Avalara\SDK\Model\EInvoicing\V1\SubmitDocumentData
- Avalara\SDK\Model\EInvoicing\V1\SubmitDocumentMetadata
- Avalara\SDK\Model\EInvoicing\V1\WorkflowIds