-
Notifications
You must be signed in to change notification settings - Fork 100
Home
Nikhil Mashettiwar edited this page Jul 8, 2015
·
12 revisions
Welcome to the DocuSign Node Client wiki!
This example shows you how to do the following:
- Create a DocuSign Object with an Integrator Key and a Target DocuSign Environment
- Create a DocuSign Client Object with your DocuSign Account Credentials
- Create a new Envelope using a Template and sending to the recipient you specify
- Logout of the Client by Revoking the DocuSign user's OAuth Token
var docusign = require('docusign-node');
var async = require('async');
var integratorKey = "***", //Integrator Key associated with your DocuSign Integration
email = "***", //Email for your DocuSign Account
password = "***", //Password for your DocuSign Account
docusignEnv = "***", //DocuSign Environment generally demo for testing purposes
fullName = "***", //Recipient's Full Name
recipientEmail = "***", //Recipient's Email
templateId = "***", //ID of the Template you with to create the Envelope with
templateRoleName = "***"; //Role Name of the Template
var templateRoles = [{
email: email,
name: fullName,
roleName: tempalteRoleName,
}]
async.waterfall([
//**********************************************************************************
// Step 1 - Initialize DocuSign Object with Integratory Key and Desired Environment
//**********************************************************************************
function init(next){
docusign.init(integratorKey, docusignEnv, debug, function(response){
if(response.message === 'succesfully initialized'){
next(null);
} else {
return;
}
});
},
//**********************************************************************************
// Step 2 - Create a DocuSign Client Object
//**********************************************************************************
function createClient(next){
docusign.client(email, password, function(response){
if('error' in response){
console.log('Error: ' + response.error);
return;
}
next(null, response);
});
},
//**********************************************************************************
// Step 3 - Request Signature via Template
//**********************************************************************************
function sendTemplate(client, next){
client.envelopes.sendEnvelope('Sent from a Template', templateId, templateRoles, function(err, response){
if(response.error){
console.log('Error: ' + response.error);
return;
}
console.log('The envelope information of the created envelope is: \n' + JSON.stringify(response));
next(null, client);
});
},
//**********************************************************************************
// Step 4 - Revoke OAuth Token for Logout
//**********************************************************************************
function logOut(client, next){
client.logOut(function(err, response){
if(!err){
next(null);
} else {
console.log(err);
}
});
},
]);