1 | |
2 | type Zoho = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Delink record |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Zoho, |
11 | module_api_name: string, |
12 | record_id: string, |
13 | related_list_api_name: string, |
14 | related_record_id: string, |
15 | X_EXTERNAL?: string, |
16 | ) { |
17 | const url = new URL( |
18 | `https://zohoapis.com/crm/v8/${module_api_name}/${record_id}/${related_list_api_name}/${related_record_id}`, |
19 | ); |
20 |
|
21 | const response = await fetch(url, { |
22 | method: "DELETE", |
23 | headers: { |
24 | ...(X_EXTERNAL ? { "X-EXTERNAL": X_EXTERNAL } : {}), |
25 | Authorization: "Zoho-oauthtoken " + auth.token, |
26 | }, |
27 | body: undefined, |
28 | }); |
29 | if (!response.ok) { |
30 | const text = await response.text(); |
31 | throw new Error(`${response.status} ${text}`); |
32 | } |
33 | return await response.json(); |
34 | } |
35 |
|