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 Details

    • 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
  • Constructor Details

    • DocuSign

      public DocuSign(long userId) throws com.logicaldoc.core.PersistenceException
      Constructor
      Parameters:
      userId - identifier of the user
      Throws:
      com.logicaldoc.core.PersistenceException - error at data layer
  • Method Details

    • sendEnvelope

      public String sendEnvelope(List<com.logicaldoc.core.document.Document> documents, com.logicaldoc.core.document.DocumentHistory transaction, String subject, String body, Date expire) throws com.logicaldoc.core.PersistenceException, IOException, com.docusign.esign.client.ApiException
      Prepares and sends an envelope to DocuSign
      Parameters:
      documents - collection of documents in the envelope
      transaction - transaction informations
      subject - subject of the email that notifies the signers
      body - object of the email that notifies the signers
      expire - optional expiration date for the envelope
      Returns:
      identifier of the created envelope
      Throws:
      com.logicaldoc.core.PersistenceException - Error in the database layer
      IOException - I/O error
      com.docusign.esign.client.ApiException - 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 envelope
      docId - identifier of the file inside the envelope
      out - file where the contents have to be written
      Throws:
      com.docusign.esign.client.ApiException - Error communicating with DocuSign
      IOException - 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 error
      com.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 by getAuthorizationUrl().
      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 error
      com.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()