diff --git a/components/envelopes.js b/components/envelopes.js index 1e5ee20fd..100f13512 100644 --- a/components/envelopes.js +++ b/components/envelopes.js @@ -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); } }; }; @@ -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); } diff --git a/jsconfig.json b/jsconfig.json new file mode 100644 index 000000000..0438b79f6 --- /dev/null +++ b/jsconfig.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "target": "ES6", + "module": "commonjs" + } +} \ No newline at end of file diff --git a/test/component-tests/envelopes.spec.js b/test/component-tests/envelopes.spec.js index e633e8c5b..3e4e2000c 100644 --- a/test/component-tests/envelopes.spec.js +++ b/test/component-tests/envelopes.spec.js @@ -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: [{ @@ -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;