@@ -8,7 +8,6 @@ const path = require('path')
8
8
, fs = require ( 'fs-extra' )
9
9
, docusign = require ( 'docusign-esign' )
10
10
, validator = require ( 'validator' )
11
- , { promisify} = require ( 'util' ) // http://2ality.com/2017/05/util-promisify.html
12
11
, dsConfig = require ( '../../ds_configuration.js' ) . config
13
12
;
14
13
@@ -23,29 +22,6 @@ const eg001EmbeddedSigning = exports
23
22
, dsPingUrl = dsConfig . appUrl + '/' // Url that will be pinged by the DocuSign Signing Ceremony via Ajax
24
23
;
25
24
26
- /**
27
- * Form page for this application
28
- */
29
- eg001EmbeddedSigning . getController = ( req , res ) => {
30
- // Check that the authentication token is ok with a long buffer time.
31
- // If needed, now is the best time to ask the user to authenticate
32
- // since they have not yet entered any information into the form.
33
- let tokenOK = req . dsAuthCodeGrant . checkToken ( ) ;
34
- if ( tokenOK ) {
35
- res . render ( 'pages/examples/eg001EmbeddedSigning' , {
36
- csrfToken : req . csrfToken ( ) ,
37
- title : "Embedded Signing Ceremony" ,
38
- sourceFile : path . basename ( __filename ) ,
39
- sourceUrl : dsConfig . githubExampleUrl + path . basename ( __filename ) ,
40
- documentation : dsConfig . documentation + eg ,
41
- showDoc : dsConfig . documentation
42
- } ) ;
43
- } else {
44
- // Save the current operation so it will be resumed after authentication
45
- req . dsAuthCodeGrant . setEg ( req , eg ) ;
46
- res . redirect ( mustAuthenticate ) ;
47
- }
48
- }
49
25
50
26
/**
51
27
* Create the envelope, the Signing Ceremony, and then redirect to the Signing Ceremony
@@ -125,7 +101,6 @@ eg001EmbeddedSigning.createController = async (req, res) => {
125
101
// ***DS.worker.start ***DS.snippet.1.start
126
102
eg001EmbeddedSigning . worker = async ( args ) => {
127
103
let envelopesApi = new docusign . EnvelopesApi ( args . dsAPIclient )
128
- , createEnvelopeP = promisify ( envelopesApi . createEnvelope ) . bind ( envelopesApi )
129
104
, results = null
130
105
;
131
106
@@ -134,19 +109,16 @@ eg001EmbeddedSigning.worker = async (args) => {
134
109
135
110
// Step 2. call Envelopes::create API method
136
111
// Exceptions will be caught by the calling function
137
- results = await createEnvelopeP ( args . accountId , { envelopeDefinition : envelope } ) ;
138
-
112
+ results = await envelopesApi . createEnvelope ( args . accountId , { envelopeDefinition : envelope } ) ;
113
+
139
114
let envelopeId = results . envelopeId ;
140
115
console . log ( `Envelope was created. EnvelopeId ${ envelopeId } ` ) ;
141
116
142
117
// Step 3. create the recipient view, the Signing Ceremony
143
- let viewRequest = makeRecipientViewRequest ( args . envelopeArgs )
144
- , createRecipientViewP = promisify ( envelopesApi . createRecipientView ) . bind ( envelopesApi )
145
- ;
146
-
118
+ let viewRequest = makeRecipientViewRequest ( args . envelopeArgs ) ;
147
119
// Call the CreateRecipientView API
148
120
// Exceptions will be caught by the calling function
149
- results = await createRecipientViewP ( args . accountId , envelopeId ,
121
+ results = await envelopesApi . createRecipientView ( args . accountId , envelopeId ,
150
122
{ recipientViewRequest : viewRequest } ) ;
151
123
152
124
return ( { envelopeId : envelopeId , redirectUrl : results . url } )
@@ -267,3 +239,27 @@ function makeRecipientViewRequest(args) {
267
239
}
268
240
// ***DS.snippet.3.end
269
241
242
+
243
+ /**
244
+ * Form page for this application
245
+ */
246
+ eg001EmbeddedSigning . getController = ( req , res ) => {
247
+ // Check that the authentication token is ok with a long buffer time.
248
+ // If needed, now is the best time to ask the user to authenticate
249
+ // since they have not yet entered any information into the form.
250
+ let tokenOK = req . dsAuthCodeGrant . checkToken ( ) ;
251
+ if ( tokenOK ) {
252
+ res . render ( 'pages/examples/eg001EmbeddedSigning' , {
253
+ csrfToken : req . csrfToken ( ) ,
254
+ title : "Embedded Signing Ceremony" ,
255
+ sourceFile : path . basename ( __filename ) ,
256
+ sourceUrl : dsConfig . githubExampleUrl + path . basename ( __filename ) ,
257
+ documentation : dsConfig . documentation + eg ,
258
+ showDoc : dsConfig . documentation
259
+ } ) ;
260
+ } else {
261
+ // Save the current operation so it will be resumed after authentication
262
+ req . dsAuthCodeGrant . setEg ( req , eg ) ;
263
+ res . redirect ( mustAuthenticate ) ;
264
+ }
265
+ }
0 commit comments