Skip to content
This repository was archived by the owner on Oct 17, 2023. It is now read-only.

Commit 6a2db19

Browse files
author
Chris Paul
committed
Add ux_version parameter to requests. Add template/files support.
1 parent 8149b81 commit 6a2db19

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<groupId>com.hellosign</groupId>
77
<artifactId>hellosign-java-sdk</artifactId>
88
<packaging>jar</packaging>
9-
<version>3.2.3</version>
9+
<version>3.3.0</version>
1010
<name>HelloSign Java SDK</name>
1111
<url>https://github.com/HelloFax/hellosign-java-sdk</url>
1212
<properties>

src/main/java/com/hellosign/sdk/HelloSignClient.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ public class HelloSignClient {
114114
private String URL_SIGNATURE_REQUEST_LIST;
115115
private String URL_SIGNATURE_REQUEST_SEND;
116116
private String URL_TEMPLATE;
117+
private String URL_TEMPLATE_FILE;
117118
private String URL_TEMPLATE_LIST;
118119
private String URL_TEMPLATE_ADD_USER;
119120
private String URL_TEMPLATE_REMOVE_USER;
@@ -142,6 +143,9 @@ public class HelloSignClient {
142143
public static final String FILES_FILE_NAME = "files";
143144
public static final String FILES_FILE_EXT = "pdf";
144145

146+
public static final String TEMPLATE_FILE_NAME = "template";
147+
public static final String TEMPLATE_FILE_EXT = "pdf";
148+
145149
public static final String OAUTH_CODE = "code";
146150
public static final String OAUTH_STATE = "state";
147151
public static final String OAUTH_GRANT_TYPE = "grant_type";
@@ -186,6 +190,7 @@ private void initApiEndpoints() {
186190
URL_SIGNATURE_REQUEST_LIST = URL_SIGNATURE_REQUEST + "/list";
187191
URL_SIGNATURE_REQUEST_SEND = URL_SIGNATURE_REQUEST + "/send";
188192
URL_TEMPLATE = URL_API + "/template";
193+
URL_TEMPLATE_FILE = URL_TEMPLATE + "/files";
189194
URL_TEMPLATE_LIST = URL_TEMPLATE + "/list";
190195
URL_TEMPLATE_ADD_USER = URL_TEMPLATE + "/add_user";
191196
URL_TEMPLATE_REMOVE_USER = URL_TEMPLATE + "/remove_user";
@@ -613,6 +618,20 @@ public TemplateList getTemplates(int page) throws HelloSignException {
613618
return new TemplateList(request.getJsonResponse());
614619
}
615620

621+
622+
/**
623+
* Retrieves the PDF file backing the Template specified by
624+
* the provided Template ID.
625+
* @param templateId String Template ID
626+
* @return File PDF file object
627+
* @throws HelloSignException
628+
*/
629+
public File getTemplateFile(String templateId) throws HelloSignException {
630+
String url = URL_TEMPLATE_FILE + "/" + templateId;
631+
HttpGetRequest request = new HttpGetRequest(url, auth);
632+
return request.getFileResponse(TEMPLATE_FILE_NAME + "." + TEMPLATE_FILE_EXT);
633+
}
634+
616635
/**
617636
* Retrieves a specific Template based on the provided Template ID.
618637
* @param templateId String Template ID

src/main/java/com/hellosign/sdk/resource/AbstractRequest.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,19 @@ public abstract class AbstractRequest extends AbstractResource {
5656
public static final String REQUEST_USE_PREEXISTING_FIELDS = "use_preexisting_fields";
5757
public static final String REQUEST_HIDE_TEXT_TAGS = "hide_text_tags";
5858
public static final String REQUEST_METADATA = "metadata";
59+
public static final String REQUEST_UX_VERSION = "ux_version";
60+
61+
// UX Version 1 = Original, non-responsive signer page is used
62+
public static final int UX_VERSION_1 = 1;
63+
64+
// UX Version 2 = Responsive signer page is displayed to signer(s)
65+
public static final int UX_VERSION_2 = 2;
5966

6067
private Metadata metadata;
6168
private List<Document> documents = new ArrayList<Document>();
6269
private List<String> fileUrls = new ArrayList<String>();
6370
private boolean orderMatters = false;
71+
private int uxVersion = UX_VERSION_1;
6472

6573
public AbstractRequest() {
6674
super();
@@ -89,6 +97,10 @@ protected Map<String, Serializable> getPostFields() throws HelloSignException {
8997
} catch (Exception ex) {
9098
throw new HelloSignException("Could not extract metadata fields.", ex);
9199
}
100+
// For now, only send the UX version if it's the non-default (2)
101+
if (this.getUxVersion() == UX_VERSION_2) {
102+
fields.put(REQUEST_UX_VERSION, UX_VERSION_2);
103+
}
92104
return fields;
93105
}
94106

@@ -313,4 +325,23 @@ public List<String> getFileUrls() {
313325
public void setFileUrls(List<String> fileUrls) {
314326
this.fileUrls = fileUrls;
315327
}
328+
329+
/**
330+
* Set the UX version for this request. This determines the version
331+
* of the signer page displayed to signer(s). The default is
332+
* UX_VERSION_1 (non-responsive). Use UX_VERSION_2 for the responsive
333+
* signer page.
334+
* @param uxVersion int
335+
*/
336+
public void setUxVersion(int uxVersion) {
337+
this.uxVersion = uxVersion;
338+
}
339+
340+
/**
341+
* Return the UX version for this request.
342+
* @return int UX version (UX_VERSION_1 or UX_VERSION_2)
343+
*/
344+
public int getUxVersion() {
345+
return this.uxVersion;
346+
}
316347
}

0 commit comments

Comments
 (0)