1 | |
2 | type Zoho = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Delete pipeline |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Zoho, |
11 | id: string, |
12 | layout_id: string, |
13 | body: { pipeline: { _delete: { permanent: false | true } }[] }, |
14 | ) { |
15 | const url = new URL(`https://zohoapis.com/crm/v8/settings/pipeline/${id}`); |
16 | for (const [k, v] of [["layout_id", layout_id]]) { |
17 | if (v !== undefined && v !== "" && k !== undefined) { |
18 | url.searchParams.append(k, v); |
19 | } |
20 | } |
21 | const response = await fetch(url, { |
22 | method: "PATCH", |
23 | headers: { |
24 | "Content-Type": "application/json", |
25 | Authorization: "Zoho-oauthtoken " + auth.token, |
26 | }, |
27 | body: JSON.stringify(body), |
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 |
|