-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support Sign Templates and new Sign Request statuses (#920)
- Loading branch information
1 parent
3d7278a
commit 78580fb
Showing
27 changed files
with
990 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Box.V2.Managers; | ||
using Box.V2.Models; | ||
using Box.V2.Models.Request; | ||
using Box.V2.Test.Extensions; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Moq; | ||
using Newtonsoft.Json.Linq; | ||
|
||
namespace Box.V2.Test | ||
{ | ||
[TestClass] | ||
public class BoxSignTemplatesManagerTest : BoxResourceManagerTest | ||
{ | ||
private readonly BoxSignTemplatesManager _signTemplatesManager; | ||
|
||
public BoxSignTemplatesManagerTest() | ||
{ | ||
_signTemplatesManager = new BoxSignTemplatesManager(Config.Object, Service, Converter, AuthRepository); | ||
} | ||
|
||
[TestMethod] | ||
public async Task GetSignTemplateById_Success() | ||
{ | ||
/** Arrange **/ | ||
const string signTemplateId = "93153068-5420-467b-b8ef-8e54bfb7be42"; | ||
IBoxRequest boxRequest = null; | ||
Handler.Setup(h => h.ExecuteAsync<BoxSignTemplate>(It.IsAny<IBoxRequest>())) | ||
.Returns(Task.FromResult<IBoxResponse<BoxSignTemplate>>(new BoxResponse<BoxSignTemplate>() | ||
{ | ||
Status = ResponseStatus.Success, | ||
ContentString = LoadFixtureFromJson("Fixtures/BoxSignTemplate/GetSignTemplate200.json") | ||
})) | ||
.Callback<IBoxRequest>(r => boxRequest = r); | ||
|
||
/*** Act ***/ | ||
BoxSignTemplate response = await _signTemplatesManager.GetSignTemplateByIdAsync(signTemplateId); | ||
|
||
/*** Assert ***/ | ||
// Request check | ||
Assert.IsNotNull(boxRequest); | ||
Assert.AreEqual(RequestMethod.Get, boxRequest.Method); | ||
Assert.AreEqual(new Uri("https://api.box.com/2.0/sign_templates/93153068-5420-467b-b8ef-8e54bfb7be42"), boxRequest.AbsoluteUri); | ||
|
||
// Response check | ||
Assert.AreEqual(signTemplateId, response.Id); | ||
Assert.AreEqual("requirements-dev.pdf", response.Name); | ||
Assert.AreEqual("Please sign this document.\n\nKind regards", response.EmailMessage); | ||
Assert.AreEqual("Someone ([email protected]) has requested your signature on a document", response.EmailSubject); | ||
Assert.AreEqual("1234567890", response.ParentFolder.Id); | ||
Assert.AreEqual(1, response.SourceFiles.Count); | ||
Assert.AreEqual("1234567890", response.SourceFiles[0].Id); | ||
Assert.AreEqual("https://app.box.com/sign/ready-sign-link/59917816-c12b-4ef6-8f1d-aaaaaaa", response.ReadySignLink.Url); | ||
} | ||
|
||
[TestMethod] | ||
public async Task GetSignTemplates_Success() | ||
{ | ||
/** Arrange **/ | ||
IBoxRequest boxRequest = null; | ||
Handler.Setup(h => h.ExecuteAsync<BoxCollectionMarkerBased<BoxSignTemplate>>(It.IsAny<IBoxRequest>())) | ||
.Returns(Task.FromResult<IBoxResponse<BoxCollectionMarkerBased<BoxSignTemplate>>>(new BoxResponse<BoxCollectionMarkerBased<BoxSignTemplate>>() | ||
{ | ||
Status = ResponseStatus.Success, | ||
ContentString = LoadFixtureFromJson("Fixtures/BoxSignTemplate/GetAllSignTemplates200.json") | ||
})) | ||
.Callback<IBoxRequest>(r => boxRequest = r); | ||
|
||
/*** Act ***/ | ||
BoxCollectionMarkerBased<BoxSignTemplate> response = await _signTemplatesManager.GetSignTemplatesAsync(1000, "JV9IRGZmieiBasejOG9yDCRNgd2ymoZIbjsxbJMjIs3kioVii"); | ||
|
||
/*** Assert ***/ | ||
// Request check | ||
Assert.IsNotNull(boxRequest); | ||
Assert.AreEqual(RequestMethod.Get, boxRequest.Method); | ||
Assert.AreEqual(new Uri("https://api.box.com/2.0/sign_templates?limit=1000&marker=JV9IRGZmieiBasejOG9yDCRNgd2ymoZIbjsxbJMjIs3kioVii"), boxRequest.AbsoluteUri); | ||
|
||
// Response check | ||
Assert.AreEqual(1, response.Entries.Count); | ||
Assert.AreEqual("93153068-5420-467b-b8ef-8e54bfb7be42", response.Entries[0].Id); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,5 +101,6 @@ | |
} | ||
} | ||
], | ||
"status": "cancelled" | ||
"status": "cancelled", | ||
"template_id": "12345" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,5 +101,6 @@ | |
} | ||
} | ||
], | ||
"status": "converting" | ||
"status": "converting", | ||
"template_id": "12345" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,5 +101,6 @@ | |
} | ||
} | ||
], | ||
"status": "converting" | ||
"status": "converting", | ||
"template_id": "12345" | ||
} |
101 changes: 101 additions & 0 deletions
101
Box.V2.Test/Fixtures/BoxSignTemplate/GetAllSignTemplates200.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
{ | ||
"limit": 10, | ||
"next_marker": null, | ||
"prev_marker": null, | ||
"entries": [ | ||
{ | ||
"id": "93153068-5420-467b-b8ef-8e54bfb7be42", | ||
"type": "sign-template", | ||
"name": "requirements-dev.pdf", | ||
"email_message": "Please sign this document.\n\nKind regards", | ||
"email_subject": "Someone ([email protected]) has requested your signature on a document", | ||
"parent_folder": { | ||
"id": "1234567890", | ||
"etag": "0", | ||
"type": "folder", | ||
"sequence_id": "0", | ||
"name": "My Sign Requests" | ||
}, | ||
"auto_expire_days": null, | ||
"source_files": [ | ||
{ | ||
"id": "1234567890", | ||
"etag": "0", | ||
"type": "file", | ||
"sequence_id": "0", | ||
"sha1": "082c9540e82e9c465309367a3240405aaaaaaa", | ||
"file_version": { | ||
"id": "1234567890", | ||
"type": "file_version", | ||
"sha1": "082c9540e82e9c465309367a3240405aaaaaaa" | ||
} | ||
} | ||
], | ||
"are_email_settings_locked": false, | ||
"are_fields_locked": false, | ||
"are_files_locked": false, | ||
"are_options_locked": false, | ||
"are_recipients_locked": false, | ||
"signers": [ | ||
{ | ||
"email": "", | ||
"label": "", | ||
"public_id": "18K8K7Q4", | ||
"role": "final_copy_reader", | ||
"is_in_person": false, | ||
"order": 1, | ||
"inputs": [] | ||
}, | ||
{ | ||
"email": "", | ||
"label": "", | ||
"public_id": "13XQXJZ4", | ||
"role": "signer", | ||
"is_in_person": false, | ||
"order": 1, | ||
"inputs": [ | ||
{ | ||
"document_tag_id": null, | ||
"id": "0260f921-3b52-477f-ae74-aaaaaaa", | ||
"type": "signature", | ||
"text_value": null, | ||
"is_required": true, | ||
"coordinates": { | ||
"x": 0.27038464059712, | ||
"y": 0.10051756244533624 | ||
}, | ||
"dimensions": { | ||
"width": 0.23570031566618235, | ||
"height": 0.04781003891921971 | ||
}, | ||
"date_value": null, | ||
"page_index": 0, | ||
"checkbox_value": null, | ||
"document_id": "2fdf9003-d798-40ee-be7f-aaaaaaa", | ||
"content_type": "signature", | ||
"dropdown_choices": null, | ||
"group_id": null, | ||
"label": null | ||
} | ||
] | ||
} | ||
], | ||
"ready_sign_link": { | ||
"url": "https://app.box.com/sign/ready-sign-link/59917816-c12b-4ef6-8f1d-aaaaaaa", | ||
"name": "requirements-dev.pdf", | ||
"instructions": "Hello", | ||
"folder_id": "1234567890", | ||
"is_notification_disabled": true, | ||
"is_active": true | ||
}, | ||
"custom_branding": null, | ||
"days_valid": 0, | ||
"additional_info": { | ||
"non_editable": [], | ||
"required": { | ||
"signers": [["email"], ["email"]] | ||
} | ||
} | ||
} | ||
] | ||
} |
102 changes: 102 additions & 0 deletions
102
Box.V2.Test/Fixtures/BoxSignTemplate/GetSignTemplate200.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
|
||
{ | ||
"id": "93153068-5420-467b-b8ef-8e54bfb7be42", | ||
"type": "sign-template", | ||
"name": "requirements-dev.pdf", | ||
"email_message": "Please sign this document.\n\nKind regards", | ||
"email_subject": "Someone ([email protected]) has requested your signature on a document", | ||
"parent_folder": { | ||
"id": "1234567890", | ||
"etag": "0", | ||
"type": "folder", | ||
"sequence_id": "0", | ||
"name": "My Sign Requests" | ||
}, | ||
"auto_expire_days": null, | ||
"source_files": [ | ||
{ | ||
"id": "1234567890", | ||
"etag": "0", | ||
"type": "file", | ||
"sequence_id": "0", | ||
"sha1": "082c9540e82e9c465309367a3240405aaaaaaa", | ||
"file_version": { | ||
"id": "1234567890", | ||
"type": "file_version", | ||
"sha1": "082c9540e82e9c465309367a3240405aaaaaaa" | ||
} | ||
} | ||
], | ||
"are_email_settings_locked": false, | ||
"are_fields_locked": false, | ||
"are_files_locked": false, | ||
"are_options_locked": false, | ||
"are_recipients_locked": false, | ||
"signers": [ | ||
{ | ||
"email": "", | ||
"label": "", | ||
"public_id": "18K8K7Q4", | ||
"role": "final_copy_reader", | ||
"is_in_person": false, | ||
"order": 1, | ||
"inputs": [] | ||
}, | ||
{ | ||
"email": "", | ||
"label": "", | ||
"public_id": "13XQXJZ4", | ||
"role": "signer", | ||
"is_in_person": false, | ||
"order": 1, | ||
"inputs": [ | ||
{ | ||
"document_tag_id": null, | ||
"id": "0260f921-3b52-477f-ae74-aaaaaaa", | ||
"type": "signature", | ||
"text_value": null, | ||
"is_required": true, | ||
"coordinates": { | ||
"x": 0.27038464059712, | ||
"y": 0.10051756244533624 | ||
}, | ||
"dimensions": { | ||
"width": 0.23570031566618235, | ||
"height": 0.04781003891921971 | ||
}, | ||
"date_value": null, | ||
"page_index": 0, | ||
"checkbox_value": null, | ||
"document_id": "2fdf9003-d798-40ee-be7f-aaaaaaa", | ||
"content_type": "signature", | ||
"dropdown_choices": null, | ||
"group_id": null, | ||
"label": null | ||
} | ||
] | ||
} | ||
], | ||
"ready_sign_link": { | ||
"url": "https://app.box.com/sign/ready-sign-link/59917816-c12b-4ef6-8f1d-aaaaaaa", | ||
"name": "requirements-dev.pdf", | ||
"instructions": "Hello", | ||
"folder_id": "1234567890", | ||
"is_notification_disabled": true, | ||
"is_active": true | ||
}, | ||
"custom_branding": null, | ||
"days_valid": 0, | ||
"additional_info": { | ||
"non_editable": [], | ||
"required": { | ||
"signers": [ | ||
[ | ||
"email" | ||
], | ||
[ | ||
"email" | ||
] | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.