1 | |
2 | type Zoho = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Single update |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Zoho, |
11 | _module: string, |
12 | id: string, |
13 | body: { |
14 | owner?: { id?: string }; |
15 | notify?: false | true; |
16 | related_modules?: { id?: string; api_name?: string }[]; |
17 | }, |
18 | ) { |
19 | const url = new URL( |
20 | `https://zohoapis.com/crm/v8/${_module}/${id}/actions/change_owner`, |
21 | ); |
22 |
|
23 | const response = await fetch(url, { |
24 | method: "POST", |
25 | headers: { |
26 | "Content-Type": "application/json", |
27 | Authorization: "Zoho-oauthtoken " + auth.token, |
28 | }, |
29 | body: JSON.stringify(body), |
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 |
|