From dcb86af92973a7f6139ccdba9332df3988d2b497 Mon Sep 17 00:00:00 2001 From: Mykyta-Petrov Date: Thu, 9 May 2024 14:28:03 +0300 Subject: [PATCH 1/2] Embedded sending update --- .../controllers/eg011EmbeddedSending.js | 3 +- lib/eSignature/examples/embeddedSending.js | 39 +++++++++++++++---- package-lock.json | 8 ++-- package.json | 2 +- views/pages/examples/eg011EmbeddedSending.ejs | 4 +- 5 files changed, 40 insertions(+), 16 deletions(-) diff --git a/lib/eSignature/controllers/eg011EmbeddedSending.js b/lib/eSignature/controllers/eg011EmbeddedSending.js index ac4174d..2e049fb 100644 --- a/lib/eSignature/controllers/eg011EmbeddedSending.js +++ b/lib/eSignature/controllers/eg011EmbeddedSending.js @@ -42,13 +42,13 @@ eg011EmbeddedSending.createController = async (req, res) => { // Step 2. Call the worker method const { body } = req; // Additional data validation might also be appropriate - const startingView = validator.escape(body.startingView); const envelopeArgs = { signerEmail: validator.escape(body.signerEmail), signerName: validator.escape(body.signerName), ccEmail: validator.escape(body.ccEmail), ccName: validator.escape(body.ccName), dsReturnUrl: dsReturnUrl, + startingView: validator.escape(body.startingView), doc2File: path.resolve(demoDocsPath, doc2File), doc3File: path.resolve(demoDocsPath, doc3File) }; @@ -56,7 +56,6 @@ eg011EmbeddedSending.createController = async (req, res) => { accessToken: req.user.accessToken, basePath: req.session.basePath, accountId: req.session.accountId, - startingView: startingView, envelopeArgs: envelopeArgs }; let results = null; diff --git a/lib/eSignature/examples/embeddedSending.js b/lib/eSignature/examples/embeddedSending.js index 83a8544..25113d5 100644 --- a/lib/eSignature/examples/embeddedSending.js +++ b/lib/eSignature/examples/embeddedSending.js @@ -42,29 +42,54 @@ const sendEnvelopeUsingEmbeddedSending = async (args) => { // Call the CreateSenderView API // Exceptions will be caught by the calling function results = await envelopesApi.createSenderView(args.accountId, envelopeId, { - returnUrlRequest: viewRequest, + envelopeViewRequest: viewRequest, }); // Switch to Recipient and Documents view if requested by the user let url = results.url; //ds-snippet-end:eSign11Step3 - console.log(`startingView: ${args.startingView}`); - if (args.startingView === 'recipient') { - url = url.replace('send=1', 'send=0'); - } + console.log(`startingView: ${args.envelopeArgs.startingView}`); return { envelopeId: envelopeId, redirectUrl: url }; }; //ds-snippet-start:eSign11Step3 function makeSenderViewRequest(args) { - let viewRequest = new docusign.ReturnUrlRequest(); // Data for this method // args.dsReturnUrl // Set the url where you want the recipient to go once they are done signing // should typically be a callback route somewhere in your app. - viewRequest.returnUrl = args.dsReturnUrl; + let viewRequest = docusign.EnvelopeViewRequest.constructFromObject({ + returnUrl: args.dsReturnUrl, + viewAccess: 'envelope', + settings: docusign.EnvelopeViewSettings.constructFromObject({ + startingScreen: args.startingView, + sendButtonAction: 'send', + showBackButton: 'false', + backButtonAction: 'previousPage', + showHeaderActions: 'false', + showDiscardAction: 'false', + lockToken: '', + recipientSettings: docusign.EnvelopeViewRecipientSettings.constructFromObject({ + showEditRecipients: 'false', + showContactsList: 'false' + }), + documentSettings: docusign.EnvelopeViewDocumentSettings.constructFromObject({ + showEditDocuments: 'false', + showEditDocumentVisibility: 'false', + showEditPages: 'false' + }), + taggerSettings: docusign.EnvelopeViewTaggerSettings.constructFromObject({ + paletteSections: 'default', + paletteDefault: 'custom' + }), + templateSettings: docusign.EnvelopeViewTemplateSettings.constructFromObject({ + showMatchingTemplatesPrompt: 'true' + }) + }) + }); + return viewRequest; } //ds-snippet-end:eSign11Step3 diff --git a/package-lock.json b/package-lock.json index be72369..bbdb587 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ "csurf": "^1.11.0", "docusign-admin": "^2.3.0", "docusign-click": "^2.2.0", - "docusign-esign": "^6.6.0-rc2", + "docusign-esign": "^7.0.0-rc1", "docusign-maestro": "1.0.0-rc3", "docusign-monitor": "^2.1.0", "docusign-rooms": "^2.0.0", @@ -1121,9 +1121,9 @@ } }, "node_modules/docusign-esign": { - "version": "6.6.0-rc2", - "resolved": "https://registry.npmjs.org/docusign-esign/-/docusign-esign-6.6.0-rc2.tgz", - "integrity": "sha512-416mUnL5VC89s36L1Sf0XcSPbtoXzvyTCk3HffbYxm7Fue6C52oEWGhz7CveEBKFVlswIQa1BvmvLA6Yhl7M5A==", + "version": "7.0.0-rc1", + "resolved": "https://registry.npmjs.org/docusign-esign/-/docusign-esign-7.0.0-rc1.tgz", + "integrity": "sha512-muuh3i6lX0N747isHfGeIGGbKHFn6qFJVR1h2kcqdHPzWm80nUdQGHrRDxo/aMB895nl1kXNNUR4lWmmdghTFw==", "dependencies": { "@devhigley/parse-proxy": "^1.0.3", "axios": "^1.6.8", diff --git a/package.json b/package.json index feecbc1..81e5c82 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "csurf": "^1.11.0", "docusign-admin": "^2.3.0", "docusign-click": "^2.2.0", - "docusign-esign": "^6.6.0-rc2", + "docusign-esign": "^7.0.0-rc1", "docusign-maestro": "1.0.0-rc3", "docusign-monitor": "^2.1.0", "docusign-rooms": "^2.0.0", diff --git a/views/pages/examples/eg011EmbeddedSending.ejs b/views/pages/examples/eg011EmbeddedSending.ejs index 0945e6a..783bd5f 100644 --- a/views/pages/examples/eg011EmbeddedSending.ejs +++ b/views/pages/examples/eg011EmbeddedSending.ejs @@ -10,8 +10,8 @@
From a7a8387d04f944fc196d0db193cc561c46aa92bd Mon Sep 17 00:00:00 2001 From: Raileen Del Rosario Date: Fri, 17 May 2024 15:19:55 -0700 Subject: [PATCH 2/2] fixing codeDepot markers --- lib/eSignature/examples/embeddedSending.js | 91 ++++++++++------------ 1 file changed, 43 insertions(+), 48 deletions(-) diff --git a/lib/eSignature/examples/embeddedSending.js b/lib/eSignature/examples/embeddedSending.js index 25113d5..dbcdcb4 100644 --- a/lib/eSignature/examples/embeddedSending.js +++ b/lib/eSignature/examples/embeddedSending.js @@ -25,7 +25,7 @@ const sendEnvelopeUsingEmbeddedSending = async (args) => { dsApiClient.addDefaultHeader('Authorization', 'Bearer ' + args.accessToken); let envelopesApi = new docusign.EnvelopesApi(dsApiClient); - // Step 2. Make the envelope with "created" (draft) status + // Make the envelope with "created" (draft) status args.envelopeArgs.status = 'created'; // We want a draft envelope let envelope = makeEnvelope(args.envelopeArgs); @@ -34,10 +34,7 @@ const sendEnvelopeUsingEmbeddedSending = async (args) => { envelopeDefinition: envelope, }); let envelopeId = results.envelopeId; - //ds-snippet-end:eSign11Step2 - // Step 3. create the sender view - //ds-snippet-start:eSign11Step3 let viewRequest = makeSenderViewRequest(args.envelopeArgs); // Call the CreateSenderView API // Exceptions will be caught by the calling function @@ -47,54 +44,11 @@ const sendEnvelopeUsingEmbeddedSending = async (args) => { // Switch to Recipient and Documents view if requested by the user let url = results.url; - //ds-snippet-end:eSign11Step3 console.log(`startingView: ${args.envelopeArgs.startingView}`); return { envelopeId: envelopeId, redirectUrl: url }; }; -//ds-snippet-start:eSign11Step3 -function makeSenderViewRequest(args) { - // Data for this method - // args.dsReturnUrl - - // Set the url where you want the recipient to go once they are done signing - // should typically be a callback route somewhere in your app. - let viewRequest = docusign.EnvelopeViewRequest.constructFromObject({ - returnUrl: args.dsReturnUrl, - viewAccess: 'envelope', - settings: docusign.EnvelopeViewSettings.constructFromObject({ - startingScreen: args.startingView, - sendButtonAction: 'send', - showBackButton: 'false', - backButtonAction: 'previousPage', - showHeaderActions: 'false', - showDiscardAction: 'false', - lockToken: '', - recipientSettings: docusign.EnvelopeViewRecipientSettings.constructFromObject({ - showEditRecipients: 'false', - showContactsList: 'false' - }), - documentSettings: docusign.EnvelopeViewDocumentSettings.constructFromObject({ - showEditDocuments: 'false', - showEditDocumentVisibility: 'false', - showEditPages: 'false' - }), - taggerSettings: docusign.EnvelopeViewTaggerSettings.constructFromObject({ - paletteSections: 'default', - paletteDefault: 'custom' - }), - templateSettings: docusign.EnvelopeViewTemplateSettings.constructFromObject({ - showMatchingTemplatesPrompt: 'true' - }) - }) - }); - - return viewRequest; -} -//ds-snippet-end:eSign11Step3 - -//ds-snippet-start:eSign11Step2 function makeEnvelope(args) { // Data for this method // args.signerEmail @@ -211,6 +165,48 @@ function makeEnvelope(args) { return env; } +//ds-snippet-end:eSign11Step2 + +//ds-snippet-start:eSign11Step3 +function makeSenderViewRequest(args) { + // Data for this method + // args.dsReturnUrl + + // Set the url where you want the recipient to go once they are done signing + // should typically be a callback route somewhere in your app. + let viewRequest = docusign.EnvelopeViewRequest.constructFromObject({ + returnUrl: args.dsReturnUrl, + viewAccess: 'envelope', + settings: docusign.EnvelopeViewSettings.constructFromObject({ + startingScreen: args.startingView, + sendButtonAction: 'send', + showBackButton: 'false', + backButtonAction: 'previousPage', + showHeaderActions: 'false', + showDiscardAction: 'false', + lockToken: '', + recipientSettings: docusign.EnvelopeViewRecipientSettings.constructFromObject({ + showEditRecipients: 'false', + showContactsList: 'false' + }), + documentSettings: docusign.EnvelopeViewDocumentSettings.constructFromObject({ + showEditDocuments: 'false', + showEditDocumentVisibility: 'false', + showEditPages: 'false' + }), + taggerSettings: docusign.EnvelopeViewTaggerSettings.constructFromObject({ + paletteSections: 'default', + paletteDefault: 'custom' + }), + templateSettings: docusign.EnvelopeViewTemplateSettings.constructFromObject({ + showMatchingTemplatesPrompt: 'true' + }) + }) + }); + + return viewRequest; +} +//ds-snippet-end:eSign11Step3 /** * Creates document 1 @@ -251,6 +247,5 @@ function document1(args) { `; } -//ds-snippet-end:eSign11Step2 module.exports = { sendEnvelopeUsingEmbeddedSending };