Skip to content

Commit

Permalink
arguments explicitly listed
Browse files Browse the repository at this point in the history
Added comments to explicitly list the arguments for the methods related to using the DocuSign API.
  • Loading branch information
LarryKlugerDS committed Dec 16, 2018
1 parent 1813d06 commit 9237c6e
Show file tree
Hide file tree
Showing 18 changed files with 255 additions and 88 deletions.
19 changes: 19 additions & 0 deletions lib/examples/eg001EmbeddedSigning.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ eg001EmbeddedSigning.createController = async (req, res) => {
*/
// ***DS.worker.start ***DS.snippet.1.start
eg001EmbeddedSigning.worker = async (args) => {
// Data for this method
// args.basePath
// args.accessToken
// args.accountId

let dsApiClient = new docusign.ApiClient();
dsApiClient.setBasePath(args.basePath);
dsApiClient.addDefaultHeader('Authorization', 'Bearer ' + args.accessToken);
Expand Down Expand Up @@ -132,6 +137,13 @@ eg001EmbeddedSigning.worker = async (args) => {
* @private
*/
function makeEnvelope(args){
// Data for this method
// args.signerEmail
// args.signerName
// args.signerClientId
// demoDocsPath (module constant)
// pdf1File (module constant)

// document 1 (pdf) has tag /sn1/
//
// The envelope has one recipients.
Expand Down Expand Up @@ -200,6 +212,13 @@ function makeEnvelope(args){

// ***DS.snippet.3.start
function makeRecipientViewRequest(args) {
// Data for this method
// args.dsReturnUrl
// args.signerEmail
// args.signerName
// args.signerClientId
// args.dsPingUrl

let viewRequest = new docusign.RecipientViewRequest();

// Set the url where you want the recipient to go once they are done signing
Expand Down
22 changes: 22 additions & 0 deletions lib/examples/eg002SigningViaEmail.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ eg002SigningViaEmail.createController = async (req, res) => {
*/
// ***DS.worker.start ***DS.snippet.1.start
eg002SigningViaEmail.worker = async (args) => {
// Data for this method
// args.basePath
// args.accessToken
// args.accountId

let dsApiClient = new docusign.ApiClient();
dsApiClient.setBasePath(args.basePath);
dsApiClient.addDefaultHeader('Authorization', 'Bearer ' + args.accessToken);
Expand Down Expand Up @@ -137,6 +142,17 @@ eg002SigningViaEmail.worker = async (args) => {
* @private
*/
function makeEnvelope(args){
// Data for this method
// args.signerEmail
// args.signerName
// args.ccEmail
// args.ccName
// args.status
// demoDocsPath (module constant)
// doc2File (module constant)
// doc3File (module constant)


// document 1 (html) has tag **signature_1**
// document 2 (docx) has tag /sn1/
// document 3 (pdf) has tag /sn1/
Expand Down Expand Up @@ -251,6 +267,12 @@ function makeEnvelope(args){
*/

function document1(args) {
// Data for this method
// args.signerEmail
// args.signerName
// args.ccEmail
// args.ccName

return `
<!DOCTYPE html>
<html>
Expand Down
6 changes: 6 additions & 0 deletions lib/examples/eg003ListEnvelopes.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ eg003ListEnvelopes.createController = async (req, res) => {
*/
// ***DS.worker.start ***DS.snippet.1.start
eg003ListEnvelopes.worker = async (args) => {
// Data for this method
// args.basePath
// args.accessToken
// args.accountId


let dsApiClient = new docusign.ApiClient();
dsApiClient.setBasePath(args.basePath);
dsApiClient.addDefaultHeader('Authorization', 'Bearer ' + args.accessToken);
Expand Down
7 changes: 7 additions & 0 deletions lib/examples/eg004EnvelopeInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ eg004EnvelopeInfo.createController = async (req, res) => {
*/
// ***DS.worker.start ***DS.snippet.1.start
eg004EnvelopeInfo.worker = async (args) => {
// Data for this method
// args.basePath
// args.accessToken
// args.accountId
// args.envelopeId


let dsApiClient = new docusign.ApiClient();
dsApiClient.setBasePath(args.basePath);
dsApiClient.addDefaultHeader('Authorization', 'Bearer ' + args.accessToken);
Expand Down
11 changes: 7 additions & 4 deletions lib/examples/eg005EnvelopeRecipients.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,16 @@ eg005EnvelopeRecipients.createController = async (req, res) => {

/**
* This function does the work of listing the envelope's recipients
* @param {object} args An object with the following elements: <br/>
* <tt>dsAPIclient</tt>: The DocuSign API Client object, already set with an access token and base url <br/>
* <tt>accountId</tt>: Current account Id <br/>
* <tt>envelopeId</tt>: envelope Id <br/>
* @param {object} args object
*/
// ***DS.worker.start ***DS.snippet.1.start
eg005EnvelopeRecipients.worker = async (args) => {
// Data for this method
// args.basePath
// args.accessToken
// args.accountId
// args.envelopeId

let dsApiClient = new docusign.ApiClient();
dsApiClient.setBasePath(args.basePath);
dsApiClient.addDefaultHeader('Authorization', 'Bearer ' + args.accessToken);
Expand Down
12 changes: 8 additions & 4 deletions lib/examples/eg006EnvelopeDocs.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,17 @@ eg006EnvelopeDocs.createController = async (req, res) => {

/**
* This function does the work of listing the envelope's documents
* @param {object} args An object with the following elements: <br/>
* <tt>dsAPIclient</tt>: The DocuSign API Client object, already set with an access token and base url <br/>
* <tt>accountId</tt>: Current account Id <br/>
* <tt>envelopeId</tt>: envelope Id <br/>
* @param {object} args object
*/
// ***DS.worker.start ***DS.snippet.1.start
eg006EnvelopeDocs.worker = async (args) => {
// Data for this method
// args.basePath
// args.accessToken
// args.accountId
// args.envelopeId


let dsApiClient = new docusign.ApiClient();
dsApiClient.setBasePath(args.basePath);
dsApiClient.addDefaultHeader('Authorization', 'Bearer ' + args.accessToken);
Expand Down
10 changes: 9 additions & 1 deletion lib/examples/eg007EnvelopeGetDoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,22 @@ eg007EnvelopeGetDoc.createController = async (req, res) => {

/**
* This function does the work of listing the envelope's recipients
* @param {object} args An object with the following elements: <br/>
* @param {object} args object with the following elements: <br/>
* <tt>dsAPIclient</tt>: The DocuSign API Client object, already set with an access token and base url <br/>
* <tt>accountId</tt>: Current account Id <br/>
* <tt>documentId</tt>: the document to be fetched <br/>
* <tt>envelopeDocuments</tt>: object with data about the envelope's documents
*/
// ***DS.worker.start ***DS.snippet.1.start
eg007EnvelopeGetDoc.worker = async (args) => {
// Data for this method
// args.basePath
// args.accessToken
// args.accountId
// args.documentId
// args.envelopeDocuments.envelopeId
// args.envelopeDocuments.documents -- array of {documentId, name, type}

let dsApiClient = new docusign.ApiClient();
dsApiClient.setBasePath(args.basePath);
dsApiClient.addDefaultHeader('Authorization', 'Bearer ' + args.accessToken);
Expand Down
23 changes: 16 additions & 7 deletions lib/examples/eg008CreateTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,20 @@ eg008CreateTemplate.createController = async (req, res) => {

/**
* This function does the work of checking to see if the template exists and creating it if not.
* @param {object} args An object with the following elements: <br/>
* <tt>dsAPIclient</tt>: The DocuSign API Client object, already set with an access token and base url <br/>
* <tt>accountId</tt>: Current account Id <br/>
* <tt>templateName</tt>: The template's name <br/>
* @param {object} args object
*/
// ***DS.worker.start ***DS.snippet.1.start
eg008CreateTemplate.worker = async (args) => {
let dsApiClient = new docusign.ApiClient();
dsApiClient.setBasePath(args.basePath);
dsApiClient.addDefaultHeader('Authorization', 'Bearer ' + args.accessToken);
// Data for this method
// args.basePath
// args.accessToken
// args.accountId
// args.templateName


let dsApiClient = new docusign.ApiClient();
dsApiClient.setBasePath(args.basePath);
dsApiClient.addDefaultHeader('Authorization', 'Bearer ' + args.accessToken);
let templatesApi = new docusign.TemplatesApi(dsApiClient)
, results = null
, templateId = null // the template that exists or will be created.
Expand Down Expand Up @@ -131,6 +135,11 @@ eg008CreateTemplate.createController = async (req, res) => {
* @private
*/
function makeTemplate(){
// Data for this method
// demoDocsPath -- module global
// docFile -- module global
// templateName -- module global

// document 1 (pdf) has tag /sn1/
//
// The template has two recipient roles.
Expand Down
25 changes: 16 additions & 9 deletions lib/examples/eg009UseTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,16 @@ eg009UseTemplate.createController = async (req, res) => {

/**
* This function does the work of creating the envelope
* @param {object} args An object with the following elements: <br/>
* <tt>dsAPIclient</tt>: The DocuSign API Client object, already set with an access token and base url <br/>
* <tt>accountId</tt>: Current account Id <br/>
* <tt>envelopeArgs</tt>: envelopeArgs, an object with elements
* <tt>templateId</tt>, <tt>signerEmail</tt>, <tt>signerName</tt>,
* <tt>ccEmail</tt>, <tt>ccName</tt>
* @param {object} args object
*/
// ***DS.worker.start ***DS.snippet.1.start
eg009UseTemplate.worker = async (args) => {
// Data for this method
// args.basePath
// args.accessToken
// args.accountId


let dsApiClient = new docusign.ApiClient();
dsApiClient.setBasePath(args.basePath);
dsApiClient.addDefaultHeader('Authorization', 'Bearer ' + args.accessToken);
Expand All @@ -128,13 +129,19 @@ eg009UseTemplate.worker = async (args) => {
/**
* Creates envelope from the template
* @function
* @param {Object} args parameters for the envelope:
* <tt>signerEmail</tt>, <tt>signerName</tt>, <tt>ccEmail</tt>, <tt>ccName</tt>,
* <tt>templateId</tt>
* @param {Object} args object
* @returns {Envelope} An envelope definition
* @private
*/
function makeEnvelope(args){
// Data for this method
// args.signerEmail
// args.signerName
// args.ccEmail
// args.ccName
// args.templateId


// The envelope has two recipients.
// recipient 1 - signer
// recipient 2 - cc
Expand Down
37 changes: 23 additions & 14 deletions lib/examples/eg010SendBinaryDocs.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,18 @@ eg010SendBinaryDocs.createController = async (req, res) => {
/**
* This function does the work of creating the envelope by using
* the API directly with multipart mime
* @param {object} args An object with the following elements: <br/>
* <tt>accountId</tt>: Current account Id <br/>
* <tt> basePath</tt>: base path for making API call <br/>
* <tt> accessToken</tt>: a valid access token <br/>
* <tt>demoDocsPath</tt>: relative path for the demo docs <br/>
* <tt>doc2File: file name for doc 2 <br/>
* <tt>doc3File: file name for doc 3 <br/>
* <tt>envelopeArgs</tt>: envelopeArgs, an object with elements <br/>
* <tt>signerEmail</tt>, <tt>signerName</tt>, <tt>ccEmail</tt>, <tt>ccName</tt>
* @param {object} args object
*/
// ***DS.worker.start ***DS.snippet.1.start
eg010SendBinaryDocs.worker = async (args) => {
// Data for this method
// args.basePath
// args.accessToken
// args.accountId
// demoDocsPath: relative path for the demo docs
// doc2File: file name for doc 2
// doc3File: file name for doc 3


// Step 1. Make the envelope JSON request body
let envelopeJSON = makeEnvelopeJSON( args.envelopeArgs )
Expand Down Expand Up @@ -195,12 +195,17 @@ eg010SendBinaryDocs.worker = async (args) => {
* <br>DocuSign will convert all of the documents to the PDF format.
* <br>The recipients' field tags are placed using <b>anchor</b> strings.
* @function
* @param {Object} args parameters for the envelope:
* <tt>signerEmail</tt>, <tt>signerName</tt>, <tt>ccEmail</tt>, <tt>ccName</tt>
* @param {Object} args object
* @returns {Envelope} An envelope definition
* @private
*/
function makeEnvelopeJSON(args){
// Data for this method
// args.signerEmail
// args.signerName
// args.ccEmail
// args.ccName

// document 1 (html) has tag **signature_1**
// document 2 (docx) has tag /sn1/
// document 3 (pdf) has tag /sn1/
Expand Down Expand Up @@ -291,12 +296,16 @@ function makeEnvelopeJSON(args){
* Creates document 1
* @function
* @private
* @param {Object} args parameters for the envelope:
* <tt>signerEmail</tt>, <tt>signerName</tt>, <tt>ccEmail</tt>, <tt>ccName</tt>
* @param {Object} args object
* @returns {string} A document in HTML format
*/

function document1(args) {
// Data for this method
// args.signerEmail
// args.signerName
// args.ccEmail
// args.ccName

return `
<!DOCTYPE html>
<html>
Expand Down
22 changes: 10 additions & 12 deletions lib/examples/eg011EmbeddedSending.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,16 @@ eg011EmbeddedSending.createController = async (req, res) => {
/**
* This function does the work of creating the envelope in
* draft mode and returning a URL for the sender's view
* @param {object} args An object with the following elements: <br/>
* <tt>dsAPIclient</tt>: The DocuSign API Client object, already set with an access token and base url <br/>
* <tt>accountId</tt>: Current account Id <br/>
* <tt>senderView</tt>: tagging or recipient
* <tt>envelopeArgs</tt>: envelopeArgs, an object with elements
* <tt>signerEmail</tt>, <tt>signerName</tt>, <tt>ccEmail</tt>, <tt>ccName</tt>
* @param {object} args object
*/
// ***DS.worker.start ***DS.snippet.1.start
eg011EmbeddedSending.worker = async (args) => {
// Data for this method
// args.basePath
// args.accessToken
// args.accountId
// args.startingView -- 'recipient' or 'tagging'

let dsApiClient = new docusign.ApiClient();
dsApiClient.setBasePath(args.basePath);
dsApiClient.addDefaultHeader('Authorization', 'Bearer ' + args.accessToken);
Expand Down Expand Up @@ -134,15 +135,12 @@ eg011EmbeddedSending.worker = async (args) => {
// ***DS.snippet.3.start
function makeSenderViewRequest(args) {
let viewRequest = new docusign.ReturnUrlRequest();
// Data for this method
// args.dsReturnUrl

// Set the url where you want the recipient to go once they are done signing
// should typically be a callback route somewhere in your app.
// The query parameter is included as an example of how
// to save/recover state information during the redirect to
// the DocuSign signing ceremony. It's usually better to use
// the session mechanism of your web framework. Query parameters
// can be changed/spoofed very easily.
viewRequest.returnUrl = args.dsReturnUrl + "?state=123";
viewRequest.returnUrl = args.dsReturnUrl;
return viewRequest
}
// ***DS.snippet.3.end
Expand Down
Loading

0 comments on commit 9237c6e

Please sign in to comment.