Skip to content

Commit fddaff4

Browse files
committed
[SN-9374] - added generate embedded link
1 parent 31010d0 commit fddaff4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+10550
-2627
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111

1212
- Implemented *Create embedded signing invites for a document without sending emails.* feature. See gow to apply it in [Documentation](https://github.com/signnow/SignNowNodeSDK/blob/master/lib/embedded/index.js~Embedded.html#static-method-createInvite), [Short example](https://github.com/signnow/SignNowNodeSDK/blob/master/README.md#embedded-create-invites), [Full example](https://github.com/signnow/SignNowNodeSDK/blob/master/samples/snippets/embeddedCreateInvites.js), [CLI applet](https://github.com/signnow/SignNowNodeSDK/blob/master/bin/embedded-create-invites.js).
13+
- Implemented *Creates a link for the embedded invite.* feature. See gow to apply it in [Documentation](https://github.com/signnow/SignNowNodeSDK/blob/master/lib/embedded/index.js~Embedded.html#static-method-generateInviteLink), [Short example](https://github.com/signnow/SignNowNodeSDK/blob/master/README.md#embedded-generate-invite), [Full example](https://github.com/signnow/SignNowNodeSDK/blob/master/samples/snippets/embeddedGenerateInviteLink.js), [CLI applet](https://github.com/signnow/SignNowNodeSDK/blob/master/bin/embedded-generate-link.js).
1314

1415
## [v1.7.0] - 2019-12-24
1516

README.md

+15
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ SignNow Node.js REST API Wrapper
7070
* [Create a Webhook](#create-webhook)
7171
* [Embedded](#embedded)
7272
* [Create embedded signing invites for a document without sending emails](#embedded-create-invites)
73+
* [Creates a link for the embedded invite.](#embedded-generate-invite)
7374
* [Promisify methods](#promisify)
7475
7. [Unit Tests](#unit-tests)
7576
8. [License](#license)
@@ -1006,6 +1007,20 @@ signnow.embedded.createInvite({
10061007
});
10071008
```
10081009

1010+
#### <a name="embedded-generate-invite"></a>Creates a link for the embedded invite.
1011+
1012+
```javascript
1013+
signnow.embedded.generateInviteLink({
1014+
token: 'access token',
1015+
document_id: 'document id',
1016+
field_invite_unique_id: 'field invite unique id',
1017+
link_expiration: 15,
1018+
auth_method: 'password',
1019+
}, (err, res) => {
1020+
// handle error or process response data
1021+
});
1022+
```
1023+
10091024
### <a name="promisify"></a>Promisify methods
10101025

10111026
If you are using node.js version **8.0.0** or higher you can use built in [*promisify*](https://nodejs.org/api/util.html#util_util_promisify_original) utility:

bin/embedded-create-invites.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env node
22

33
/**
4-
* to run remove-template applet from the project root folder type in your console:
5-
* > node bin/remove-template <client_id> <client_secret> <username> <password> <template_id>
6-
* <client_id>, <client_secret>, <username>, <password>, <template_id> - are required params
4+
* to run embedded-create-invites applet from the project root folder type in your console:
5+
* > node bin/embedded-create-invites <client_id> <client_secret> <username> <password> <document_id> <invites_stringified>
6+
* <client_id>, <client_secret>, <username>, <password>, <document_id> <invites_stringified> - are required params
77
* options:
88
* --dev - request will be sent to developer sandbox API
99
*/

bin/embedded-generate-link.js

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* to run embedded-generate-link applet from the project root folder type in your console:
5+
* > node bin/embedded-generate-link <client_id> <client_secret> <username> <password> <document_id> <field_invite_unique_id> <link_expiration> <auth_method>
6+
* <client_id>, <client_secret>, <username>, <password>, <document_id> <field_invite_unique_id> <link_expiration> <auth_method> - are required params
7+
* options:
8+
* --dev - request will be sent to developer sandbox API
9+
*/
10+
11+
'use strict';
12+
13+
const args = process.argv.slice(2);
14+
const flags = args.filter(arg => /^--/.test(arg));
15+
const params = args.filter(arg => !/^--/.test(arg));
16+
17+
const [
18+
clientId,
19+
clientSecret,
20+
username,
21+
password,
22+
documentId,
23+
fieldInviteUniqueId,
24+
linkExpiration,
25+
authMethod,
26+
] = params;
27+
28+
const dev = flags.includes('--dev');
29+
30+
const { promisify } = require('../utils');
31+
const api = require('../lib')({
32+
credentials: Buffer.from(`${clientId}:${clientSecret}`).toString('base64'),
33+
production: !dev,
34+
});
35+
36+
const {
37+
oauth2: { requestToken: getAccessToken },
38+
embedded: { generateInviteLink },
39+
} = api;
40+
41+
const getAccessToken$ = promisify(getAccessToken);
42+
const generateInviteLink$ = promisify(generateInviteLink);
43+
44+
getAccessToken$({
45+
username,
46+
password,
47+
})
48+
.then(({ access_token: token }) => generateInviteLink$({
49+
token,
50+
document_id: documentId,
51+
field_invite_unique_id: fieldInviteUniqueId,
52+
link_expiration: linkExpiration,
53+
auth_method: authMethod,
54+
}))
55+
.then(res => console.log(res))
56+
.catch(err => console.error(err));

0 commit comments

Comments
 (0)