Package com.hellosign.sdk.resource
Class TemplateDraft
- java.lang.Object
-
- com.hellosign.sdk.resource.AbstractResource
-
- com.hellosign.sdk.resource.AbstractRequest
-
- com.hellosign.sdk.resource.TemplateDraft
-
public class TemplateDraft extends AbstractRequest
Represents a HelloSign template draft.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
SIGREQ_ATTACHMENTS
static java.lang.String
SIGREQ_ATTACHMENTS_INDEX
static java.lang.String
SIGREQ_ATTACHMENTS_INSTRUCTIONS
static java.lang.String
SIGREQ_ATTACHMENTS_NAME
static java.lang.String
SIGREQ_ATTACHMENTS_REQUIRED
static java.lang.String
TEMPLATE_DRAFT_ID
static java.lang.String
TEMPLATE_DRAFT_KEY
static java.lang.String
TEMPLATE_EDIT_URL
static java.lang.String
TEMPLATE_EXPIRES_AT
-
Fields inherited from class com.hellosign.sdk.resource.AbstractRequest
REQUEST_ALLOW_DECLINE, REQUEST_ALLOW_REASSIGN, REQUEST_CLIENT_ID, REQUEST_CUSTOM_FIELDS, REQUEST_HIDE_TEXT_TAGS, REQUEST_MESSAGE, REQUEST_METADATA, REQUEST_REDIRECT_URL, REQUEST_SUBJECT, REQUEST_TEST_MODE, REQUEST_TITLE, REQUEST_USE_PREEXISTING_FIELDS, REQUEST_USE_TEXT_TAGS, REQUEST_UX_VERSION, UX_VERSION_1, UX_VERSION_2
-
Fields inherited from class com.hellosign.sdk.resource.AbstractResource
dataObj, warnings
-
-
Constructor Summary
Constructors Constructor Description TemplateDraft()
TemplateDraft(org.json.JSONObject json)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCCRole(java.lang.String ccRole)
Adds a named role for a CC recipient that must be specified when the template is used.void
addCustomField(CustomField field)
Not implemented for Template Draftsvoid
addMergeField(java.lang.String name, FieldType type)
Add merge fields to the template draft.void
addSignerRole(java.lang.String signerRole)
Adds the signer role to the template draft.void
addSignerRole(java.lang.String role, int order)
Adds the signer role with the given order to the list of signers for this request.void
clearCustomFields()
Not implemented for Template Draftsvoid
clearMergeFields()
Clears the current merge field map.java.util.List<Attachment>
getAttachments()
java.util.List<java.lang.String>
getCCRoles()
Returns the CC roles for this request.java.util.List<CustomField>
getCustomFields()
Not implemented for Template Draftsjava.util.List<CustomField>
getCustomFieldsList()
Not implemented for Template Draftsjava.util.Map<java.lang.String,java.lang.String>
getCustomFieldsMap()
Not implemented for Template Draftsjava.lang.String
getEditUrl()
Returns the edit URL for creating an embedded template draft.java.lang.String
getExpiresAt()
Returns the expiration time for the edit URL of this template.java.lang.String
getId()
Returns the ID for this request.java.util.Map<java.lang.String,FieldType>
getMergeFields()
Returns the current map of merge field names to types.java.util.Map<java.lang.String,java.io.Serializable>
getPostFields()
Internal method used to retrieve the necessary POST fields.java.util.List<java.lang.String>
getSignerRoles()
Returns the signer roles specified for this template draft.boolean
hasEditUrl()
Utility method to detect whether the "edit_url" parameter is set on this template object.boolean
hasExpiresAt()
Utility method to detect whether the "expires_at" parameter is set on this template object.boolean
hasId()
Returns true if this request has an ID.boolean
removeSignerRole(java.lang.String signerRole)
Removes the signer role.static java.lang.String
serializeMergeFields(java.util.Map<java.lang.String,FieldType> mergeFields)
Helper method to convert a Java Map into the JSON string required by the HelloSign API.void
setAttachments(java.util.List<Attachment> attachments)
Set List of Attachments to the request.void
setCustomFields(java.util.Map<java.lang.String,java.lang.String> fields)
Not implemented for Template Draftsvoid
setCustomFieldValue(java.lang.String fieldNameOrApiId, java.lang.String value)
Not implemented for Template Draftsvoid
setSignerRoles(java.util.List<java.lang.String> signerRoles)
Overwrites the current list of signer roles.-
Methods inherited from class com.hellosign.sdk.resource.AbstractRequest
addDocument, addDocument, addFile, addFile, addFileUrl, addMetadata, clearDocuments, getClientId, getDocuments, getFileUrls, getIsDeclinable, getMessage, getMetadata, getMetadata, getOrderMatters, getRedirectUrl, getSubject, getTitle, getUxVersion, hasAllowReassign, hasHideTextTags, hasMessage, hasRedirectUrl, hasSubject, hasTitle, hasUsePreexistingFields, hasUseTextTags, isAllowReassign, isHidingTextTags, isTestMode, isUsingPreexistingFields, isUsingTextTags, setAllowReassign, setClientId, setDocuments, setFileUrls, setHideTextTags, setIsDeclinable, setMessage, setOrderMatters, setRedirectUrl, setSubject, setTestMode, setTitle, setUsePreexistingFields, setUseTextTags, setUxVersion
-
Methods inherited from class com.hellosign.sdk.resource.AbstractResource
add, addToList, clearList, get, getBoolean, getConstructor, getDate, getInteger, getJSONObject, getList, getList, getLong, getObject, getString, getWarnings, has, hasString, set, toString, toString
-
-
-
-
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
-
-
Constructor Detail
-
TemplateDraft
public TemplateDraft()
-
TemplateDraft
public TemplateDraft(org.json.JSONObject json) throws HelloSignException
- Throws:
HelloSignException
-
-
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.
-
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 classAbstractRequest
-
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
- Stringorder
- 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 classAbstractRequest
- Returns:
- Map
- Throws:
HelloSignException
- thrown if there is a problem serializing the POST fields.
-
addCustomField
public void addCustomField(CustomField field)
Not implemented for Template Drafts- Overrides:
addCustomField
in classAbstractRequest
- Parameters:
field
- CustomField
-
setCustomFieldValue
public void setCustomFieldValue(java.lang.String fieldNameOrApiId, java.lang.String value)
Not implemented for Template Drafts- Overrides:
setCustomFieldValue
in classAbstractRequest
- 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 classAbstractRequest
- Returns:
- Map
-
getCustomFields
public java.util.List<CustomField> getCustomFields()
Not implemented for Template Drafts- Overrides:
getCustomFields
in classAbstractRequest
- Returns:
- List CustomFields
-
setCustomFields
public void setCustomFields(java.util.Map<java.lang.String,java.lang.String> fields)
Not implemented for Template Drafts- Overrides:
setCustomFields
in classAbstractRequest
- Parameters:
fields
- Map
-
getCustomFieldsList
public java.util.List<CustomField> getCustomFieldsList()
Not implemented for Template Drafts- Overrides:
getCustomFieldsList
in classAbstractRequest
- Returns:
- List of CustomFields
-
clearCustomFields
public void clearCustomFields()
Not implemented for Template Drafts- Overrides:
clearCustomFields
in classAbstractRequest
-
-