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.StringTEMPLATE_DRAFT_IDstatic java.lang.StringTEMPLATE_DRAFT_KEYstatic java.lang.StringTEMPLATE_EDIT_URLstatic java.lang.StringTEMPLATE_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 voidaddCCRole(java.lang.String ccRole)Adds a named role for a CC recipient that must be specified when the template is used.voidaddCustomField(CustomField field)Not implemented for Template DraftsvoidaddMergeField(java.lang.String name, FieldType type)Add merge fields to the template draft.voidaddSignerRole(java.lang.String signerRole)Adds the signer role to the template draft.voidaddSignerRole(java.lang.String role, int order)Adds the signer role with the given order to the list of signers for this request.voidclearCustomFields()Not implemented for Template DraftsvoidclearMergeFields()Clears the current merge field map.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.StringgetEditUrl()Returns the edit URL for creating an embedded template draft.java.lang.StringgetExpiresAt()Returns the expiration time for the edit URL of this template.java.lang.StringgetId()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.booleanhasEditUrl()Utility method to detect whether the "edit_url" parameter is set on this template object.booleanhasExpiresAt()Utility method to detect whether the "expires_at" parameter is set on this template object.booleanhasId()Returns true if this request has an ID.booleanremoveSignerRole(java.lang.String signerRole)Removes the signer role.static java.lang.StringserializeMergeFields(java.util.Map<java.lang.String,FieldType> mergeFields)Helper method to convert a Java Map into the JSON string required by the HelloSign API.voidsetCustomFields(java.util.Map<java.lang.String,java.lang.String> fields)Not implemented for Template DraftsvoidsetCustomFieldValue(java.lang.String fieldNameOrApiId, java.lang.String value)Not implemented for Template DraftsvoidsetSignerRoles(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, 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
-
-
Constructor Detail
-
TemplateDraft
public TemplateDraft()
-
TemplateDraft
public TemplateDraft(org.json.JSONObject json) throws HelloSignException- Throws:
HelloSignException
-
-
Method Detail
-
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:
getIdin 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 HelloSignExceptionAdds 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 HelloSignExceptionAdd 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 HelloSignExceptionInternal method used to retrieve the necessary POST fields.- Overrides:
getPostFieldsin 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:
addCustomFieldin classAbstractRequest- Parameters:
field- CustomField
-
setCustomFieldValue
public void setCustomFieldValue(java.lang.String fieldNameOrApiId, java.lang.String value)Not implemented for Template Drafts- Overrides:
setCustomFieldValuein 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:
getCustomFieldsMapin classAbstractRequest- Returns:
- Map
-
getCustomFields
public java.util.List<CustomField> getCustomFields()
Not implemented for Template Drafts- Overrides:
getCustomFieldsin classAbstractRequest- Returns:
- List CustomFields
-
setCustomFields
public void setCustomFields(java.util.Map<java.lang.String,java.lang.String> fields)
Not implemented for Template Drafts- Overrides:
setCustomFieldsin classAbstractRequest- Parameters:
fields- Map
-
getCustomFieldsList
public java.util.List<CustomField> getCustomFieldsList()
Not implemented for Template Drafts- Overrides:
getCustomFieldsListin classAbstractRequest- Returns:
- List of CustomFields
-
clearCustomFields
public void clearCustomFields()
Not implemented for Template Drafts- Overrides:
clearCustomFieldsin classAbstractRequest
-
-