1 | |
2 | type Zoho = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Delete custom layout |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Zoho, |
11 | id: string, |
12 | _module: string, |
13 | transfer_to: string, |
14 | ) { |
15 | const url = new URL(`https://zohoapis.com/crm/v8/settings/layouts/${id}`); |
16 | for (const [k, v] of [ |
17 | ["module", _module], |
18 | ["transfer_to", transfer_to], |
19 | ]) { |
20 | if (v !== undefined && v !== "" && k !== undefined) { |
21 | url.searchParams.append(k, v); |
22 | } |
23 | } |
24 | const response = await fetch(url, { |
25 | method: "DELETE", |
26 | headers: { |
27 | Authorization: "Zoho-oauthtoken " + auth.token, |
28 | }, |
29 | body: undefined, |
30 | }); |
31 | if (!response.ok) { |
32 | const text = await response.text(); |
33 | throw new Error(`${response.status} ${text}`); |
34 | } |
35 | return await response.json(); |
36 | } |
37 |
|