Skip to content
This repository was archived by the owner on Oct 17, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ web.properties
.project
.classpath
src/test/webapp
.idea/
*.iml
33 changes: 32 additions & 1 deletion src/main/java/com/hellosign/sdk/HelloSignClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,22 @@ public SignatureRequestList getSignatureRequests(int page) throws HelloSignExcep
.get(BASE_URI + SIGNATURE_REQUEST_LIST_URI).asJson());
}

/**
* Retrieves a specific page of the current user's signature requests.
*
* @param page int
* @param pageSize int Must be between 1 and 100.
* @return SignatureRequestList
* @throws HelloSignException thrown if there's a problem processing the
* HTTP request or the JSON response.
*/
public SignatureRequestList getSignatureRequests(int page, int pageSize) throws HelloSignException {
return new SignatureRequestList(
httpClient.withAuth(auth).withGetParam(AbstractResourceList.PAGE, Integer.toString(page))
.withGetParam(AbstractResourceList.PAGE_SIZE, Integer.toString(pageSize))
.get(BASE_URI + SIGNATURE_REQUEST_LIST_URI).asJson());
}

/**
* Sends the provided signature request to HelloSign.
*
Expand Down Expand Up @@ -512,7 +528,7 @@ public TemplateList getTemplates() throws HelloSignException {
}

/**
* Retreives a page of templates for the current user account.
* Retrieves a page of templates for the current user account.
*
* @param page int
* @return TemplateList
Expand All @@ -525,6 +541,21 @@ public TemplateList getTemplates(int page) throws HelloSignException {
.get(BASE_URI + TEMPLATE_LIST_URI).asJson());
}

/**
* Retrieves a page of templates with a specific pageSize
* @param page int
* @param pageSize int Must be between 1 and 100.
* @return TemplateList
* @throws HelloSignException thrown if there's a problem processing the
* HTTP request or the JSON response.
*/
public TemplateList getTemplates(int page, int pageSize) throws HelloSignException {
return new TemplateList(
httpClient.withAuth(auth).withGetParam(AbstractResourceList.PAGE, Integer.toString(page))
.withGetParam(AbstractResourceList.PAGE_SIZE, Integer.toString(pageSize))
.get(BASE_URI + TEMPLATE_LIST_URI).asJson());
}

/**
* Retrieves the PDF file backing the Template specified by the provided
* Template ID.
Expand Down
35 changes: 35 additions & 0 deletions src/test/java/com/hellosign/sdk/HelloSignClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,21 @@ public void testGetSignatureRequestsPageInvalid() throws Exception {
assertFalse(list.iterator().hasNext());
}

@Test
public void testGetSignatureRequestsPageSize() throws Exception {
SignatureRequestList list = client.getSignatureRequests(1, 20);
for (SignatureRequest s : list) {
assertNotNull(s);
assertNotNull(s.getId());
}
}

@Test
public void testGetSignatureRequestsPageSizeInvalid() throws Exception {
SignatureRequestList list = client.getSignatureRequests(1, 200);
assertFalse(list.iterator().hasNext());
}

@Test
public void testSendSignatureRequest() throws Exception {
String subject = "From the Mare";
Expand Down Expand Up @@ -432,6 +447,26 @@ public void testGetTemplatesPageInvalid() throws Exception {
assertFalse(templates.iterator().hasNext());
}

@Test
public void testGetTemplatePageSize() throws Exception {
TemplateList templates = client.getTemplates(1, 20);
assertNotNull(templates);
for (Template t : templates) {
assertNotNull(t);
assertTrue(t.hasId());
}
}

@Test
public void testGetTemplatePageSizeInvalid() throws Exception {
TemplateList templates = client.getTemplates(1, 200);
assertNotNull(templates);
for (Template t : templates) {
assertNotNull(t);
assertTrue(t.hasId());
}
}

@Test
public void testGetTemplateFile() throws Exception {
// Mock a random byte size written
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"list_info": {
"page": 1,
"num_pages": 1,
"num_results": 1,
"page_size": 100
},
"signature_requests": [
{
"signature_request_id": "c946eddbcc89583d9ed3173ea3fa2f98ee47f1c6",
"test_mode": false,
"title": "Test Document",
"original_title": "Test Document",
"subject": "Test Document",
"message": null,
"metadata": {},
"is_complete": false,
"is_declined": false,
"has_error": false,
"custom_fields": [],
"response_data": [],
"signing_url": "https://app.dev-hellosign.com/sign/c946eddbcc89583d9ed3173ea3fa2f98ee47f1c6",
"signing_redirect_url": null,
"final_copy_uri": "/v3/signature_request/final_copy/c946eddbcc89583d9ed3173ea3fa2f98ee47f1c6",
"files_url": "https://api.dev-hellosign.com/apiapp_dev.php/v3/signature_request/files/c946eddbcc89583d9ed3173ea3fa2f98ee47f1c6",
"details_url": "https://app.dev-hellosign.com/home/manage?guid=c946eddbcc89583d9ed3173ea3fa2f98ee47f1c6",
"requester_email_address": "john.spaetzel@hellosign.com",
"signatures": [
{
"signature_id": "12af84fa86c652212ba78da66a71ad6e",
"has_pin": false,
"signer_email_address": "john@hellosign.com",
"signer_name": "John",
"signer_role": null,
"order": null,
"status_code": "awaiting_signature",
"signed_at": null,
"last_viewed_at": null,
"last_reminded_at": null,
"error": null
}
],
"cc_email_addresses": []
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"list_info": {
"page": 1,
"num_pages": 0,
"num_results": 0,
"page_size": 200
},
"signature_requests": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"list_info": {
"page": 1,
"num_pages": 1,
"num_results": 1,
"page_size": 20
},
"templates": [
{
"template_id": "6773f5cb6d191248366695ddca468751a3f9578f",
"reusable_form_id": "6773f5cb6d191248366695ddca468751a3f9578f",
"title": "Test Template",
"message": "",
"is_creator": true,
"is_embedded": false,
"can_edit": true,
"metadata": {},
"is_locked": false,
"signer_roles": [
{
"name": "Client",
"order": null
}
],
"cc_roles": [],
"documents": [
{
"index": 0,
"name": "Test - No tags - 1 page.pdf",
"field_groups": [],
"custom_fields": [],
"form_fields": [
{
"name": "",
"type": "signature",
"signer": "1",
"x": 609,
"y": 131,
"width": 120,
"height": 30,
"required": true,
"api_id": "df80de_9",
"group": null
}
]
}
],
"custom_fields": [],
"named_form_fields": [
{
"name": "",
"type": "signature",
"signer": "1",
"x": 609,
"y": 131,
"width": 120,
"height": 30,
"required": true,
"api_id": "df80de_9",
"group": null
}
],
"accounts": [
{
"account_id": "13dd6e424c6d7b6d5fb325f1da907aef968e9fc4",
"email_address": "john.spaetzel@hellosign.com",
"is_locked": false,
"is_paid_hs": true,
"is_paid_hf": true,
"quotas": {
"fax_pages_left": 1010
}
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"list_info": {
"page": 1,
"num_pages": 1,
"num_results": 1,
"page_size": 20
},
"templates": [
]
}