Acrobat Sign JAVA SDK

The Acrobat Sign SDK supports integrating the Acrobat Sign RESTful web service into client applications via easy-to-consume client side objects wrapping the REST API functionality. This repository contains Acrobat Sign’s JAVA SDK and samples for these APIs.

Prerequisites

For the building of Acrobat Sign Java SDK, the client machine should have the following software installed:

  • OS: Windows/Mac/Linux

  • Java JDK: version 1.8 or above

  • Maven: 3.3.3 version or above

  • Gradle: 2.11 version or above

Requirements for Building the SDK

Building the API client library requires Maven for Java 8 or Gradle for Java (8 or above) to be installed.

Installation

To install the API client library to your local repository:

  1. Generate the JAR either by executing:

mvn package
  1. Manually install the following JARs:

    • target/swagger-java-client-1.0.0.jar

    • target/lib/*.jar

    or

gradle build
  1. Manually install the following JAR: build/libs/swagger-java-client-1.0.0.jar

Getting Started

Acrobat Sign clients must follow these steps:

  1. In order to use the SDK, you need to have an account with Acrobat Sign. Please register for a developer account here.

  2. Sign in to create an application on the Acrobat Sign web portal and obtain it’s application id and application secret.

  3. Generate the OAuth access token by using the above application id and the application secret. The access token will need to be generated by using the OAuth APIs.

  4. Use the generated OAuth access token for trying out the sample API code given below.

  5. Follow the installation instructions and execute the following Java code:

java
import java.io.File;
import io.swagger.client.ApiClient;
import io.swagger.client.ApiException;
import io.swagger.client.api.AgreementsApi;
import io.swagger.client.api.BaseUrisApi;
import io.swagger.client.api.TransientDocumentsApi;
import io.swagger.client.model.AgreementCreationResponse;
import io.swagger.client.model.AgreementInfo;
import io.swagger.client.model.BaseUriInfo;
import io.swagger.client.model.FileInfo;
import io.swagger.client.model.ParticipantSetInfo;
import io.swagger.client.model.ParticipantSetMemberInfo;
import io.swagger.client.model.TransientDocumentResponse;

/**
* This sample client demonstrates how to send a new agreement.
* <p>
* <p>
* Following workflow has been implemented here :
* <li> Call base uris api to fetch api access point to invoke further API calls.</li>
* <li> Create a transient document and get transient document id.</li>
* <li> Prepare agreement info and create an agreement using the transient document.</li>
* <li> Send the agreement.</li>
* <li> Display agreement details.</li>
* </p>
*/
public class SendAgreementUsingTransientDocument {

/**
* Entry point for this sample client program.
*/
public static void main(String[] args) {

    try {
    ApiClient apiClient = new ApiClient();

            //Default baseUrl to make GET /baseUris API call.
            String baseUrl = "https://api.echosign.com/";
            String endpointUrl = "/api/rest/v6";
            apiClient.setBasePath(baseUrl + endpointUrl);

            //TODO : Provide an OAuth Access Token as "Bearer : access token" in authorization
            String authorization = "authorization_example";

            //Get the baseUris for the user and set it in apiClient.
            BaseUrisApi baseUrisApi = new BaseUrisApi(apiClient);
            BaseUriInfo baseUriInfo = baseUrisApi.getBaseUris(authorization);
            apiClient.setBasePath(baseUriInfo.getApiAccessPoint() + endpointUrl);

            //TODO : Provide path and name of file to be uploaded as transient document
            String filePath = "filePath_example";
            String fileName = "fileName_example";
            File file = new File(filePath + fileName);
            String xApiUser = null;
            String xOnBehalfOfUser = null;
            String mimeType = "application/pdf";

            //Get the id of the transient document.
            TransientDocumentsApi transientDocumentsApi = new TransientDocumentsApi(apiClient);
            TransientDocumentResponse response = transientDocumentsApi.createTransientDocument(authorization, file, xApiUser, xOnBehalfOfUser, fileName, mimeType);
            String transientDocumentId = response.getTransientDocumentId();

            //prepare request body for agreement creation.
            AgreementInfo agreementInfo = new AgreementInfo();
            agreementInfo.setName("Sample_Agreement");
            agreementInfo.setSignatureType(AgreementInfo.SignatureTypeEnum.ESIGN);
            agreementInfo.setState(AgreementInfo.StateEnum.DRAFT);

            FileInfo fileInfo = new FileInfo();
            fileInfo.setTransientDocumentId(transientDocumentId);
            agreementInfo.addFileInfosItem(fileInfo);

            ParticipantSetInfo participantSetInfo = new ParticipantSetInfo();
            ParticipantSetMemberInfo participantSetMemberInfo = new ParticipantSetMemberInfo();

            //TODO : Provide email of recipient to whom agreement will be sent
            participantSetMemberInfo.setEmail("email_example");
            participantSetInfo.addMemberInfosItem(participantSetMemberInfo);
            participantSetInfo.setOrder(1);
            participantSetInfo.setRole(ParticipantSetInfo.RoleEnum.SIGNER);
            agreementInfo.addParticipantSetsInfoItem(participantSetInfo);

            //Create agreement using the transient document.
            AgreementsApi agreementsApi = new AgreementsApi(apiClient);
            AgreementCreationResponse agreementCreationResponse = agreementsApi.createAgreement(authorization, agreementInfo, xApiUser, xOnBehalfOfUser);
            String id = agreementCreationResponse.getId();

            //Get agreement info using the agreement id.
            String ifNoneMatch = null;
            agreementInfo = agreementsApi.getAgreementInfo(authorization, id, xApiUser, xOnBehalfOfUser, ifNoneMatch);
            System.out.println("Agreement ID = " + agreementInfo.getId());
            System.out.println("Agreement Name = " + agreementInfo.getName());
            System.out.println("Agreement Status = " + agreementInfo.getStatus());

    }
    catch (ApiException e) {
    System.err.println(e.toString());
    }
}
}

Recommendation

It’s recommended to create an instance of ApiClient per thread and per user (with baseUris fetched for user) in a multithreaded environment to avoid any potential issues.

JAVA SDK Docs and downloads

Reporting issues

Please report issues on the Acrobat Sign Developer Forum.