1 | |
2 | type Zoho = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Create audit log export |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Zoho, |
11 | body: { |
12 | audit_log_export: { |
13 | criteria: { |
14 | field: { api_name: string }; |
15 | comparator: string; |
16 | value: {}; |
17 | group_operator: string; |
18 | group: {}[]; |
19 | }; |
20 | id?: string; |
21 | status?: string; |
22 | created_by?: { name?: string; id: string }; |
23 | download_links?: string[]; |
24 | job_start_time?: string; |
25 | job_end_time?: string; |
26 | expiry_date?: string; |
27 | }[]; |
28 | }, |
29 | ) { |
30 | const url = new URL(`https://zohoapis.com/crm/v8/settings/audit_log_export`); |
31 |
|
32 | const response = await fetch(url, { |
33 | method: "POST", |
34 | headers: { |
35 | "Content-Type": "application/json", |
36 | Authorization: "Zoho-oauthtoken " + auth.token, |
37 | }, |
38 | body: JSON.stringify(body), |
39 | }); |
40 | if (!response.ok) { |
41 | const text = await response.text(); |
42 | throw new Error(`${response.status} ${text}`); |
43 | } |
44 | return await response.json(); |
45 | } |
46 |
|