@@ -25,7 +25,7 @@ const sendEnvelopeUsingEmbeddedSending = async (args) => {
2525 dsApiClient . addDefaultHeader ( 'Authorization' , 'Bearer ' + args . accessToken ) ;
2626 let envelopesApi = new docusign . EnvelopesApi ( dsApiClient ) ;
2727
28- // Step 2. Make the envelope with "created" (draft) status
28+ // Make the envelope with "created" (draft) status
2929 args . envelopeArgs . status = 'created' ; // We want a draft envelope
3030
3131 let envelope = makeEnvelope ( args . envelopeArgs ) ;
@@ -34,42 +34,21 @@ const sendEnvelopeUsingEmbeddedSending = async (args) => {
3434 envelopeDefinition : envelope ,
3535 } ) ;
3636 let envelopeId = results . envelopeId ;
37- //ds-snippet-end:eSign11Step2
3837
39- // Step 3. create the sender view
40- //ds-snippet-start:eSign11Step3
4138 let viewRequest = makeSenderViewRequest ( args . envelopeArgs ) ;
4239 // Call the CreateSenderView API
4340 // Exceptions will be caught by the calling function
4441 results = await envelopesApi . createSenderView ( args . accountId , envelopeId , {
45- returnUrlRequest : viewRequest ,
42+ envelopeViewRequest : viewRequest ,
4643 } ) ;
4744
4845 // Switch to Recipient and Documents view if requested by the user
4946 let url = results . url ;
50- //ds-snippet-end:eSign11Step3
51- console . log ( `startingView: ${ args . startingView } ` ) ;
52- if ( args . startingView === 'recipient' ) {
53- url = url . replace ( 'send=1' , 'send=0' ) ;
54- }
47+ console . log ( `startingView: ${ args . envelopeArgs . startingView } ` ) ;
5548
5649 return { envelopeId : envelopeId , redirectUrl : url } ;
5750} ;
5851
59- //ds-snippet-start:eSign11Step3
60- function makeSenderViewRequest ( args ) {
61- let viewRequest = new docusign . ReturnUrlRequest ( ) ;
62- // Data for this method
63- // args.dsReturnUrl
64-
65- // Set the url where you want the recipient to go once they are done signing
66- // should typically be a callback route somewhere in your app.
67- viewRequest . returnUrl = args . dsReturnUrl ;
68- return viewRequest ;
69- }
70- //ds-snippet-end:eSign11Step3
71-
72- //ds-snippet-start:eSign11Step2
7352function makeEnvelope ( args ) {
7453 // Data for this method
7554 // args.signerEmail
@@ -186,6 +165,48 @@ function makeEnvelope(args) {
186165
187166 return env ;
188167}
168+ //ds-snippet-end:eSign11Step2
169+
170+ //ds-snippet-start:eSign11Step3
171+ function makeSenderViewRequest ( args ) {
172+ // Data for this method
173+ // args.dsReturnUrl
174+
175+ // Set the url where you want the recipient to go once they are done signing
176+ // should typically be a callback route somewhere in your app.
177+ let viewRequest = docusign . EnvelopeViewRequest . constructFromObject ( {
178+ returnUrl : args . dsReturnUrl ,
179+ viewAccess : 'envelope' ,
180+ settings : docusign . EnvelopeViewSettings . constructFromObject ( {
181+ startingScreen : args . startingView ,
182+ sendButtonAction : 'send' ,
183+ showBackButton : 'false' ,
184+ backButtonAction : 'previousPage' ,
185+ showHeaderActions : 'false' ,
186+ showDiscardAction : 'false' ,
187+ lockToken : '' ,
188+ recipientSettings : docusign . EnvelopeViewRecipientSettings . constructFromObject ( {
189+ showEditRecipients : 'false' ,
190+ showContactsList : 'false'
191+ } ) ,
192+ documentSettings : docusign . EnvelopeViewDocumentSettings . constructFromObject ( {
193+ showEditDocuments : 'false' ,
194+ showEditDocumentVisibility : 'false' ,
195+ showEditPages : 'false'
196+ } ) ,
197+ taggerSettings : docusign . EnvelopeViewTaggerSettings . constructFromObject ( {
198+ paletteSections : 'default' ,
199+ paletteDefault : 'custom'
200+ } ) ,
201+ templateSettings : docusign . EnvelopeViewTemplateSettings . constructFromObject ( {
202+ showMatchingTemplatesPrompt : 'true'
203+ } )
204+ } )
205+ } ) ;
206+
207+ return viewRequest ;
208+ }
209+ //ds-snippet-end:eSign11Step3
189210
190211/**
191212 * Creates document 1
@@ -226,6 +247,5 @@ function document1(args) {
226247 </html>
227248 ` ;
228249}
229- //ds-snippet-end:eSign11Step2
230250
231251module . exports = { sendEnvelopeUsingEmbeddedSending } ;
0 commit comments