Skip to content

Commit 49ecef0

Browse files
author
Ruslan Tereshchenko
committed
implement template invite method
1 parent c8392d3 commit 49ecef0

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

lib/template.js

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ const https = require('https');
33
const {
44
responseHandler, errorHandler, buildRequestOptions,
55
} = require('./common');
6-
const { remove: removeDocument } = require('./document');
6+
const {
7+
remove: removeDocument,
8+
invite: sendDocumentInvite,
9+
} = require('./document');
710

811

912
/**
@@ -142,6 +145,39 @@ class Template {
142145
req.end();
143146
}
144147

148+
/**
149+
* Creates an invite to sign a template.
150+
* You can create a simple free form invite(s) or a role-based invite(s).
151+
* The method copies a template into document and creates an invite using created document.
152+
* @param {DocumentInviteParams} data - create document invite payload
153+
* @param {function(err: ApiErrorResponse, res: DocumentInviteResponse)} [callback] - error first node.js callback
154+
*/
155+
static invite ({
156+
id,
157+
data,
158+
options,
159+
token,
160+
}, callback) {
161+
this.duplicate({
162+
id,
163+
token,
164+
}, (err, res) => {
165+
if (err) {
166+
callback(err);
167+
return;
168+
} else {
169+
const { id: documentId } = res;
170+
171+
sendDocumentInvite({
172+
id: documentId,
173+
data,
174+
options,
175+
token,
176+
}, callback);
177+
}
178+
});
179+
}
180+
145181
}
146182

147183
module.exports = Template;

0 commit comments

Comments
 (0)