@@ -23,30 +23,35 @@ const docusign = require("docusign-esign");
2323 * @param {string } args.envelopeArgs.docFile Path to the document
2424 */
2525const sendEnvelopeForInPersonSigning = async ( args ) => {
26+
27+ // Step 3 start
2628 const dsApiClient = new docusign . ApiClient ( ) ;
2729 dsApiClient . setBasePath ( args . basePath ) ;
2830 dsApiClient . addDefaultHeader ( "Authorization" , "Bearer " + args . accessToken ) ;
2931 const envelopesApi = new docusign . EnvelopesApi ( dsApiClient ) ;
3032
31- // Step 1. Make the envelope request body
33+ // Make the envelope request body
3234 const envelope = makeEnvelope ( args . envelopeArgs ) ;
3335
34- // Step 2. call Envelopes::create API method
36+ // Call Envelopes::create API method
3537 // Exceptions will be caught by the calling function
3638 let results = await envelopesApi . createEnvelope ( args . accountId , {
3739 envelopeDefinition : envelope ,
3840 } ) ;
3941
4042 const envelopeId = results . envelopeId ;
43+ // Step 3 end
4144 console . log ( `Envelope was created. EnvelopeId ${ envelopeId } ` ) ;
4245
43- // Step 3. create the recipient view, the embedded signing
46+ // Create the recipient view, the embedded signing
47+ // Step 5 start
4448 const viewRequest = makeRecipientViewRequest ( args . envelopeArgs ) ;
4549 // Call the CreateRecipientView API
4650 // Exceptions will be caught by the calling function
4751 results = await envelopesApi . createRecipientView ( args . accountId , envelopeId , {
4852 recipientViewRequest : viewRequest ,
4953 } ) ;
54+ // Step 5 end
5055
5156 return { envelopeId : envelopeId , redirectUrl : results . url } ;
5257} ;
@@ -62,6 +67,8 @@ const sendEnvelopeForInPersonSigning = async (args) => {
6267 * @returns {Envelope } An envelope definition
6368 * @private
6469 */
70+
71+ // Step 2 start
6572function makeEnvelope ( args ) {
6673 // document 1 (pdf) has tag /sn1/
6774 //
@@ -127,6 +134,8 @@ function makeEnvelope(args) {
127134 return env ;
128135}
129136
137+ // Step 2 end
138+
130139/**
131140 * Creates recipient view definition
132141 * @function
@@ -138,6 +147,7 @@ function makeEnvelope(args) {
138147 * @returns {docusign.RecipientViewRequest } A recipient view definition
139148 * @private
140149 */
150+ // Step 4 start
141151function makeRecipientViewRequest ( args ) {
142152 let viewRequest = new docusign . RecipientViewRequest ( ) ;
143153
@@ -172,5 +182,6 @@ function makeRecipientViewRequest(args) {
172182
173183 return viewRequest ;
174184}
185+ // Step 4 end
175186
176187module . exports = { sendEnvelopeForInPersonSigning } ;
0 commit comments