@@ -41,53 +41,53 @@ eg030ApplyBrandToTemplate.createController = async (req, res) => {
4141 documentation : dsConfig . documentation + eg ,
4242 showDoc : dsConfig . documentation
4343 } ) ;
44- }
45-
46- const { body } = req ;
44+ } else {
45+ const { body } = req ;
4746
48- //Step 1. Obtain your OAuth token
49- const args = {
50- accessToken : req . user . accessToken , // Represents your {ACCESS_TOKEN}
51- basePath : req . session . basePath ,
52- accountId : req . session . accountId , // Represents your {ACCOUNT_ID}
53- brandId : validator . escape ( body . brandId ) ,
54- templateId : req . session . templateId ,
55- status : req . status ,
56- templateRoles : [
57- {
58- name : validator . escape ( body . signerName ) ,
59- email : validator . escape ( body . signerEmail ) ,
60- roleName : "signer"
61- } ,
62- {
63- name : validator . escape ( body . ccName ) ,
64- email : validator . escape ( body . ccEmail ) ,
65- roleName : "cc"
66- }
67- ]
68- } ;
69- let results = null ;
47+ //Step 1. Obtain your OAuth token
48+ const args = {
49+ accessToken : req . user . accessToken , // Represents your {ACCESS_TOKEN}
50+ basePath : req . session . basePath ,
51+ accountId : req . session . accountId , // Represents your {ACCOUNT_ID}
52+ brandId : validator . escape ( body . brandId ) ,
53+ templateId : req . session . templateId ,
54+ status : req . status ,
55+ templateRoles : [
56+ {
57+ name : validator . escape ( body . signerName ) ,
58+ email : validator . escape ( body . signerEmail ) ,
59+ roleName : "signer"
60+ } ,
61+ {
62+ name : validator . escape ( body . ccName ) ,
63+ email : validator . escape ( body . ccEmail ) ,
64+ roleName : "cc"
65+ }
66+ ]
67+ } ;
68+ let results = null ;
7069
71- try {
72- // Step 2. Call the eSignature REST API
73- results = await applyBrandToTemplate ( args ) ;
74- }
75- catch ( error ) {
76- const errorBody = error && error . response && error . response . body ;
77- // We can pull the DocuSign error code and message from the response body
78- const errorCode = errorBody && errorBody . errorCode ;
79- const errorMessage = errorBody && errorBody . message ;
80- // In production, you may want to provide customized error messages and
81- // remediation advice to the user
82- res . render ( 'pages/error' , { err : error , errorCode, errorMessage} ) ;
83- }
70+ try {
71+ // Step 2. Call the eSignature REST API
72+ results = await applyBrandToTemplate ( args ) ;
73+ }
74+ catch ( error ) {
75+ const errorBody = error && error . response && error . response . body ;
76+ // We can pull the DocuSign error code and message from the response body
77+ const errorCode = errorBody && errorBody . errorCode ;
78+ const errorMessage = errorBody && errorBody . message ;
79+ // In production, you may want to provide customized error messages and
80+ // remediation advice to the user
81+ res . render ( 'pages/error' , { err : error , errorCode, errorMessage} ) ;
82+ }
8483
85- if ( results ) {
86- res . render ( 'pages/example_done' , {
87- title : "Envelope sent" ,
88- h1 : "Envelope sent" ,
89- message : `The envelope has been created and sent!<br />Envelope ID: ${ results . envelopeId } .`
90- } ) ;
84+ if ( results ) {
85+ res . render ( 'pages/example_done' , {
86+ title : "Envelope sent" ,
87+ h1 : "Envelope sent" ,
88+ message : `The envelope has been created and sent!<br />Envelope ID: ${ results . envelopeId } .`
89+ } ) ;
90+ }
9191 }
9292}
9393
0 commit comments