From f7b1b4409e0f72c264cc23a0f1ca1849060bf121 Mon Sep 17 00:00:00 2001 From: Minh Nguyen Cong Date: Fri, 23 Feb 2024 11:31:13 +0100 Subject: [PATCH] feat: Support sign request signer group ID (#521) --- docs/sign-requests.md | 4 ++-- src/commands/sign-requests/create.js | 10 ++++++++-- test/commands/sign-requests.test.js | 14 +++++++++----- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/docs/sign-requests.md b/docs/sign-requests.md index 5e6ba31e..313a5453 100644 --- a/docs/sign-requests.md +++ b/docs/sign-requests.md @@ -167,8 +167,8 @@ OPTIONS --signer=signer (required) A signer for the sign request. 35 is the max number of signers permitted. Can be added multiple times. Allowed (recommended) properties: - email,role,is-in-person,order,embed-url-external-user-id,redirect-url,declined-redirect-url but snake case is also - supported for: is_in_person,order,embed_url_external_user_id,redirect_url,declined_redirect_url + email,role,is-in-person,order,embed-url-external-user-id,redirect-url,declined-redirect-url,group-id but snake case is also + supported for: is_in_person,order,embed_url_external_user_id,redirect_url,declined_redirect_url,group_id --source-files=source-files (required) Comma separated list of files to create a signing document from. This is currently limited to 10 files, diff --git a/src/commands/sign-requests/create.js b/src/commands/sign-requests/create.js index 81854c3b..41251036 100644 --- a/src/commands/sign-requests/create.js +++ b/src/commands/sign-requests/create.js @@ -48,8 +48,8 @@ SignRequestsCreateCommand.flags = { required: true, description: 'A signer for the sign request. 35 is the max number of signers permitted. Can be added multiple times. ' + - 'Allowed (recommended) properties: email,role,is-in-person,order,embed-url-external-user-id,redirect-url,declined-redirect-url ' + - 'but snake case is also supported for: is_in_person,order,embed_url_external_user_id,redirect_url,declined_redirect_url', + 'Allowed (recommended) properties: email,role,is-in-person,order,embed-url-external-user-id,redirect-url,declined-redirect-url,group-id ' + + 'but snake case is also supported for: is_in_person,order,embed_url_external_user_id,redirect_url,declined_redirect_url,group_id', multiple: true, parse(input) { const signer = { @@ -107,6 +107,12 @@ SignRequestsCreateCommand.flags = { signer.declined_redirect_url = value; break; + case 'signer-group-id': + case 'signer_group_id': + case 'group-id': + case 'group_id': + signer.signer_group_id = value; + break; default: throw new BoxCLIError(`Unknown property for signer: ${key}`); } diff --git a/test/commands/sign-requests.test.js b/test/commands/sign-requests.test.js index fab5f94c..a19ede6d 100644 --- a/test/commands/sign-requests.test.js +++ b/test/commands/sign-requests.test.js @@ -58,7 +58,8 @@ describe('Sign requests', () => { documentTag2Id = '4567', fixture = getFixture('sign-requests/post_sign_requests'), redirectUrl = 'https://box.com/redirect_url', - declinedRedirectUrl = 'https://box.com/declined_redirect_url'; + declinedRedirectUrl = 'https://box.com/declined_redirect_url', + signerGroupId = 'signers'; test .nock(TEST_API_ROOT, api => api @@ -69,7 +70,8 @@ describe('Sign requests', () => { email: signerEmail, is_in_person: true, redirect_url: signerRedirectUrl, - declined_redirect_url: signerDeclinedRedirectUrl + declined_redirect_url: signerDeclinedRedirectUrl, + signer_group_id: signerGroupId }, ], source_files: [ @@ -104,7 +106,7 @@ describe('Sign requests', () => { .stdout() .command([ 'sign-requests:create', - `--signer=email=${signerEmail},role=approver,is_in_person=1,redirect_url=${signerRedirectUrl},declined_redirect_url=${signerDeclinedRedirectUrl}`, + `--signer=email=${signerEmail},role=approver,is_in_person=1,redirect_url=${signerRedirectUrl},declined_redirect_url=${signerDeclinedRedirectUrl},group_id=${signerGroupId}`, `--source-files=${fileId},${fileId2}`, `--parent-folder=${parentFolderId}`, `--prefill-tag=id=${documentTag1Id},text=${documentTag1Value}`, @@ -127,7 +129,8 @@ describe('Sign requests', () => { email: signerEmail, is_in_person: true, redirect_url: signerRedirectUrl, - declined_redirect_url: signerDeclinedRedirectUrl + declined_redirect_url: signerDeclinedRedirectUrl, + signer_group_id: signerGroupId }, ], source_files: [ @@ -162,7 +165,7 @@ describe('Sign requests', () => { .stdout() .command([ 'sign-requests:create', - `--signer=email=${signerEmail},role=approver,is-in-person=1,redirect-url=${signerRedirectUrl},declined-redirect-url=${signerDeclinedRedirectUrl}`, + `--signer=email=${signerEmail},role=approver,is-in-person=1,redirect-url=${signerRedirectUrl},declined-redirect-url=${signerDeclinedRedirectUrl},group-id=${signerGroupId}`, `--source-files=${fileId},${fileId2}`, `--parent-folder=${parentFolderId}`, `--prefill-tag=id=${documentTag1Id},text=${documentTag1Value}`, @@ -175,6 +178,7 @@ describe('Sign requests', () => { .it('should create a sign request with kebab case', ctx => { assert.equal(ctx.stdout, fixture); }); + }); describe('sign-requests:cancel', () => {