Skip to content

Commit

Permalink
Merge pull request #36 from docusign/recipienttabs
Browse files Browse the repository at this point in the history
Added the ability to get recipient tabs as an optional parameter
  • Loading branch information
Whoaa512 committed Oct 28, 2015
2 parents e686289 + d75ff66 commit fdd6896
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
19 changes: 14 additions & 5 deletions components/envelopes.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,19 @@ exports.init = function (accountId, baseUrl, accessToken) {
* @public
* @function
* @param {string} envelopeId - ID of envelope to get list of recipients from.
* @param {boolean} [include_tabs] - When true the tab information associated with the recipient is included in the response.
* @param {function} [callback] - Returns the list of recipients in the form of function(error, response).
* @returns {Promise} - A thenable bluebird Promise; if callback is given it is called before the promise is resolved
*/
getRecipients: function (envelopeId, callback) {
return getRecipients(accessToken, baseUrl, envelopeId).asCallback(callback);
getRecipients: function (envelopeId, include_tabs, callback) {
// handle the case where people omit the tabs
if (arguments.length === 2 && Object.prototype.toString.call(include_tabs) === '[object Function]') {
callback = include_tabs;
include_tabs = false;
} else if (arguments.length === 1) {
include_tabs = false;
}
return getRecipients(accessToken, baseUrl, envelopeId, include_tabs).asCallback(callback);
}
};
};
Expand Down Expand Up @@ -847,14 +855,15 @@ function getTemplateView (apiToken, baseUrl, templateId, returnUrl) {
* @param {string} apiToken - DocuSign API OAuth2 access token.
* @param {string} baseUrl - DocuSign API base URL.
* @param {string} envelopeId - ID of envelope to get list of recipients from.
* @param {boolean} [include_tabs] - When true the tab information associated with the recipient is included in the response.
* @returns {Promise} - A thenable bluebird Promise fulfilled with the list of recipients
*/
function getRecipients (apiToken, baseUrl, envelopeId) {
function getRecipients (apiToken, baseUrl, envelopeId, include_tabs) {
include_tabs = include_tabs != null ? include_tabs : false;
var options = {
method: 'GET',
url: baseUrl + '/envelopes/' + envelopeId + '/recipients',
url: baseUrl + '/envelopes/' + envelopeId + '/recipients?include_tabs=' + include_tabs,
headers: dsUtils.getHeaders(apiToken)
};

return dsUtils.makeRequest('Get List of Recipients', options);
}
6 changes: 6 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs"
}
}
18 changes: 18 additions & 0 deletions test/component-tests/envelopes.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ let roleName = config.templateRole;
let clientUserId = '1001';
let returnUrl = 'http://www.docusign.com/devcenter';
let emailSubject = 'DocuSign API - Signature Request on Document Call';
let include_tabs = true;
let additionalParams = {};
let recipients = {
signers: [{
Expand Down Expand Up @@ -134,6 +135,23 @@ test(function getRecipients (t) {
});
});

test(function getRecipientsWithTabs (t) {
return client.envelopes.getRecipients(envelopeId, include_tabs)
.then(response => {
t.ok(response.signers);
t.ok(response.signers[0].isBulkRecipient);
t.ok(response.signers[0].name);
t.ok(response.signers[0].email);
t.ok(response.signers[0].recipientId);
t.ok(response.signers[0].recipientIdGuid);
t.ok(response.signers[0].requireIdLookup);
t.ok(response.signers[0].userId);
t.ok(response.signers[0].tabs);
t.ok(response.signers[0].tabs.signHereTabs);
t.ok(response.signers[0].tabs.signHereTabs.length === 1);
});
});

test(function getView (t) {
let action = 'send';
let event = null;
Expand Down

0 comments on commit fdd6896

Please sign in to comment.