Class TemplateDraft


  • public class TemplateDraft
    extends AbstractRequest
    Represents a HelloSign template draft.
    • Field Detail

      • TEMPLATE_DRAFT_KEY

        public static final java.lang.String TEMPLATE_DRAFT_KEY
        See Also:
        Constant Field Values
      • TEMPLATE_DRAFT_ID

        public static final java.lang.String TEMPLATE_DRAFT_ID
        See Also:
        Constant Field Values
      • TEMPLATE_EDIT_URL

        public static final java.lang.String TEMPLATE_EDIT_URL
        See Also:
        Constant Field Values
      • TEMPLATE_EXPIRES_AT

        public static final java.lang.String TEMPLATE_EXPIRES_AT
        See Also:
        Constant Field Values
      • SIGREQ_ATTACHMENTS

        public static final java.lang.String SIGREQ_ATTACHMENTS
        See Also:
        Constant Field Values
      • SIGREQ_ATTACHMENTS_NAME

        public static final java.lang.String SIGREQ_ATTACHMENTS_NAME
        See Also:
        Constant Field Values
      • SIGREQ_ATTACHMENTS_INSTRUCTIONS

        public static final java.lang.String SIGREQ_ATTACHMENTS_INSTRUCTIONS
        See Also:
        Constant Field Values
      • SIGREQ_ATTACHMENTS_INDEX

        public static final java.lang.String SIGREQ_ATTACHMENTS_INDEX
        See Also:
        Constant Field Values
      • SIGREQ_ATTACHMENTS_REQUIRED

        public static final java.lang.String SIGREQ_ATTACHMENTS_REQUIRED
        See Also:
        Constant Field Values
    • Method Detail

      • getAttachments

        public java.util.List<Attachment> getAttachments()
      • setAttachments

        public void setAttachments​(java.util.List<Attachment> attachments)
        Set List of Attachments to the request.
        Parameters:
        attachments -
      • serializeMergeFields

        public static java.lang.String serializeMergeFields​(java.util.Map<java.lang.String,​FieldType> mergeFields)
                                                     throws HelloSignException
        Helper method to convert a Java Map into the JSON string required by the HelloSign API.
        Parameters:
        mergeFields - Map
        Returns:
        String
        Throws:
        HelloSignException - Thrown if there's a problem parsing JSONObjects
      • getId

        public java.lang.String getId()
        Returns the ID for this request.
        Specified by:
        getId in class AbstractRequest
      • hasId

        public boolean hasId()
        Returns true if this request has an ID. Useful if checking to see if this request is for submission or is the result of a call to HelloSign.
        Returns:
        true if the request has an ID, false otherwise
      • getCCRoles

        public java.util.List<java.lang.String> getCCRoles()
        Returns the CC roles for this request.
        Returns:
        List
      • addCCRole

        public void addCCRole​(java.lang.String ccRole)
        Adds a named role for a CC recipient that must be specified when the template is used.
        Parameters:
        ccRole - String
      • addSignerRole

        public void addSignerRole​(java.lang.String signerRole)
        Adds the signer role to the template draft.
        Parameters:
        signerRole - String
      • getSignerRoles

        public java.util.List<java.lang.String> getSignerRoles()
        Returns the signer roles specified for this template draft.
        Returns:
        List
      • setSignerRoles

        public void setSignerRoles​(java.util.List<java.lang.String> signerRoles)
        Overwrites the current list of signer roles.
        Parameters:
        signerRoles - List
      • addSignerRole

        public void addSignerRole​(java.lang.String role,
                                  int order)
                           throws HelloSignException
        Adds the signer role with the given order to the list of signers for this request. NOTE: The order refers to the 1-base index, not 0-base. This is to reflect the indexing used by the HelloSign API. This means that adding an item at order 1 will place it in the 0th index of the list (it will be the first item).
        Parameters:
        role - String
        order - int
        Throws:
        HelloSignException - thrown if there is a problem adding the signer role.
      • removeSignerRole

        public boolean removeSignerRole​(java.lang.String signerRole)
        Removes the signer role.
        Parameters:
        signerRole - String
        Returns:
        boolean
      • addMergeField

        public void addMergeField​(java.lang.String name,
                                  FieldType type)
                           throws HelloSignException
        Add merge fields to the template draft. These are fields that your app can pre-populate whenever the *finished* template is used to send a signature request.
        Parameters:
        name - String name of the merge field that will be displayed to the user and used to key off the custom field when populating the value.
        type - FieldType (currently only "text" and "checkbox" are allowed)
        Throws:
        HelloSignException - thrown if there is a problem adding the merge field.
      • getMergeFields

        public java.util.Map<java.lang.String,​FieldType> getMergeFields()
        Returns the current map of merge field names to types.
        Returns:
        Map
      • clearMergeFields

        public void clearMergeFields()
        Clears the current merge field map.
      • hasEditUrl

        public boolean hasEditUrl()
        Utility method to detect whether the "edit_url" parameter is set on this template object.
        Returns:
        boolean
      • getEditUrl

        public java.lang.String getEditUrl()
        Returns the edit URL for creating an embedded template draft.
        Returns:
        String edit URL
      • hasExpiresAt

        public boolean hasExpiresAt()
        Utility method to detect whether the "expires_at" parameter is set on this template object.
        Returns:
        boolean
      • getExpiresAt

        public java.lang.String getExpiresAt()
        Returns the expiration time for the edit URL of this template.
        Returns:
        String expiration timestamp
      • getPostFields

        public java.util.Map<java.lang.String,​java.io.Serializable> getPostFields()
                                                                                 throws HelloSignException
        Internal method used to retrieve the necessary POST fields.
        Overrides:
        getPostFields in class AbstractRequest
        Returns:
        Map
        Throws:
        HelloSignException - thrown if there is a problem serializing the POST fields.
      • setCustomFieldValue

        public void setCustomFieldValue​(java.lang.String fieldNameOrApiId,
                                        java.lang.String value)
        Not implemented for Template Drafts
        Overrides:
        setCustomFieldValue in class AbstractRequest
        Parameters:
        fieldNameOrApiId - String name (or "Field Label") of the custom field to be filled in. The "api_id" can also be used instead of the name.
        value - String value
      • getCustomFieldsMap

        public java.util.Map<java.lang.String,​java.lang.String> getCustomFieldsMap()
        Not implemented for Template Drafts
        Overrides:
        getCustomFieldsMap in class AbstractRequest
        Returns:
        Map
      • setCustomFields

        public void setCustomFields​(java.util.Map<java.lang.String,​java.lang.String> fields)
        Not implemented for Template Drafts
        Overrides:
        setCustomFields in class AbstractRequest
        Parameters:
        fields - Map