Skip to content
This repository has been archived by the owner on Oct 17, 2023. It is now read-only.

hellosign/hellosign-java-sdk

Repository files navigation

⚠ This SDK has been deprecated ⚠

This SDK is now deprecated and will no longer receive feature updates or bug fixes. Security fixes will still be applied as needed.

The new dropbox-sign SDK can be found at hellosign/dropbox-sign-java!

The new SDK and this legacy SDK are not backwards-compatible!

Please see here for a comprehensive migration guide.


HelloSign Java SDK

Build Status Maven Central Javadocs

Get your Java app connected to HelloSign's API in jiffy.

To build this project you'll need JDK 9+ but the release artifacts support JRE 8+.

Installing

SDK releases are published to Maven's Central repository:

<dependency>
  <groupId>com.hellosign</groupId>
  <artifactId>hellosign-java-sdk</artifactId>
  <version>RELEASE</version>
</dependency>

Releases can also be consumed using other build tools that support Maven Central.

Gradle for example:

repositories {
    mavenCentral()
}

dependencies {
    compile group: 'com.hellosign', name: 'hellosign-java-sdk', version:'RELEASE'
}

Alternatively, you can build the JAR yourself:

./gradlew jar

or a fatJar with all dependencies if you'd like:

./gradlew fatJar

Place build/libs/hellosign-java-sdk-<VERSION>.jar on your project classpath.

Usage

First initialize an instance of the HelloSignClient with your API key:

HelloSignClient client = new HelloSignClient(apiKey);

Send a Signature Request

SignatureRequest request = new SignatureRequest();
request.setSubject("NDA");
request.setMessage("Hi Jack, Please sign this NDA and let's discuss.");
request.addSigner("jack@example.com", "Jack");
request.addFile(new File("nda.pdf"));

SignatureRequest response = client.sendSignatureRequest(request);
System.out.println(response.toString());

Add Signer Fields to a Signature Request

SignatureRequest request = new SignatureRequest();
Document doc = new Document();
doc.setFile(new File("/path/to/myfile.pdf")));

FormField textField = new FormField();
textField.setType(FieldType.TEXT);
textField.setName("First Name"); // Displayed to the signer as the "Field Label"
textField.setValidationType(ValidationType.letters_only);
textField.setSigner(0); // Signer indexes are zero-based
textField.setHeight(25);
textField.setWidth(300);
textField.setIsRequired(true);
textField.setPage(1); // 1-based indexing, relative to the document
textField.setX(100);
textField.setY(100);

doc.addFormField(textField);
request.addDocument(doc);

Retrieve Templates

TemplateList templateList = client.getTemplates();
for (Template template : templateList) {
    System.out.println(template.getTitle());
}

Or filter the paged list:

TemplateList templateList = client.getTemplates();
List<Template> filteredList = templateList.filterCurrentPageBy(Template.TEMPLATE_TITLE, "W-2 Template");
for (Template template : filteredList) {
    System.out.println(template.getTitle());
}

Send a Templated Signature Request

TemplateSignatureRequest request = new TemplateSignatureRequest();
request.setTemplateId(templateId);
request.setSigner("Client", "george@example.com", "George");
request.setCC("Accounting", "accounting@hellosign.com");
request.addCustomFieldValue("Cost", "$20,000");

SignatureRequest response = client.sendTemplateSignatureRequest(request);
System.out.println(response.toString());

Check Signature Request Status

While we encourage you to take advantage of our callback functionality, you can also retrieve the status of a specific request:

SignatureRequest response = client.getSignatureRequest(signatureRequestId);
if (response.isComplete()) {
    System.out.println("All signers have signed this request.");
} else {
    for (Signature signature : response.getSignatures()) {
        System.out.println(signature.getStatusString());
    }
}

Reference

License

The MIT License (MIT)

Copyright (C) 2020 hellosign.com

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.