-
Notifications
You must be signed in to change notification settings - Fork 22
/
getDocumentHistory.js
51 lines (45 loc) · 1.24 KB
/
getDocumentHistory.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
45
46
47
48
49
50
51
'use strict';
const signnow = require('@signnow/api-client')({
credentials: 'BASE64_ENCODED_CLIENT_CREDENTIALS',
production: true, // if false then uses eval server
});
const getDocumentHistory = signnow.document.history;
const id = 'DOCUMENT_ID_GOES_HERE';
const token = 'YOUR_ACCESS_TOKEN';
/**
* @typedef {Object} DocumentEvent
* @property {string} client_app_name
* @property {?string} client_timestamp
* @property {string} created - timestamp of action creation
* @property {string} email - email of actor
* @property {string} event
* @property {string} ip_address
* @property {?string} element_id
* @property {?string} field_id
* @property {?string} json_attributes
* @property {string} [document_id]
* @property {string} [origin]
* @property {string} [unique_id]
* @property {string} [user_agent]
* @property {string} [user_id] - id of actor
* @property {string} [version] - version of signed document (incremented after each signature addition)
*/
/**
* @param {DocumentEvent[]} res
*/
const handleResponse = res => {
console.log(res);
};
const handleError = err => {
console.error(err);
};
getDocumentHistory({
id,
token,
}, (err, res) => {
if (err) {
handleError(err);
} else {
handleResponse(res);
}
});