Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'docusign-esign' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
// list of user account(s)
// note that a given user may be a member of multiple accounts
var loginAccounts = loginInfo.getLoginAccounts();
console.log('LoginInformation: ' + JSON.stringify(loginAccounts));
// ===============================================================================
// Step 2: List Recipients() API
// ===============================================================================
// use the |accountId| we retrieved through the Login API
var loginAccount = new docusign.LoginAccount();
loginAccount = loginAccounts[0];
var accountId = loginAccount.accountId;
// instantiate a new EnvelopesApi object
var envelopesApi = new docusign.EnvelopesApi();
// call the listRecipients() API
envelopesApi.listRecipients(accountId, envelopeId, function (error, recips, response) {
if (error) {
console.log('Error: ' + error);
return;
}
if (recips) {
console.log('Recipients: ' + JSON.stringify(recips));
}
});
}
});
}; // end listRecipients()
// list of user account(s)
// note that a given user may be a member of multiple accounts
var loginAccounts = loginInfo.getLoginAccounts();
console.log('LoginInformation: ' + JSON.stringify(loginAccounts));
// ===============================================================================
// Step 2: Create ConsoleView API
// ===============================================================================
// use the |accountId| we retrieved through the Login API
var loginAccount = new docusign.LoginAccount();
loginAccount = loginAccounts[0];
var accountId = loginAccount.accountId;
// instantiate a new envelopesApi object
var envelopesApi = new docusign.EnvelopesApi();
// set the url where you want the user to go once they logout of the Console
var returnUrl = new docusign.ConsoleViewRequest();
returnUrl.setReturnUrl('https://www.docusign.com/devcenter');
// call the createConsoleView() API
envelopesApi.createConsoleView(accountId, returnUrl, function (error, consoleView, response) {
if (error) {
console.log('Error: ' + error);
return;
}
if (consoleView) {
console.log('ConsoleView: ' + JSON.stringify(consoleView));
}
});
}
if (envelopeSummary) {
envelopeId = envelopeSummary.envelopeId;
console.log('EnvelopeSummary: ' + JSON.stringify(envelopeSummary));
// ===============================================================================
// Step 3: Create RecipientView API
// ===============================================================================
// use the |accountId| we retrieved through the Login API
var loginAccount = new docusign.LoginAccount();
loginAccount = loginAccounts[0];
var accountId = loginAccount.accountId;
// instantiate a new EnvelopesApi object
var envelopesApi = new docusign.EnvelopesApi();
// set the url where you want the recipient to go once they are done signing
var returnUrl = new docusign.RecipientViewRequest();
returnUrl.setReturnUrl('https://www.docusign.com/devcenter');
returnUrl.setAuthenticationMethod('email');
// recipient information must match embedded recipient info we provided in step #2
returnUrl.setEmail(signerEmail);
returnUrl.setUserName(signerName);
returnUrl.setRecipientId('1');
returnUrl.setClientUserId('1001');
// call the CreateRecipientView API
envelopesApi.createRecipientView(accountId, envelopeId, returnUrl, function (error, recipientView, response) {
if (error) {
console.log('Error: ' + error);
// list of user account(s)
// note that a given user may be a member of multiple accounts
var loginAccounts = loginInfo.getLoginAccounts();
console.log('LoginInformation: ' + JSON.stringify(loginAccounts));
// ===============================================================================
// Step 2: Get Document API
// ===============================================================================
// use the |accountId| we retrieved through the Login API
var loginAccount = new docusign.LoginAccount();
loginAccount = loginAccounts[0];
var accountId = loginAccount.accountId;
// instantiate a new EnvelopesApi object
var envelopesApi = new docusign.EnvelopesApi();
// call the getDocument() API
envelopesApi.getDocument(accountId, envelopeId, documentId, function (error, document, response) {
if (error) {
console.log('Error: ' + error);
return;
}
if (document) {
try {
var fs = require('fs');
var path = require('path');
// download the document pdf
var filename = accountId + '_' + envelopeId + '_' + documentId + '.pdf';
var tempFile = path.resolve(__dirname, filename);
fs.writeFile(tempFile, Buffer.from(document, 'binary'), function (err) {
// list of user account(s)
// note that a given user may be a member of multiple accounts
var loginAccounts = loginInfo.getLoginAccounts();
console.log('LoginInformation: ' + JSON.stringify(loginAccounts));
// ===============================================================================
// Step 2: List Envelope API
// ===============================================================================
// use the |accountId| we retrieved through the Login API
var loginAccount = new docusign.LoginAccount();
loginAccount = loginAccounts[0];
var accountId = loginAccount.accountId;
// instantiate a new EnvelopesApi object
var envelopesApi = new docusign.EnvelopesApi();
// the list status changes call requires at least a from_date
var options = new envelopesApi.ListStatusChangesOptions();
// set from date to filter envelopes (ex: Dec 1, 2015)
options.setFromDate('2015/12/01');
// call the listStatusChanges() API
envelopesApi.listStatusChanges(accountId, options, function (error, envelopes, response) {
if (error) {
console.log('Error: ' + error);
return;
}
if (envelopes) {
console.log('EnvelopesInformation: ' + JSON.stringify(envelopes));
}
if (envelopeSummary) {
envelopeId = envelopeSummary.getEnvelopeId();
console.log('EnvelopeSummary: ' + JSON.stringify(envelopeSummary));
// ===============================================================================
// Step 3: Create SenderView API
// ===============================================================================
// use the |accountId| we retrieved through the Login API
var loginAccount = new docusign.LoginAccount();
loginAccount = loginAccounts[0];
var accountId = loginAccount.accountId;
// instantiate a new EnvelopesApi object
var envelopesApi = new docusign.EnvelopesApi();
// set the url where you want the sender to go once they are done editing/sending the envelope
var returnUrl = new docusign.ReturnUrlRequest();
returnUrl.setReturnUrl('https://www.docusign.com/devcenter');
// call the createEnvelope() API
envelopesApi.createSenderView(accountId, envelopeId, returnUrl, function (error, senderView, response) {
if (error) {
console.log('Error: ' + error);
return;
}
if (senderView) {
console.log('ViewUrl: ' + JSON.stringify(senderView));
}
});
// list of user account(s)
// note that a given user may be a member of multiple accounts
var loginAccounts = loginInfo.getLoginAccounts();
console.log('LoginInformation: ' + JSON.stringify(loginAccounts));
// ===============================================================================
// Step 2: Get Envelope API
// ===============================================================================
// use the |accountId| we retrieved through the Login API to access envelope info
var loginAccount = new docusign.LoginAccount();
loginAccount = loginAccounts[0];
var accountId = loginAccount.accountId;
// instantiate a new EnvelopesApi object
var envelopesApi = new docusign.EnvelopesApi();
// call the getEnvelope() API
envelopesApi.getEnvelope(accountId, envelopeId, null, function (error, env, response) {
if (error) {
console.log('Error: ' + error);
return;
}
if (env) {
console.log('Envelope: ' + JSON.stringify(env));
}
});
}
});
}; // end GetEnvelopeInformation()
var templateRolesList = [];
templateRolesList.push(tRole);
// assign template role(s) to the envelope
envDef.setTemplateRoles(templateRolesList);
// send the envelope by setting |status| to "sent". To save as a draft set to "created"
envDef.setStatus('sent');
// use the |accountId| we retrieved through the Login API to create the Envelope
var loginAccount = new docusign.LoginAccount();
loginAccount = loginAccounts[0];
var accountId = loginAccount.accountId;
// instantiate a new EnvelopesApi object
var envelopesApi = new docusign.EnvelopesApi();
// call the createEnvelope() API
envelopesApi.createEnvelope(accountId, envDef, null, function (error, envelopeSummary, response) {
if (error) {
console.log('Error: ' + error);
return;
}
if (envelopeSummary) {
console.log('EnvelopeSummary: ' + JSON.stringify(envelopeSummary));
}
});
}
});
}; // end RequestSignatureFromTemplate()
var EmbeddedConsole = function () {
// initialize the api client
var apiClient = new docusign.ApiClient();
apiClient.setBasePath(BaseUrl);
// create JSON formatted auth header
var creds = '{"Username":"' + UserName + '","Password":"' + Password + '","IntegratorKey":"' + IntegratorKey + '"}';
apiClient.addDefaultHeader('X-DocuSign-Authentication', creds);
// assign api client to the Configuration object
docusign.Configuration.default.setDefaultApiClient(apiClient);
// ===============================================================================
// Step 1: Login() API
// ===============================================================================
// login call available off the AuthenticationApi
var authApi = new docusign.AuthenticationApi();
// login has some optional parameters we can set
var loginOps = new authApi.LoginOptions();
loginOps.setApiPassword('true');
loginOps.setIncludeAccountIdGuid('true');
authApi.login(loginOps, function (error, loginInfo, response) {
if (error) {
console.log('Error: ' + error);
return;
}
// point to a local document for testing
var SignTest1File = '[PATH/TO/DOCUMENT/TEST.PDF]';
// we will generate this from the second API call we make
var envelopeId = '';
// initialize the api client
var apiClient = new docusign.ApiClient();
apiClient.setBasePath(BaseUrl);
// create JSON formatted auth header
var creds = '{"Username":"' + UserName + '","Password":"' + Password + '","IntegratorKey":"' + IntegratorKey + '"}';
apiClient.addDefaultHeader('X-DocuSign-Authentication', creds);
// assign api client to the Configuration object
docusign.Configuration.default.setDefaultApiClient(apiClient);
// ===============================================================================
// Step 1: Login() API
// ===============================================================================
// login call available off the AuthenticationApi
var authApi = new docusign.AuthenticationApi();
// login has some optional parameters we can set
var loginOps = new authApi.LoginOptions();
loginOps.setApiPassword('true');
loginOps.setIncludeAccountIdGuid('true');
authApi.login(loginOps, function (error, loginInfo, response) {
if (error) {
console.log('Error: ' + error);
return;
}