Skip to content

avadev/Avalara-SDK-Java

Repository files navigation

Avalara.SDK - the Unified Java SDK for next gen Avalara services.

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.

Requirements

Building the API client library requires:

  1. Java 1.7+
  2. Maven/Gradle

Installation

To install the API client library to your local Maven repository, simply execute:

mvn clean install

To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:

mvn clean deploy

Refer to the OSSRH Guide for more information.

Maven users

Add this dependency to your project's POM:

<dependency>
  <groupId>net.avalara</groupId>
  <artifactId>avalara-sdk</artifactId>
  <version>24.12.0</version>
  <scope>compile</scope>
</dependency>

Gradle users

Add this dependency to your project's build file:

  repositories {
  mavenCentral()
  mavenLocal()
}

dependencies {
  implementation 'net.avalara:avalara-sdk:24.12.0'
}

Getting Started

Please follow the installation instruction and execute the following Java code:

import Avalara.SDK.*;
import Avalara.SDK.api.EInvoicing.V1.*;
import Avalara.SDK.model.EInvoicing.V1.*;

public class MandatesApiExample {

  public static void main(String[] args) {
      Configuration configuration = new Configuration();
      configuration.setAppName("Test");
      configuration.setAppVersion("1.0");
      configuration.setMachineName("LocalBox");
      configuration.setTimeout(5000);
      configuration.setEnvironment(AvaTaxEnvironment.Sandbox);
      // Configure OAuth2 access token for authorization
      configuration.setBearerToken("YOUR ACCESS TOKEN");

      try {
          ApiClient apiClient = new ApiClient(configuration);
          Avalara.SDK.api.EInvoicing.V1.MandatesApi apiInstance = new MandatesApi(apiClient);
          String xAvalaraClient = "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/) .
          MandatesApi.GetMandatesRequest request = apiInstance.getGetMandatesRequest();
          request.setXAvalaraClient(xAvalaraClient);
          MandatesResponse result = apiInstance.getMandates(request);
          System.out.println(result);
      } catch (ApiException e) {
          System.err.println("Exception when calling MandatesAPI#getMandates");
          System.err.println("Status code: " + e.getCode());
          System.err.println("Reason: " + e.getResponseBody());
          System.err.println("Response headers: " + e.getResponseHeaders());
          e.printStackTrace();
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
}

Recommendation

It's recommended to create an instance of ApiClient per thread in a multithreaded environment to avoid any potential issues.

Documentation for API Endpoints

EInvoicing V1 API Documentation

Class Method HTTP request Description
DataInputFieldsApi getDataInputFields GET /data-input-fields Returns the optionality of document fields for different country mandates
DocumentsApi downloadDocument GET /documents/{documentId}/$download Returns a copy of the document
DocumentsApi fetchDocuments POST /documents/$fetch Fetch the inbound document from a tax authority
DocumentsApi getDocumentList GET /documents Returns a summary of documents for a date range
DocumentsApi getDocumentStatus GET /documents/{documentId}/status Checks the status of a document
DocumentsApi submitDocument POST /documents Submits a document to Avalara E-Invoicing API
InteropApi submitInteropDocument POST /interop/documents Submit a document
MandatesApi getMandateDataInputFields GET /mandates/{mandateId}/data-input-fields Returns document field information for a country mandate, a selected document type, and its version
MandatesApi getMandates GET /mandates List country mandates that are supported by the Avalara E-Invoicing platform
TradingPartnersApi batchSearchParticipants POST /trading-partners/batch-searches Creates a batch search and performs a batch search in the directory for participants in the background.
TradingPartnersApi downloadBatchSearchReport GET /trading-partners/batch-searches/{id}/$download-results Download batch search results in a csv file.
TradingPartnersApi getBatchSearchDetail GET /trading-partners/batch-searches/{id} Get the batch search details for a given id.
TradingPartnersApi listBatchSearches GET /trading-partners/batch-searches List all batch searches that were previously submitted.
TradingPartnersApi searchParticipants GET /trading-partners Returns a list of participants matching the input query.

Documentation for Models

EInvoicing V1 Model Documentation