Package com.logicaldoc.docusign
Class DocuSign
- java.lang.Object
-
- com.logicaldoc.docusign.DocuSign
-
public class DocuSign extends Object
Facade over the DocuSign eSignature online platform.- Since:
- 8.5
- Author:
- Marco Meschieri - LogicalDOC
-
-
Field Summary
Fields Modifier and Type Field Description static String
COMPANY
Type of a note that represents a Company tabstatic String
DATE
Type of a note that represents a Date tabstatic String
DATE_SIGNED
Type of a note that represents a DateSigned tabstatic String
EMAIL
Type of a note that represents a Email tab to input an email addressstatic String
EMAIL_ADDRESS
Type of a note that represents a Email Address tab to print the recipients's emailstatic String
ENVELOPE_ID
Type of a note that represents a EnvelopeId tabstatic String
FULL_NAME
Type of a note that represents a FullName tabstatic String[]
NOTE_TYPES
The different types of document notes used to model DocuSing tabsstatic String
SIGN_HERE
Type of a note that represents a SignHere tabstatic String
TEXT
Type of a note that represents a Text tabstatic String
TITLE
Type of a note that represents a Title tab
-
Constructor Summary
Constructors Constructor Description DocuSign(long userId)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
downloadDocument(String envelopeId, String docId, File out)
Downloads a document from an envelope into a local fileString
getAccessToken()
String
getAccountId()
String
getApiBaseUrl()
String
getAuthBaseUrl()
String
getAuthorizationUrl()
This is the first authentication step to be used when it is the first time you connect or when the previous access token has expired.String
getCallbackUrl()
String
getCustomValue(String envelopeId, String fieldName)
Map<String,String>
getCustomValues(String envelopeId)
Retrieves the custom fields of an envelopecom.docusign.esign.model.Envelope
getEnvelope(String envelopeId)
Retrieves a single envelopeString
getIntegrationKey()
String
getLastProcessed()
String
getRefreshToken()
String
getSecretKey()
long
getUserId()
List<com.docusign.esign.model.EnvelopeDocument>
listDocuments(String envelopeId)
Retrieves the list of the documents enclosed in an envelopeList<com.docusign.esign.model.Envelope>
listEnvelopes(String status)
Retrieves the envelopes generated by the current user after the last processed dateList<com.docusign.esign.model.Envelope>
listEnvelopes(String from, String status)
Retrieves the envelopes generated by the current userList<String>
listSigners(String envelopeId)
Retrieves the list of signers of an envelopevoid
retrieveAccessToken()
Shortcut for retrieveAccessToken(null);void
retrieveAccessToken(String authorizationToken)
This is the second step of the authentication process.void
saveSettings()
Saves the DocuSign settingsString
sendEnvelope(List<com.logicaldoc.core.document.Document> documents, com.logicaldoc.core.document.DocumentHistory transaction, String subject, String body, Date expire)
Prepares and sends an envelope to DocuSignvoid
setAccessToken(String accessToken)
Sets the access tokenvoid
setAccountId(String accountId)
void
setApiBaseUrl(String apiBaseUrl)
void
setAuthBaseUrl(String authBaseUrl)
void
setIntegrationKey(String integrationKey)
void
setLastProcessed(String date)
void
setRefreshToken(String refreshToken)
Sets the refresh tokenvoid
setSecretKey(String secretKey)
-
-
-
Field Detail
-
SIGN_HERE
public static String SIGN_HERE
Type of a note that represents a SignHere tab
-
TEXT
public static String TEXT
Type of a note that represents a Text tab
-
DATE
public static String DATE
Type of a note that represents a Date tab
-
COMPANY
public static String COMPANY
Type of a note that represents a Company tab
-
DATE_SIGNED
public static String DATE_SIGNED
Type of a note that represents a DateSigned tab
-
TITLE
public static String TITLE
Type of a note that represents a Title tab
-
FULL_NAME
public static String FULL_NAME
Type of a note that represents a FullName tab
-
ENVELOPE_ID
public static String ENVELOPE_ID
Type of a note that represents a EnvelopeId tab
-
EMAIL
public static String EMAIL
Type of a note that represents a Email tab to input an email address
-
EMAIL_ADDRESS
public static String EMAIL_ADDRESS
Type of a note that represents a Email Address tab to print the recipients's email
-
NOTE_TYPES
public static String[] NOTE_TYPES
The different types of document notes used to model DocuSing tabs
-
-
Method Detail
-
sendEnvelope
public String sendEnvelope(List<com.logicaldoc.core.document.Document> documents, com.logicaldoc.core.document.DocumentHistory transaction, String subject, String body, Date expire) throws Exception
Prepares and sends an envelope to DocuSign- Parameters:
documents
- collection of documents in the envelopetransaction
- transaction informationssubject
- subject of the email that notifies the signersbody
- object of the email that notifies the signersexpire
- optional expiration date for the envelope- Returns:
- identifier of the created envelope
- Throws:
Exception
- error creating the envelope or communicating with DocuSign
-
getEnvelope
public com.docusign.esign.model.Envelope getEnvelope(String envelopeId) throws com.docusign.esign.client.ApiException
Retrieves a single envelope- Parameters:
envelopeId
- unique identifier of the envelope- Returns:
- the envelope instance
- Throws:
com.docusign.esign.client.ApiException
- Error communicating with DocuSign
-
listEnvelopes
public List<com.docusign.esign.model.Envelope> listEnvelopes(String status) throws com.docusign.esign.client.ApiException
Retrieves the envelopes generated by the current user after the last processed date- Parameters:
status
- optional status to use as search criteria- Returns:
- list of envelopes
- Throws:
com.docusign.esign.client.ApiException
- Error communicating with DocuSign
-
listEnvelopes
public List<com.docusign.esign.model.Envelope> listEnvelopes(String from, String status) throws com.docusign.esign.client.ApiException
Retrieves the envelopes generated by the current user- Parameters:
from
- optional creation date to use as search criteria (use the RFC3339 format)status
- optional status to use as search criteria- Returns:
- list of envelopes
- Throws:
com.docusign.esign.client.ApiException
- Error communicating with DocuSign
-
getCustomValue
public String getCustomValue(String envelopeId, String fieldName) throws com.docusign.esign.client.ApiException
- Throws:
com.docusign.esign.client.ApiException
-
listSigners
public List<String> listSigners(String envelopeId) throws com.docusign.esign.client.ApiException
Retrieves the list of signers of an envelope- Parameters:
envelopeId
- identifier of the envelope- Returns:
- list of the emails of all the signers
- Throws:
com.docusign.esign.client.ApiException
- Error communicating with DocuSign
-
getCustomValues
public Map<String,String> getCustomValues(String envelopeId) throws com.docusign.esign.client.ApiException
Retrieves the custom fields of an envelope- Parameters:
envelopeId
- identifier of the envelope- Returns:
- The map of values
- Throws:
com.docusign.esign.client.ApiException
- Error communicating with DocuSign
-
listDocuments
public List<com.docusign.esign.model.EnvelopeDocument> listDocuments(String envelopeId) throws com.docusign.esign.client.ApiException
Retrieves the list of the documents enclosed in an envelope- Parameters:
envelopeId
- identifier of the envelope- Returns:
- the list of contained documents
- Throws:
com.docusign.esign.client.ApiException
- Error communicating with DocuSign
-
downloadDocument
public void downloadDocument(String envelopeId, String docId, File out) throws com.docusign.esign.client.ApiException, IOException
Downloads a document from an envelope into a local file- Parameters:
envelopeId
- identifier of the envelopedocId
- identifier of the file inside the envelopeout
- file where the contents have to be written- Throws:
com.docusign.esign.client.ApiException
- Error communicating with DocuSignIOException
- Error writing the file
-
getAuthorizationUrl
public String getAuthorizationUrl()
This is the first authentication step to be used when it is the first time you connect or when the previous access token has expired. Generates the URL to request the authorization code the user must be redirected to. See https://developers.docusign.com/platform/auth/authcode.- Returns:
- the URL to redirect the user to
-
retrieveAccessToken
public void retrieveAccessToken() throws IOException, com.logicaldoc.core.security.authentication.AuthenticationException
Shortcut for retrieveAccessToken(null);- Throws:
IOException
- A communication errorcom.logicaldoc.core.security.authentication.AuthenticationException
- The user was not authenticated by DocuSign, probably this means you need another authorization code
-
retrieveAccessToken
public void retrieveAccessToken(String authorizationToken) throws IOException, com.logicaldoc.core.security.authentication.AuthenticationException
This is the second step of the authentication process. Invoke this method before invoking the others. If a refresh token is available, then it is used to get the access token, otherwise a new access token is asked using the authorization code previously saved bygetAuthorizationUrl()
.
for a test access token see https://developers.docusign.com/oauth-token-generator
See also https://developers.docusign.com/esign-rest-api/guides/authentication/oauth2-code-grant- Parameters:
authorizationToken
- optional authorization code- Throws:
IOException
- A communication errorcom.logicaldoc.core.security.authentication.AuthenticationException
- The user was not authenticated by DocuSign, probably this means you need another authorization code
-
saveSettings
public void saveSettings()
Saves the DocuSign settings
-
getApiBaseUrl
public String getApiBaseUrl()
-
setApiBaseUrl
public void setApiBaseUrl(String apiBaseUrl)
-
getAuthBaseUrl
public String getAuthBaseUrl()
-
setAuthBaseUrl
public void setAuthBaseUrl(String authBaseUrl)
-
getAccountId
public String getAccountId()
-
setAccountId
public void setAccountId(String accountId)
-
getCallbackUrl
public String getCallbackUrl()
-
getIntegrationKey
public String getIntegrationKey()
-
setIntegrationKey
public void setIntegrationKey(String integrationKey)
-
getSecretKey
public String getSecretKey()
-
setSecretKey
public void setSecretKey(String secretKey)
-
getAccessToken
public String getAccessToken()
-
getLastProcessed
public String getLastProcessed()
-
setLastProcessed
public void setLastProcessed(String date)
-
setAccessToken
public void setAccessToken(String accessToken)
Sets the access token- Parameters:
accessToken
- the access token
-
getRefreshToken
public String getRefreshToken()
-
setRefreshToken
public void setRefreshToken(String refreshToken)
Sets the refresh token- Parameters:
refreshToken
- the refresh token
-
getUserId
public long getUserId()
-
-