-
Notifications
You must be signed in to change notification settings - Fork 22
/
updateTemplateRoutingDetails.js
100 lines (92 loc) · 2.54 KB
/
updateTemplateRoutingDetails.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
'use strict';
const signnow = require('@signnow/api-client')({
credentials: 'BASE64_ENCODED_CLIENT_CREDENTIALS',
production: true, // if false then uses eval server
});
const { updateRoutingDetails } = signnow.template;
const id = 'TEMPLATE_ID_GOES_HERE';
const token = 'YOUR_ACCESS_TOKEN';
/**
* Template Update Routing Details item data
* @typedef {Object} TemplateUpdateRoutingDetailsItem
* @property {string} default_email - default email for routing detail
* @property {boolean} inviter_role - always `false`
* @property {string} name - signer role (actor) name
* @property {string} role_id - signer role (actor) unique ID
* @property {number} signing_order - order number of signing step
* @property {boolean} decline_by_signature - decline by signature flag
*/
/**
* Update Template Routing Details payload
* @type {Object}
* @property {TemplateUpdateRoutingDetailsItem[]} template_data - array with routing details
* @property {string[]} cc - CC emails
* @property {Object[]} cc_step - array of CC steps
* @property {string} [invite_link_instructions] - invite signing instructions
*/
const routingDetails = {
template_data: [
{
default_email: '',
inviter_role: false,
name: 'Signer 1',
role_id: 'SIGNER 1 ROLE ID',
signing_order: 1,
decline_by_signature: true,
},
{
default_email: 'signer2@mail.com',
inviter_role: false,
name: 'Signer 2',
role_id: 'SIGNER 2 ROLE ID',
signing_order: 2,
},
],
cc: [
'cc1@mail.com',
'cc2@mail.com',
],
cc_step: [
{
email: 'cc1@mail.com',
step: 1,
name: 'CC 1',
},
{
email: 'cc2@mail.com',
step: 2,
name: 'CC 2',
},
],
invite_link_instructions: 'Invite link signing instruction',
};
/**
* Update Template Routing Details response data
* @typedef {Object} TemplateUpdateRoutingDetailsResponse
* @property {string} id - unique ID of template routing details
* @property {string} document_id - unique ID of Template
* @property {Object[]} data - array with routing details
* @property {string[]} cc - CC emails
* @property {Object[]} cc_step - array of CC steps
* @property {string} invite_link_instructions - invite signing instructions
*/
/**
* @param {TemplateUpdateRoutingDetailsResponse} res
*/
const handleResponse = res => {
console.log(res);
};
const handleError = err => {
console.error(err);
};
updateRoutingDetails({
data: routingDetails,
id,
token,
}, (err, res) => {
if (err) {
handleError(err);
} else {
handleResponse(res);
}
});