Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
raileendr committed May 20, 2024
2 parents b7ac303 + 90e8274 commit 48b448a
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 34 deletions.
3 changes: 1 addition & 2 deletions lib/eSignature/controllers/eg011EmbeddedSending.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,20 @@ 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)
};
const args = {
accessToken: req.user.accessToken,
basePath: req.session.basePath,
accountId: req.session.accountId,
startingView: startingView,
envelopeArgs: envelopeArgs
};
let results = null;
Expand Down
70 changes: 45 additions & 25 deletions lib/eSignature/examples/embeddedSending.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -34,42 +34,21 @@ 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
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;
return viewRequest;
}
//ds-snippet-end:eSign11Step3

//ds-snippet-start:eSign11Step2
function makeEnvelope(args) {
// Data for this method
// args.signerEmail
Expand Down Expand Up @@ -186,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
Expand Down Expand Up @@ -226,6 +247,5 @@ function document1(args) {
</html>
`;
}
//ds-snippet-end:eSign11Step2

module.exports = { sendEnvelopeUsingEmbeddedSending };
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions views/pages/examples/eg011EmbeddedSending.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<div class="form-group">
<label for="startingView"><%= example.Forms[0].Inputs[0].InputName %></label>
<select id="startingView" name="startingView" class="form-control">
<option value="tagging" selected>Tagging view</option>
<option value="recipient">Recipient &amp; Documents view</option>
<option value="Tagger" selected>Tagging view</option>
<option value="Prepare">Prepare view</option>
</select>
</div>
<div class="form-group">
Expand Down

0 comments on commit 48b448a

Please sign in to comment.