Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support sign request signer group ID #938

Merged
merged 5 commits into from
Jan 31, 2024
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
33 changes: 29 additions & 4 deletions Box.V2.Test.Integration/BoxSignRequestManagerIntegrationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,19 @@ public async Task CreateSignRequestAsync_ForCorrectSignRequestCreateRequest_Shou
Email = "[email protected]",
RedirectUrl = new Uri("https://www.box.com/redirect_url_signer_1"),
DeclinedRedirectUrl = new Uri("https://www.box.com/declined_redirect_url_singer_1"),
EmbedUrlExternalUserId = UserId
EmbedUrlExternalUserId = UserId,
SignerGroupId = "SignerGroup",
Password = "password",
LoginRequired = false,
},
new BoxSignRequestSignerCreate()
{
Email = "[email protected]",
RedirectUrl = new Uri("https://www.box.com/redirect_url_signer_2"),
DeclinedRedirectUrl = new Uri("https://www.box.com/declined_redirect_url_singer_2"),
SignerGroupId = "SignerGroup",
Password = "password",
LoginRequired = false,
}
},
ParentFolder = new BoxRequestEntity()
Expand All @@ -55,10 +67,23 @@ public async Task CreateSignRequestAsync_ForCorrectSignRequestCreateRequest_Shou
Assert.AreEqual(signRequestCreateRequest.DeclinedRedirectUrl.ToString(), signRequest.DeclinedRedirectUrl.ToString());
Assert.AreEqual(signRequestCreateRequest.ParentFolder.Id, signRequest.ParentFolder.Id);

// first signer is the sender with role final_copy_reader, second is the recipient with role signer
Assert.AreEqual(2, signRequest.Signers.Count);
// first signer is the sender with role final_copy_reader, second and third is the recipient with role signer
Assert.AreEqual(3, signRequest.Signers.Count);
Assert.IsNotNull(signRequest.Signers[1].IframeableEmbedUrl);

var signerGroupId = "";
foreach (var signer in signRequest.Signers)
{
if (signer.Role == BoxSignRequestSignerRole.signer)
{
if (string.IsNullOrEmpty(signerGroupId))
{
signerGroupId = signer.SignerGroupId;
}
Assert.AreEqual(signerGroupId, signer.SignerGroupId);
}
}

await UserClient.SignRequestsManager.CancelSignRequestAsync(signRequest.Id);

signRequest = await UserClient.SignRequestsManager.GetSignRequestByIdAsync(signRequest.Id);
Expand All @@ -68,7 +93,7 @@ public async Task CreateSignRequestAsync_ForCorrectSignRequestCreateRequest_Shou
[TestMethod]
public async Task GetSignRequestAsync_ForExistingSignRequest_ShouldReturnSignRequest()
{
var signRequest = await CreateSignRequest();
var signRequest = await CreateSignRequest("[email protected]", FolderId);
var fetchedSignRequest = await UserClient.SignRequestsManager.GetSignRequestByIdAsync(signRequest.Id);

Assert.AreEqual(signRequest.Id, fetchedSignRequest.Id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public async Task DeleteWebhookAsync_ForExistingWebhook_ShouldDeleteWebhookAndEx
[TestMethod]
public async Task AddWebhook_ForSignRequest_ShouldCreateSuccess()
{
var signRequest = await CreateSignRequest();
var signRequest = await CreateSignRequest("[email protected]", FolderId);
var signFileId = signRequest.SignFiles.Files[0].Id;
var webhookRequest = new BoxWebhookRequest()
{
Expand Down
4 changes: 2 additions & 2 deletions Box.V2.Test.Integration/Configuration/IntegrationTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,10 @@ public static async Task Retry(Func<Task> action, int retries = 5, int sleep = 5
}
}

public static async Task<BoxSignRequest> CreateSignRequest(string signerEmail = "[email protected]")
public static async Task<BoxSignRequest> CreateSignRequest(string signerEmail = "[email protected]", string folderId = "0")
{
var file = await CreateSmallFile();
var createSignRequestCommand = new CreateSignRequestCommand(signerEmail, file.Id);
var createSignRequestCommand = new CreateSignRequestCommand(signerEmail, file.Id, folderId);
await ExecuteCommand(createSignRequestCommand);
return createSignRequestCommand.SignRequest;
}
Expand Down
35 changes: 30 additions & 5 deletions Box.V2.Test/BoxSignRequestsManagerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ public async Task CreateSignRequest_RequiredParams_Success()
{
Email = "[email protected]",
Role = BoxSignRequestSignerRole.signer
}
},
new BoxSignRequestSignerCreate()
{
Email = "[email protected]",
Role = BoxSignRequestSignerRole.signer
},
};

var parentFolder = new BoxRequestEntity()
Expand Down Expand Up @@ -77,7 +82,7 @@ public async Task CreateSignRequest_RequiredParams_Success()
// Response check
Assert.AreEqual(1, response.SourceFiles.Count);
Assert.AreEqual("12345", response.SourceFiles[0].Id);
Assert.AreEqual(1, response.Signers.Count);
Assert.AreEqual(2, response.Signers.Count);
Assert.AreEqual("[email protected]", response.Signers[0].Email);
Assert.AreEqual("12345", response.ParentFolder.Id);
Assert.AreEqual(1, response.Signers[0].Inputs.Count);
Expand Down Expand Up @@ -113,7 +118,19 @@ public async Task CreateSignRequest_OptionalParams_Success()
Email = "[email protected]",
Role = BoxSignRequestSignerRole.signer,
RedirectUrl = new Uri("https://box.com/redirect_url_signer_1"),
DeclinedRedirectUrl = new Uri("https://box.com/declined_redirect_url_signer_1")
DeclinedRedirectUrl = new Uri("https://box.com/declined_redirect_url_signer_1"),
LoginRequired = false,
Password = "abcdefg",
SignerGroupId = "SignerGroup",
VerificationPhoneNumber = "1234567890",
}, new BoxSignRequestSignerCreate()
{
Email = "[email protected]",
Role = BoxSignRequestSignerRole.signer,
RedirectUrl = new Uri("https://box.com/redirect_url_signer_1"),
DeclinedRedirectUrl = new Uri("https://box.com/declined_redirect_url_signer_1"),
SignerGroupId = "SignerGroup",
VerificationPhoneNumber = "1234567890",
}
};

Expand Down Expand Up @@ -145,7 +162,7 @@ public async Task CreateSignRequest_OptionalParams_Success()
"text"
)
},
TemplateId = "12345"
TemplateId = "12345",
};

/*** Act ***/
Expand All @@ -160,7 +177,7 @@ public async Task CreateSignRequest_OptionalParams_Success()
// Response check
Assert.AreEqual(1, response.SourceFiles.Count);
Assert.AreEqual("12345", response.SourceFiles[0].Id);
Assert.AreEqual(1, response.Signers.Count);
Assert.AreEqual(2, response.Signers.Count);
Assert.AreEqual("[email protected]", response.Signers[0].Email);
Assert.AreEqual("https://box.com/redirect_url_signer_1", response.Signers[0].RedirectUrl.ToString());
Assert.AreEqual("https://box.com/declined_redirect_url_signer_1", response.Signers[0].DeclinedRedirectUrl.ToString());
Expand All @@ -183,6 +200,14 @@ public async Task CreateSignRequest_OptionalParams_Success()
Assert.AreEqual("https://box.com/redirect_url", response.RedirectUrl.ToString());
Assert.AreEqual("https://box.com/declined_redirect_url", response.DeclinedRedirectUrl.ToString());
Assert.AreEqual("12345", response.TemplateId);
Assert.AreEqual("cd4ff89-8fc1-42cf-8b29-1890dedd26d7", response.Signers[0].SignerGroupId);
Assert.AreEqual("1234567890", response.Signers[0].VerificationPhoneNumber);
Assert.AreEqual("cd4ff89-8fc1-42cf-8b29-1890dedd26d7", response.Signers[1].SignerGroupId);
Assert.AreEqual("1234567890", response.Signers[1].VerificationPhoneNumber);
Assert.IsFalse(response.Signers[0].LoginRequired);
Assert.AreEqual("abcdefg", response.Signers[0].Password);
Assert.IsFalse(response.Signers[1].LoginRequired);
Assert.AreEqual("abcdefg", response.Signers[1].Password);
}

[TestMethod]
Expand Down
37 changes: 36 additions & 1 deletion Box.V2.Test/Fixtures/BoxSignRequest/CreateSignRequest200.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,42 @@
"embed_url": "https://example.com",
"redirect_url": "https://box.com/redirect_url_signer_1",
"declined_redirect_url": "https://box.com/declined_redirect_url_signer_1",
"iframeable_embed_url": "https://app.box.com/embed/sign/document/bf7aaac6/"
"iframeable_embed_url": "https://app.box.com/embed/sign/document/bf7aaac6/",
"login_required": false,
"password": "abcdefg",
"signer_group_id": "cd4ff89-8fc1-42cf-8b29-1890dedd26d7",
"verification_phone_number": "1234567890"
},
{
"email": "[email protected]",
"role": "signer",
"is_in_person": true,
"order": 2,
"embed_url_external_user_id": 1234,
"has_viewed_document": true,
"signer_decision": {
"type": "signed",
"finalized_at": "2021-04-26T08:12:13.982Z"
},
"inputs": [
{
"document_tag_id": 1234,
"text_value": "text",
"checkbox_value": true,
"date_value": "2021-04-26T08:12:13.982Z",
"type": "text",
"page_index": 4,
"content_type": "checkbox"
}
],
"embed_url": "https://example.com",
"redirect_url": "https://box.com/redirect_url_signer_1",
"declined_redirect_url": "https://box.com/declined_redirect_url_signer_1",
"iframeable_embed_url": "https://app.box.com/embed/sign/document/bf7aaac6/",
"login_required": false,
"password": "abcdefg",
"signer_group_id": "cd4ff89-8fc1-42cf-8b29-1890dedd26d7",
"verification_phone_number": "1234567890"
}
],
"signing_log": {
Expand Down
32 changes: 32 additions & 0 deletions Box.V2/Models/BoxSignRequestSigner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public class BoxSignRequestSigner
public const string FieldDeclinedRedirectUrl = "declined_redirect_url";
public const string FieldRedirectUrl = "redirect_url";
public const string FieldIframeableEmbedUrl = "iframeable_embed_url";
public const string FieldLoginRequired = "login_required";
public const string FieldPassword = "password";
public const string FieldSignerGroupId = "signer_group_id";
public const string FieldVerificationPhoneNumber = "verification_phone_number";


/// <summary>
/// Email address of the signer.
Expand Down Expand Up @@ -97,6 +102,33 @@ public class BoxSignRequestSigner
/// </summary>
[JsonProperty(PropertyName = FieldIframeableEmbedUrl)]
public virtual string IframeableEmbedUrl { get; private set; }

/// <summary>
/// If set to true, signer will need to login to a Box account before signing the request.
/// If the signer does not have an existing account, they will have an option to create a free Box account.
/// </summary>
[JsonProperty(PropertyName = FieldLoginRequired)]
public virtual bool LoginRequired { get; private set; }

/// <summary>
/// If set, the signer is required to enter the password before they are able to sign a document. This field is write only.
/// </summary>
[JsonProperty(PropertyName = FieldPassword)]
public virtual string Password { get; private set; }

/// <summary>
/// If set, signers who have the same group ID will be assigned to the same input.
/// A signer group is expected to have more than one signer.
/// When a group contains fewer than two signers, it will be converted to a single signer and the group will be removed.
/// </summary>
[JsonProperty(PropertyName = FieldSignerGroupId)]
public virtual string SignerGroupId { get; private set; }

/// <summary>
/// If set, this phone number is be used to verify the signer via two factor authentication before they are able to sign the document.
/// </summary>
[JsonProperty(PropertyName = FieldVerificationPhoneNumber)]
public virtual string VerificationPhoneNumber { get; private set; }
}

/// <summary>
Expand Down
27 changes: 27 additions & 0 deletions Box.V2/Models/Request/BoxSignRequestCreateRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,32 @@ public class BoxSignRequestSignerCreate
/// </summary>
[JsonProperty(PropertyName = "redirect_url")]
public Uri RedirectUrl { get; set; }

/// <summary>
/// If set to true, signer will need to login to a Box account before signing the request.
/// If the signer does not have an existing account, they will have an option to create a free Box account.
/// </summary>
[JsonProperty(PropertyName = "login_required")]
public bool? LoginRequired { get; set; }

/// <summary>
/// If set, the signer is required to enter the password before they are able to sign a document. This field is write only.
/// </summary>
[JsonProperty(PropertyName = "password")]
public string Password { get; set; }

/// <summary>
/// If set, signers who have the same group ID will be assigned to the same input.
/// A signer group is expected to have more than one signer.
/// When a group contains fewer than two signers, it will be converted to a single signer and the group will be removed.
/// </summary>
[JsonProperty(PropertyName = "signer_group_id")]
public string SignerGroupId { get; set; }

/// <summary>
/// If set, this phone number is be used to verify the signer via two factor authentication before they are able to sign the document.
/// </summary>
[JsonProperty(PropertyName = "verification_phone_number")]
public string VerificationPhoneNumber { get; set; }
}
}
Loading