Skip to content

Commit 096a098

Browse files
authored
feat: Support sign request signer group ID (#938)
* feat: Support sign request signer group ID * feat: Support sign request signer group ID * Update code
1 parent fb59489 commit 096a098

File tree

7 files changed

+157
-13
lines changed

7 files changed

+157
-13
lines changed

Box.V2.Test.Integration/BoxSignRequestManagerIntegrationTest.cs

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,19 @@ public async Task CreateSignRequestAsync_ForCorrectSignRequestCreateRequest_Shou
3636
Email = "[email protected]",
3737
RedirectUrl = new Uri("https://www.box.com/redirect_url_signer_1"),
3838
DeclinedRedirectUrl = new Uri("https://www.box.com/declined_redirect_url_singer_1"),
39-
EmbedUrlExternalUserId = UserId
39+
EmbedUrlExternalUserId = UserId,
40+
SignerGroupId = "SignerGroup",
41+
Password = "password",
42+
LoginRequired = false,
43+
},
44+
new BoxSignRequestSignerCreate()
45+
{
46+
Email = "[email protected]",
47+
RedirectUrl = new Uri("https://www.box.com/redirect_url_signer_2"),
48+
DeclinedRedirectUrl = new Uri("https://www.box.com/declined_redirect_url_singer_2"),
49+
SignerGroupId = "SignerGroup",
50+
Password = "password",
51+
LoginRequired = false,
4052
}
4153
},
4254
ParentFolder = new BoxRequestEntity()
@@ -55,10 +67,23 @@ public async Task CreateSignRequestAsync_ForCorrectSignRequestCreateRequest_Shou
5567
Assert.AreEqual(signRequestCreateRequest.DeclinedRedirectUrl.ToString(), signRequest.DeclinedRedirectUrl.ToString());
5668
Assert.AreEqual(signRequestCreateRequest.ParentFolder.Id, signRequest.ParentFolder.Id);
5769

58-
// first signer is the sender with role final_copy_reader, second is the recipient with role signer
59-
Assert.AreEqual(2, signRequest.Signers.Count);
70+
// first signer is the sender with role final_copy_reader, second and third is the recipient with role signer
71+
Assert.AreEqual(3, signRequest.Signers.Count);
6072
Assert.IsNotNull(signRequest.Signers[1].IframeableEmbedUrl);
6173

74+
var signerGroupId = "";
75+
foreach (var signer in signRequest.Signers)
76+
{
77+
if (signer.Role == BoxSignRequestSignerRole.signer)
78+
{
79+
if (string.IsNullOrEmpty(signerGroupId))
80+
{
81+
signerGroupId = signer.SignerGroupId;
82+
}
83+
Assert.AreEqual(signerGroupId, signer.SignerGroupId);
84+
}
85+
}
86+
6287
await UserClient.SignRequestsManager.CancelSignRequestAsync(signRequest.Id);
6388

6489
signRequest = await UserClient.SignRequestsManager.GetSignRequestByIdAsync(signRequest.Id);
@@ -68,7 +93,7 @@ public async Task CreateSignRequestAsync_ForCorrectSignRequestCreateRequest_Shou
6893
[TestMethod]
6994
public async Task GetSignRequestAsync_ForExistingSignRequest_ShouldReturnSignRequest()
7095
{
71-
var signRequest = await CreateSignRequest();
96+
var signRequest = await CreateSignRequest("[email protected]", FolderId);
7297
var fetchedSignRequest = await UserClient.SignRequestsManager.GetSignRequestByIdAsync(signRequest.Id);
7398

7499
Assert.AreEqual(signRequest.Id, fetchedSignRequest.Id);

Box.V2.Test.Integration/BoxWebhookManagerIntegrationTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public async Task DeleteWebhookAsync_ForExistingWebhook_ShouldDeleteWebhookAndEx
8585
[TestMethod]
8686
public async Task AddWebhook_ForSignRequest_ShouldCreateSuccess()
8787
{
88-
var signRequest = await CreateSignRequest();
88+
var signRequest = await CreateSignRequest("[email protected]", FolderId);
8989
var signFileId = signRequest.SignFiles.Files[0].Id;
9090
var webhookRequest = new BoxWebhookRequest()
9191
{

Box.V2.Test.Integration/Configuration/IntegrationTestBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,10 +389,10 @@ public static async Task Retry(Func<Task> action, int retries = 5, int sleep = 5
389389
}
390390
}
391391

392-
public static async Task<BoxSignRequest> CreateSignRequest(string signerEmail = "[email protected]")
392+
public static async Task<BoxSignRequest> CreateSignRequest(string signerEmail = "[email protected]", string folderId = "0")
393393
{
394394
var file = await CreateSmallFile();
395-
var createSignRequestCommand = new CreateSignRequestCommand(signerEmail, file.Id);
395+
var createSignRequestCommand = new CreateSignRequestCommand(signerEmail, file.Id, folderId);
396396
await ExecuteCommand(createSignRequestCommand);
397397
return createSignRequestCommand.SignRequest;
398398
}

Box.V2.Test/BoxSignRequestsManagerTest.cs

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@ public async Task CreateSignRequest_RequiredParams_Success()
4848
{
4949
Email = "[email protected]",
5050
Role = BoxSignRequestSignerRole.signer
51-
}
51+
},
52+
new BoxSignRequestSignerCreate()
53+
{
54+
Email = "[email protected]",
55+
Role = BoxSignRequestSignerRole.signer
56+
},
5257
};
5358

5459
var parentFolder = new BoxRequestEntity()
@@ -77,7 +82,7 @@ public async Task CreateSignRequest_RequiredParams_Success()
7782
// Response check
7883
Assert.AreEqual(1, response.SourceFiles.Count);
7984
Assert.AreEqual("12345", response.SourceFiles[0].Id);
80-
Assert.AreEqual(1, response.Signers.Count);
85+
Assert.AreEqual(2, response.Signers.Count);
8186
Assert.AreEqual("[email protected]", response.Signers[0].Email);
8287
Assert.AreEqual("12345", response.ParentFolder.Id);
8388
Assert.AreEqual(1, response.Signers[0].Inputs.Count);
@@ -113,7 +118,19 @@ public async Task CreateSignRequest_OptionalParams_Success()
113118
Email = "[email protected]",
114119
Role = BoxSignRequestSignerRole.signer,
115120
RedirectUrl = new Uri("https://box.com/redirect_url_signer_1"),
116-
DeclinedRedirectUrl = new Uri("https://box.com/declined_redirect_url_signer_1")
121+
DeclinedRedirectUrl = new Uri("https://box.com/declined_redirect_url_signer_1"),
122+
LoginRequired = false,
123+
Password = "abcdefg",
124+
SignerGroupId = "SignerGroup",
125+
VerificationPhoneNumber = "1234567890",
126+
}, new BoxSignRequestSignerCreate()
127+
{
128+
Email = "[email protected]",
129+
Role = BoxSignRequestSignerRole.signer,
130+
RedirectUrl = new Uri("https://box.com/redirect_url_signer_1"),
131+
DeclinedRedirectUrl = new Uri("https://box.com/declined_redirect_url_signer_1"),
132+
SignerGroupId = "SignerGroup",
133+
VerificationPhoneNumber = "1234567890",
117134
}
118135
};
119136

@@ -145,7 +162,7 @@ public async Task CreateSignRequest_OptionalParams_Success()
145162
"text"
146163
)
147164
},
148-
TemplateId = "12345"
165+
TemplateId = "12345",
149166
};
150167

151168
/*** Act ***/
@@ -160,7 +177,7 @@ public async Task CreateSignRequest_OptionalParams_Success()
160177
// Response check
161178
Assert.AreEqual(1, response.SourceFiles.Count);
162179
Assert.AreEqual("12345", response.SourceFiles[0].Id);
163-
Assert.AreEqual(1, response.Signers.Count);
180+
Assert.AreEqual(2, response.Signers.Count);
164181
Assert.AreEqual("[email protected]", response.Signers[0].Email);
165182
Assert.AreEqual("https://box.com/redirect_url_signer_1", response.Signers[0].RedirectUrl.ToString());
166183
Assert.AreEqual("https://box.com/declined_redirect_url_signer_1", response.Signers[0].DeclinedRedirectUrl.ToString());
@@ -183,6 +200,14 @@ public async Task CreateSignRequest_OptionalParams_Success()
183200
Assert.AreEqual("https://box.com/redirect_url", response.RedirectUrl.ToString());
184201
Assert.AreEqual("https://box.com/declined_redirect_url", response.DeclinedRedirectUrl.ToString());
185202
Assert.AreEqual("12345", response.TemplateId);
203+
Assert.AreEqual("cd4ff89-8fc1-42cf-8b29-1890dedd26d7", response.Signers[0].SignerGroupId);
204+
Assert.AreEqual("1234567890", response.Signers[0].VerificationPhoneNumber);
205+
Assert.AreEqual("cd4ff89-8fc1-42cf-8b29-1890dedd26d7", response.Signers[1].SignerGroupId);
206+
Assert.AreEqual("1234567890", response.Signers[1].VerificationPhoneNumber);
207+
Assert.IsFalse(response.Signers[0].LoginRequired);
208+
Assert.AreEqual("abcdefg", response.Signers[0].Password);
209+
Assert.IsFalse(response.Signers[1].LoginRequired);
210+
Assert.AreEqual("abcdefg", response.Signers[1].Password);
186211
}
187212

188213
[TestMethod]

Box.V2.Test/Fixtures/BoxSignRequest/CreateSignRequest200.json

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,42 @@
7171
"embed_url": "https://example.com",
7272
"redirect_url": "https://box.com/redirect_url_signer_1",
7373
"declined_redirect_url": "https://box.com/declined_redirect_url_signer_1",
74-
"iframeable_embed_url": "https://app.box.com/embed/sign/document/bf7aaac6/"
74+
"iframeable_embed_url": "https://app.box.com/embed/sign/document/bf7aaac6/",
75+
"login_required": false,
76+
"password": "abcdefg",
77+
"signer_group_id": "cd4ff89-8fc1-42cf-8b29-1890dedd26d7",
78+
"verification_phone_number": "1234567890"
79+
},
80+
{
81+
"email": "[email protected]",
82+
"role": "signer",
83+
"is_in_person": true,
84+
"order": 2,
85+
"embed_url_external_user_id": 1234,
86+
"has_viewed_document": true,
87+
"signer_decision": {
88+
"type": "signed",
89+
"finalized_at": "2021-04-26T08:12:13.982Z"
90+
},
91+
"inputs": [
92+
{
93+
"document_tag_id": 1234,
94+
"text_value": "text",
95+
"checkbox_value": true,
96+
"date_value": "2021-04-26T08:12:13.982Z",
97+
"type": "text",
98+
"page_index": 4,
99+
"content_type": "checkbox"
100+
}
101+
],
102+
"embed_url": "https://example.com",
103+
"redirect_url": "https://box.com/redirect_url_signer_1",
104+
"declined_redirect_url": "https://box.com/declined_redirect_url_signer_1",
105+
"iframeable_embed_url": "https://app.box.com/embed/sign/document/bf7aaac6/",
106+
"login_required": false,
107+
"password": "abcdefg",
108+
"signer_group_id": "cd4ff89-8fc1-42cf-8b29-1890dedd26d7",
109+
"verification_phone_number": "1234567890"
75110
}
76111
],
77112
"signing_log": {

Box.V2/Models/BoxSignRequestSigner.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ public class BoxSignRequestSigner
2222
public const string FieldDeclinedRedirectUrl = "declined_redirect_url";
2323
public const string FieldRedirectUrl = "redirect_url";
2424
public const string FieldIframeableEmbedUrl = "iframeable_embed_url";
25+
public const string FieldLoginRequired = "login_required";
26+
public const string FieldPassword = "password";
27+
public const string FieldSignerGroupId = "signer_group_id";
28+
public const string FieldVerificationPhoneNumber = "verification_phone_number";
29+
2530

2631
/// <summary>
2732
/// Email address of the signer.
@@ -97,6 +102,33 @@ public class BoxSignRequestSigner
97102
/// </summary>
98103
[JsonProperty(PropertyName = FieldIframeableEmbedUrl)]
99104
public virtual string IframeableEmbedUrl { get; private set; }
105+
106+
/// <summary>
107+
/// If set to true, signer will need to login to a Box account before signing the request.
108+
/// If the signer does not have an existing account, they will have an option to create a free Box account.
109+
/// </summary>
110+
[JsonProperty(PropertyName = FieldLoginRequired)]
111+
public virtual bool LoginRequired { get; private set; }
112+
113+
/// <summary>
114+
/// If set, the signer is required to enter the password before they are able to sign a document. This field is write only.
115+
/// </summary>
116+
[JsonProperty(PropertyName = FieldPassword)]
117+
public virtual string Password { get; private set; }
118+
119+
/// <summary>
120+
/// If set, signers who have the same group ID will be assigned to the same input.
121+
/// A signer group is expected to have more than one signer.
122+
/// When a group contains fewer than two signers, it will be converted to a single signer and the group will be removed.
123+
/// </summary>
124+
[JsonProperty(PropertyName = FieldSignerGroupId)]
125+
public virtual string SignerGroupId { get; private set; }
126+
127+
/// <summary>
128+
/// If set, this phone number is be used to verify the signer via two factor authentication before they are able to sign the document.
129+
/// </summary>
130+
[JsonProperty(PropertyName = FieldVerificationPhoneNumber)]
131+
public virtual string VerificationPhoneNumber { get; private set; }
100132
}
101133

102134
/// <summary>

Box.V2/Models/Request/BoxSignRequestCreateRequest.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,5 +190,32 @@ public class BoxSignRequestSignerCreate
190190
/// </summary>
191191
[JsonProperty(PropertyName = "redirect_url")]
192192
public Uri RedirectUrl { get; set; }
193+
194+
/// <summary>
195+
/// If set to true, signer will need to login to a Box account before signing the request.
196+
/// If the signer does not have an existing account, they will have an option to create a free Box account.
197+
/// </summary>
198+
[JsonProperty(PropertyName = "login_required")]
199+
public bool? LoginRequired { get; set; }
200+
201+
/// <summary>
202+
/// If set, the signer is required to enter the password before they are able to sign a document. This field is write only.
203+
/// </summary>
204+
[JsonProperty(PropertyName = "password")]
205+
public string Password { get; set; }
206+
207+
/// <summary>
208+
/// If set, signers who have the same group ID will be assigned to the same input.
209+
/// A signer group is expected to have more than one signer.
210+
/// When a group contains fewer than two signers, it will be converted to a single signer and the group will be removed.
211+
/// </summary>
212+
[JsonProperty(PropertyName = "signer_group_id")]
213+
public string SignerGroupId { get; set; }
214+
215+
/// <summary>
216+
/// If set, this phone number is be used to verify the signer via two factor authentication before they are able to sign the document.
217+
/// </summary>
218+
[JsonProperty(PropertyName = "verification_phone_number")]
219+
public string VerificationPhoneNumber { get; set; }
193220
}
194221
}

0 commit comments

Comments
 (0)