1 | |
2 | type Zoho = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Sign mail merge |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Zoho, |
11 | id: string, |
12 | _module: string, |
13 | body: { |
14 | sign_mail_merge?: { |
15 | mail_merge_template?: { id?: string; name?: string }; |
16 | sign_in_order?: false | true; |
17 | file_name?: string; |
18 | signers?: { |
19 | recipient_name?: string; |
20 | action_type?: "approve" | "sign"; |
21 | recipient?: { type?: string; value?: string }; |
22 | }[]; |
23 | }[]; |
24 | }, |
25 | ) { |
26 | const url = new URL( |
27 | `https://zohoapis.com/crm/v8/${_module}/${id}/actions/sign_mail_merge`, |
28 | ); |
29 |
|
30 | const response = await fetch(url, { |
31 | method: "POST", |
32 | headers: { |
33 | "Content-Type": "application/json", |
34 | Authorization: "Zoho-oauthtoken " + auth.token, |
35 | }, |
36 | body: JSON.stringify(body), |
37 | }); |
38 | if (!response.ok) { |
39 | const text = await response.text(); |
40 | throw new Error(`${response.status} ${text}`); |
41 | } |
42 | return await response.json(); |
43 | } |
44 |
|