@@ -25,7 +25,7 @@ const sendEnvelopeUsingEmbeddedSending = async (args) => {
25
25
dsApiClient . addDefaultHeader ( 'Authorization' , 'Bearer ' + args . accessToken ) ;
26
26
let envelopesApi = new docusign . EnvelopesApi ( dsApiClient ) ;
27
27
28
- // Step 2. Make the envelope with "created" (draft) status
28
+ // Make the envelope with "created" (draft) status
29
29
args . envelopeArgs . status = 'created' ; // We want a draft envelope
30
30
31
31
let envelope = makeEnvelope ( args . envelopeArgs ) ;
@@ -34,42 +34,21 @@ const sendEnvelopeUsingEmbeddedSending = async (args) => {
34
34
envelopeDefinition : envelope ,
35
35
} ) ;
36
36
let envelopeId = results . envelopeId ;
37
- //ds-snippet-end:eSign11Step2
38
37
39
- // Step 3. create the sender view
40
- //ds-snippet-start:eSign11Step3
41
38
let viewRequest = makeSenderViewRequest ( args . envelopeArgs ) ;
42
39
// Call the CreateSenderView API
43
40
// Exceptions will be caught by the calling function
44
41
results = await envelopesApi . createSenderView ( args . accountId , envelopeId , {
45
- returnUrlRequest : viewRequest ,
42
+ envelopeViewRequest : viewRequest ,
46
43
} ) ;
47
44
48
45
// Switch to Recipient and Documents view if requested by the user
49
46
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 } ` ) ;
55
48
56
49
return { envelopeId : envelopeId , redirectUrl : url } ;
57
50
} ;
58
51
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
73
52
function makeEnvelope ( args ) {
74
53
// Data for this method
75
54
// args.signerEmail
@@ -186,6 +165,48 @@ function makeEnvelope(args) {
186
165
187
166
return env ;
188
167
}
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
189
210
190
211
/**
191
212
* Creates document 1
@@ -226,6 +247,5 @@ function document1(args) {
226
247
</html>
227
248
` ;
228
249
}
229
- //ds-snippet-end:eSign11Step2
230
250
231
251
module . exports = { sendEnvelopeUsingEmbeddedSending } ;
0 commit comments