Giter VIP home page Giter VIP logo

hellosign-java-sdk's Introduction

⚠ 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("[email protected]", "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", "[email protected]", "George");
request.setCC("Accounting", "[email protected]");
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.

hellosign-java-sdk's People

Contributors

c-t-disher avatar chadselph avatar codylerum avatar dependabot[bot] avatar epricer avatar hellofaxsteve avatar jspaetzel avatar jtreminio-dropbox avatar michaelnlindsay avatar nealfax avatar radhack avatar vaibhavij avatar valery1707 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hellosign-java-sdk's Issues

Handle 409 responses

Per @mveitas:

Handle the case of a 409 response when retrieving signature request files.

I saw that the library is still at 1.7, if this was 1.8, Optional would be a great to use for things like 404s instead of throwing an exception.

set legal_version terms wording via ApiApp?

I noticed today "legal_version": "terms2" didn't work from the client-side Hellosign JS options (thought it used to, weird).
So I was recommended to set it from the server-side sdk/api code.
Wondering is there a way to set the legal_version wording from the java code.
Guessing it should be something like so:
ApiApp api_app = client.getApiApp(client_id);
MyHellosignHelper.setBrandFields(api_app, brandPropertiesFile); //my custom helper class
api_app.setLegalVersion("terms2"); //can you create this?
client.updateApiApp (api_app);

From Nic: "To update to terms 2 please submit a CURL request hitting the
POST /api_app/[:client_id] endpoint".
I didnt see legal_version as a separate param to that POST endpoint, and didn't really think it was one of the white_labeling_options (thought those only applied to only colors).
Is legal_version def in the sdk/api?

Implement reported_for_app_id

A user reports: Also, I can't use your api to check for null [for reported_for_app_id] to ignore this as I don't see that you have implemented the reported_for_app_id field in your java api (but you have implemented, reported_for_account_id). This could be easily added with a simple copy/paste... For now; I am doing my own check; but it would be nice to see in the API.

@cmpaul

Allow adding files to Unclaimed Draft with Template

Since we can now add files to Unclaimed Drafts with Template, we need to either remove the check for type SignatureRequest, or include TemplateSignatureRequest in these places:
https://github.com/HelloFax/hellosign-java-sdk/blob/master/src/main/java/com/hellosign/sdk/resource/UnclaimedDraft.java#L180

    /**
     * Adds a file to the unclaimed draft.
     * 
     * @param file File
     * @throws HelloSignException thrown if there is a problem adding the File.
     */
    public void addFile(File file) throws HelloSignException {
        if (!(request instanceof SignatureRequest)) {
            throw new HelloSignException("Cannot add files to this unclaimed draft");
        }
        ((SignatureRequest) request).addFile(file);
    }

https://github.com/HelloFax/hellosign-java-sdk/blob/master/src/main/java/com/hellosign/sdk/resource/UnclaimedDraft.java#L193

    /**
     * Adds a file to the unclaimed draft at the given document order.
     * 
     * @param file File
     * @param order int
     * @throws HelloSignException thrown if there is a problem adding the File.
     */
    public void addFile(File file, int order) throws HelloSignException {
        if (!(request instanceof SignatureRequest)) {
            throw new HelloSignException("Cannot add files to this unclaimed draft");
        }
        ((SignatureRequest) request).addFile(file, order);
    }

https://github.com/HelloFax/hellosign-java-sdk/blob/master/src/main/java/com/hellosign/sdk/resource/UnclaimedDraft.java#L207

    /**
     * Removes all files from this request.
     * 
     * @throws HelloSignException thrown if there is a problem clearing the
     *         Files
     */
    public void clearFiles() throws HelloSignException {
        if (!(request instanceof SignatureRequest)) {
            throw new HelloSignException("Cannot add files to this unclaimed draft");
        }
        ((SignatureRequest) request).clearDocuments();
    }

Add Editable Merge Fields support

When updating the SDKs to include editable merge fields, please also update the SDK git repos README examples (if necessary) and the following in the API docs:

  • "Send with Template" endpoint example
  • "Send Embedded Signature Request with Template" endpoint example
  • Templates Walkthrough
  • Signature Request Walkthrough -> Using Templates

SDK throws an exception when I try call getApiApp with the App ID

Posting on behalf of Jonathan Weinberg:

Java SDK version 3.4.2 throws com.hellosign.sdk.HelloSignException: org.json.JSONException: JSONObject["oauth"] is not a JSONObject.

This occurs when running the following code and not having oauth enabled for the account:
Event helloSignEvent = new Event(jsonObject); // jsonObject comes from the event callback
HelloSignClient client = new HelloSignClient(helloSignApiKey);
String appId = helloSignEvent.getAppId();
ApiApp apiApp = client.getApiApp(appId); // This throws the exception

​When client.getApiApp(appId) is called, it throws this exception​ referenced above because the oauth property is null, and the SDK seems to be expecting this to be an object. If the callback event would send it as an empty object or if it would handle when the value of the property is null, then that should fix the issue.

Signer Order in embedded template POST ignored

The Signer Order int included in the embedded template draft POST is not honored. There doesn't appear to be an error returned, and the template draft gets created and the claim url is returned in the POST response object as normal, but the Signer Order isn't assigned:

draft.addSignerRole("Tenant1", 1);
draft.addSignerRole("Signer2", 2);

The SignerRoles as passed, but the Signer Order int appears to be ignored.

Submitting form sets multiple content-type header values

Hello,

Submitting forms with v3 HEAD sets two values for content-type. They are currently being set using two different key values.

In most parts of the lib the header value Content-Type is set (note the uppercase), but later in the library, you're transposing header values from the form-data npm module which has a lower case `content-type value set. Because of the way this works we end up with multiple content-type headers, and this breaks other things.

For example, I'm trying to get this to work with a other apps that do a lower case comparison on header values, as it's not part of the standard.

The fix is simple, but I wanted to make sure I knew which content-type value to accept;
Either multipart/form-data; boundary=-..... or
application/x-www-form-urlencoded.

Thanks

Can i have radio button or similar to radio button using Java Code

Reference

Document doc = new Document();
doc.setFile(new File("C:\Users\kuldeepc\Desktop\doc1.pdf"));
FormField cb1 = new FormField();
cb1.setType(FieldType.checkbox);
cb1.setName("CB");
cb1.setSigner(0); // Signer indexes are zero-based
cb1.setHeight(25);
cb1.setWidth(25);
cb1.setPage(1); // 1-based indexing, relative to the document
cb1.setX(100);
cb1.setY(200);
doc.addFormField(cb1);
Is there anything which work same as radio button, i have multiple checkbox but i wants to select only one at a time. Please suggest me

GetEmbeddedTemplateEditUrl with skipSignerRoles and skipSubjectMessage true

Hi,

HelloSignClient#getEmbeddedTemplateEditUrl(String templateId, boolean skipSignerRoles, boolean skipSubjectMessage); with both skipSignerRoles and skipSubjectMessage set to true doesn't seem to work. Using version 3.5.6. Should there be an & in the query parameters if both are true?

Currently running this as workaround:

public String getTemplateEditUrl(String templateId) throws HelloSignException {
EmbeddedResponse ep = client.getEmbeddedTemplateEditUrl(templateId);
return ep.getEditUrl().replace("&force_signer_input=1&force_edit_subject_message=1",
"&skip_signer_roles=1&skip_subject_message=1");
}

Thanks,
Matt

get access to signature_request_id and signature_id fields returned from API in both embedded and non-embedded flow

In the non-embedded flow (send an email to user), I can't access these api vars with the java sdk, but I do see them come across the API in Fiddler.

signature_request->signature_request_id
signature_request->signatures->signature_id
We'd like to store these in our DB. Possible to add in the SDK?

For embedded flow, i can at least access the signature_id with:
```
TemplateSignatureRequest request = new TemplateSignatureRequest();
request.setTemplateId(template_id);
EmbeddedRequest embedReq = new EmbeddedRequest(client_id, request);
SignatureRequest newRequest = (SignatureRequest) client.createEmbeddedRequest(embedReq);
List signatures = newRequest.getSignatures ();
Signature patient_signature = signatures.get (0);
String signature_id = patient_signature.getId ();
EmbeddedResponse response = client.getEmbeddedSignUrl(signature_id);
esign_url = response.getSignUrl();
//hmm not sure i can get the signature_request_id? maybe that should be under request.getId(), but doesn't return anything?


We would like to store this in our DB so possibly in future we can get status with:
GET /signature_request/[:signature_request_id]
We currently use the signature_id in embedded flow to recreate the esign in an email link if the user didn't sign in our original embedded flow.
Just thought would be nice to consistently get both **signature_request_id** and **signature_id** 
on embedded or non-embedded flow.

Signer groups

Good Morning,

Someone know if there is a plan to implement something like "signer groups" for exemplo in cases where there are a group of people and out of that group 1 needs to sign. Futhermore, it could be a husband and a wife. One needs to sign, but once one does, then the signature can be complete.

Thansk.

Create convenience constructor for FormField

This is a bit verbose:

            FormField textField = new FormField();
            textField.setSigner(0);
            textField.setApiId("textfield_1");
            textField.setHeight(25);
            textField.setWidth(300);
            textField.setName("Name");
            textField.setPage(1);
            textField.setIsRequired(true);
            textField.setType(FieldType.text);
            textField.setValidationType(ValidationType.letters_only);
            textField.setX(100);
            textField.setY(100);

Let's add some constructor options to take the minimum required parameters:

  • Type
  • Signer
  • Name (Field Label)
  • x, y coordinates
  • width, height

(this wouldn't be less verbose, but it would be indicative of what's required at least, which isn't real clear right now)

Add retry logic to HTTP requests

When an HTTP request fails, retry with (configurable) exponential back-off and jitter.

This prevents clients from needing to implement retry logic themselves.

correct way to set an Editable (and prefilled) Field?

So in my online template via the Hellosign template drag + drop GUI i setup a field called 'patient_fullname'.
I set its 'Me (when sending)' to signify the API will prefilll it.
I noticed you can't set in the GUI if its editable also (and if so, if its required).

So i have to when i send up the data set if its editable.
The usual code i have for other prefilled fields looks like:
request.setCustomFieldValue ("___patient_fullname___", "John TestingFullname");
but there is no optional params to do something like so (is this correct?):
request.setCustomFieldValue ("___patient_fullname___", "John TestingFullname", "AllowedEditorRole", isRequiredBoolean);

so i had to create a helper class:

public class HellosignCustomFieldHelper
{
    public static void setCustomField (TemplateSignatureRequest request, String key, String value, String editor, boolean isRequired ) {
        CustomField x = new CustomField();
        x.setEditor (editor); //this seems needed to make the field required by the 1 role we assigned to the Template in the GUI settings
        x.setIsRequired (isRequired);
        x.setName (key);
        x.setValue (value);
        //x.setType (FieldType.text);
        request.addCustomField (x);
    }
    public static void setCustomField (TemplateSignatureRequest request, String key, String value) {
        request.setCustomFieldValue (key, value);
    }
}
...
//regular non-editable field
HellosignCustomFieldHelper.setCustomField (request, "___patient_address___", "101 Cool lane");
//convert to editable field; overloaded method
HellosignCustomFieldHelper.setCustomField (request, "___patient_fullname___", "John TestingFullname", "AllowedEditorRole", true);

Does this all look like the correct way to set a prefilled field thats editable by the user (a mix of GUI and non-GUI api setting set via CustomField class)?

Got File_error after I upgraded to latest sdk version 3.3.4

The scenario is that there are two signers need to sign the document, one is using embedded signing, the other one is using email to sign. Since embedded signing doesn't have email sent to the signer, so I'm implementing this by after the first signer signed the document, I create a signature request using the document that the first signer signed and send it to the second signer, so the second signer will receive an email to sign and the document contains the first signer's signature. I saw that in the dashboard, the signature request that I created for the second signer can be sent, but the call back contained error.
It used to work in this way before I upgraded the sdk on Dec 4th. I used to use sdk-3.2.2, now I upgraded to sdk-3.3.4 which should be the latest version. I don't know if this is related to cause this error. Please take a look, thanks!

Api on Java 6

Hi,

I have a project that can not be upgrade to java 7 or 8. This project runs on java 6.

Is there a version of api that runs on java 6?

I did the checkout of the api in my workspace java 6, the method that does not work is this one:

image

on class AbstractHttpRequest.java.

For while, to work around it i had maked some changes on:
https://github.com/wilsoncmartins/hellosign-java-sdk-master-jdk-6

Thanks.

Error creating embedded templates when there are no merge fields

I am seeing the below exception while creating an embedded template using the Java SDK 4.0.3. I see that the request object has "[]" for merge_fields. I this it is because of that. Can you please take a look. I am including screen shots and code snippet from TemplateDraft.java for your reference. I think an empty check on mergeFileds map should fix the issue.

com.hellosign.sdk.HelloSignException: Merge field is missing "name" parameter
	at com.hellosign.sdk.http.HttpClient.validate(HttpClient.java:177)
	at com.hellosign.sdk.http.HttpClient.asJson(HttpClient.java:210)
	at com.hellosign.sdk.HelloSignClient.createEmbeddedTemplateDraft(HelloSignClient.java:939)

image

image

New template endpoint: POST /template/update_files/[:template_id]

Last URI listed here: https://www.hellosign.com/api/reference#Template - POST /template/update_files/[:template_id]

Parameters:
template_id = The ID of the template whose files to update
file[] or file_url[] = Use file[] to pass the uploaded file(s). Use file_url[] to have HelloSign download the file(s). We currently only support use of either the file[] parameter or file_url[] parameter, not both.
subject = (optional) The new default template email subject
message = (optional) The new default template email message
client_id = (optional) Client ID of the app you're using to create this template
test_mode = (optional) Whether this is a test. The signature request created from this template will not be legally binding if set to 1. Defaults to 0.

Returns template_id: [:new_template_id]

Cannot set the API field's label separately than API field's ID/variable name?

Another issue related to how im doing my Editable + Prefilled settings ...
I cannot set the label separately than the API ID variable name.
The java SDK complains (so i can't have something like 'Enter your Full Name' as the label text and 'patient_fullname' as the API ID name):
http://www.screencast.com/t/YFqSBL0Gq

Does that seem wrong? If i make both the label and the variable name the same 'patient_fullname', then the API doesn't complain.

Uploaded files are out of order when signing

When sending a signature request using multiple documents the file order does not remain consistent.

This issue is for the /signature_request/create_embedded and /signature_request/send endpoints

Thank you for your help!

api timeout setting

Noticed today it took minute(s) to connect to hellosign from our servers via the java sdk code I have (maybe issue from our end or your end, not sure yet)... Is there anyway to set a timeout manually with a method of pretend 10seconds so I can control what happens if taking too long/times-out?

Extend proxy capabilities to HttpPostRequest.openMultipartPostConnection

PROBLEM : openMultipartPostConnection() in HttpPostRequest is missing the proxy changes, as done in the getConnection() in the AbstractHttpRequest class

SITUATION:

When sending a signature request with a file, post() method in HttpPostRequest checks if the request has a file, if it does, it sends it to postWithFile() which in turn calls openMultipartPostConnection() in HttpPostRequest, which does not have the proxy logic, and hence I get a cannot connect error.

When sending a signature post request (template) (without a file), post() method in HttpPostRequest checks if the request has a file, as it doesn’t, it calls postQuery() which in turn calls getConnection() in the AbstractHttpRequest class, which has the proxy changes, hence it works.

Allow unused custom fields

I have 2 templates now which I dynamically switch to in the app (and there will be more templates in the future).
One template is for Patients, and the other is for Patient+Caregivers.
so i will always send 10 fields for patients (Firstname, Lastname, etc),
and optionally send an additional 10 fields dynamically if Im also sending Caregiver information (which are collected in 1 form/page in our app).
I will always add 5 more fields for the their Doctor's information (information from another form/page in our app),
and always send over a few special questions pulled elsewhere from our questionnaire (gender, DOB, if they smoke, etc)

Now I dynamically pick one of the 2 templates, then just send all appropriate vars and the template should just use what it needs. But i think the API requires you to use everything you send up otherwise it errors. You cant send extra fields you may use but aren't using currently.

It would be nice if we can allow the developer to send up all their custom vars, and the server will just prefill what the template uses. Otherwise, I have to dynamically figure out which fields I'm sending up for specific templates, and that may not be nice if our Marketing department decides one day they want to display DOB and Gender fields (in TemplatePatient and TemplateCaregiver) and then decide a week later to remove from TemplatePatient (but keep in TemplateCaregiver). It would cause an error to happen for TemplatePatient if Im still sending up the variable.
If the API were to opt-into lax validation of variables, then Marketing could make changes without IT updating the code on which variables to send up. Something like so:

client.checkAllCustomFieldKeyExistance(false); //by default, set to true
request.setCustomFieldValue ('gender', 'Male'); //used
request.setCustomFieldValue ('DOB', '12/17/1982'); //not used, but maybe template updated tomorrow and if so this will be used... at least won't error because checkAllCustomFieldKeyExistance is set
etc

Otherwise I have to check which template im using, and dynamically figure out which fields i want to send upTemplatePatient (which is fine for example for the Caregiver fields which arent applicable to the Patient template, but some fields theoretically could be used at any point in both templates like Gender/DOB/etc).

By Pass Signer

is it possible to have in the document the tags [sig | req | signer0] and [sig | req | signer1], but during sending via api the system not have signer1 and for that reason "say" to api: ignore or by pass in signer1?

NPE when creating HelloSignClient

The constructor of HelloSignClient looks for system properties to override certain configuration but System.getProperty returns null if the property doesn't exist, causing an NPE when it checks if the property is empty.

Upgrade to Java 8

Java 7 reached EOL in April 2015 and is no longer receiving public updates.

This is the primary reason to move to Java 8, but there are other benefits, including lambda support and Optional class support.

Possible to cut a .jar build on a temporary Java6 build?

Is anyway to cut a custom Java6 build for us for the hellosign.jar? I was asked to request this.

I know its absolutely terrible, but some of our servers run older Java6 and we do not want to push our Java8 upgrade build out to our servers yet (that’s scheduled for a few months from now along with our new virtualized servers).

These below classes aren’t available in java6 but heard maybe you can swap them out with some replacement Guava code. Our management was looking for you for guidance.:
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
… bytesWritten = Files.copy(lastResponseStream, f.toPath(), StandardCopyOption.REPLACE_EXISTING);

Thanks!,
Arian

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.