avalara / avalara_sdk
API for evaluating transactions against direct-to-consumer Beverage Alcohol shipping regulations. This API is currently in beta.
Requires
- php: ^7.3 || ^8.0
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.3
- guzzlehttp/psr7: ^1.9.1 || ^2.4.5
- php-ds/php-ds: ^1.4
- psr/log: ^3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.12
- guzzlehttp/promises: ^1.4
- monolog/monolog: ^3.2
- phpunit/phpunit: ^8.0 || ^9.0
- vlucas/phpdotenv: ^5.4
README
Unified SDK consists of services on top of which the Avalara Compliance Cloud platform is built. These services are foundational and provide functionality such as einvoicing.
Installation & Usage
Requirements
PHP 7.3 and later. Should also work with PHP 8.0 but has not been tested.
Composer
To install the bindings via Composer, add the following to composer.json
:
{ "repositories": [ { "type": "vcs", "url": "https://github.com/avadev/Avalara-SDK-PHP.git" } ], "require": { "avalara/avalara_sdk": "24.12.1" } }
Then run composer install
Getting Started
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\EInvoicing\V1\MandatesApi($client); $request_options = new \Avalara\SDK\API\EInvoicing\V1\GetMandatesRequest(); $request_options->setXAvalaraClient('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/) . try { $result = $apiInstance->getMandates($request_options); print_r("Result: ". $result); } catch (Exception $e) { echo 'Exception when calling AddressesApi->resolveAddressPost: ', $e->getMessage(), PHP_EOL; }
Tests
To run the tests, use:
composer install vendor/bin/phpunit
Logging
All PSR-3 compatible loggers are supported by the SDK.
Usage
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);
Documentation for API Endpoints
EInvoicing V1 API Documentation
Documentation for Models
EInvoicing V1 Model Documentation
- Avalara\SDK\Model\EInvoicing\V1\BadDownloadRequest
- Avalara\SDK\Model\EInvoicing\V1\BadRequest
- Avalara\SDK\Model\EInvoicing\V1\BatchSearch
- Avalara\SDK\Model\EInvoicing\V1\BatchSearchListResponse
- 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\DirectorySearchResponse
- Avalara\SDK\Model\EInvoicing\V1\DirectorySearchResponseValueInner
- Avalara\SDK\Model\EInvoicing\V1\DirectorySearchResponseValueInnerAddressesInner
- Avalara\SDK\Model\EInvoicing\V1\DirectorySearchResponseValueInnerIdentifiersInner
- Avalara\SDK\Model\EInvoicing\V1\DirectorySearchResponseValueInnerSupportedDocumentTypesInner
- Avalara\SDK\Model\EInvoicing\V1\DocumentFetch
- Avalara\SDK\Model\EInvoicing\V1\DocumentFetchRequest
- Avalara\SDK\Model\EInvoicing\V1\DocumentFetchRequestDataInner
- Avalara\SDK\Model\EInvoicing\V1\DocumentFetchRequestMetadata
- 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\ErrorResponse
- 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\MandateDataInputField
- Avalara\SDK\Model\EInvoicing\V1\MandateDataInputFieldNamespace
- 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\SubmitDocumentMetadata
- Avalara\SDK\Model\EInvoicing\V1\SubmitInteropDocument202Response
- Avalara\SDK\Model\EInvoicing\V1\WorkflowIds