-
Notifications
You must be signed in to change notification settings - Fork 22
/
cancel-documentgroup-invite.js
44 lines (37 loc) · 1.13 KB
/
cancel-documentgroup-invite.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env node
/**
* to run cancel-documentgroup-invite applet from the project root folder type in your console:
* > node bin/cancel-documentgroup-invite <client_id> <client_secret> <username> <password> <documentgroup_id> <invite_id>
* <client_id>, <client_secret>, <username>, <password>, <documentgroup_id>, <invite_id> - are required params
*/
'use strict';
const [
clientId,
clientSecret,
username,
password,
documentGroupId,
inviteId,
] = process.argv.slice(2);
const { promisify } = require('../utils');
const api = require('../lib')({
credentials: Buffer.from(`${clientId}:${clientSecret}`).toString('base64'),
production: false,
});
const {
oauth2: { requestToken: getAccessToken },
documentGroup: { cancelInvite: cancelDocumentGroupInvite },
} = api;
const getAccessToken$ = promisify(getAccessToken);
const cancelDocumentGroupInvite$ = promisify(cancelDocumentGroupInvite);
getAccessToken$({
username,
password,
})
.then(({ access_token: token }) => cancelDocumentGroupInvite$({
id: documentGroupId,
inviteId,
token,
}))
.then(res => console.log(res))
.catch(err => console.error(err));