1 | |
2 | type Zoho = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Update role |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Zoho, |
11 | role_id: string, |
12 | body: { |
13 | roles: { |
14 | display_label: string; |
15 | forecast_manager: { id: string; name: string }; |
16 | reporting_to: { id: string; name: string }; |
17 | share_with_peers: false | true; |
18 | description: string; |
19 | id: string; |
20 | name: string; |
21 | created_by__s: { name: string; id: string; email?: string }; |
22 | modified_by__s: { name: string; id: string; email?: string }; |
23 | modified_time__s: string; |
24 | created_time__s: string; |
25 | admin_user?: false | true; |
26 | }[]; |
27 | }, |
28 | ) { |
29 | const url = new URL(`https://zohoapis.com/crm/v8/settings/roles/${role_id}`); |
30 |
|
31 | const response = await fetch(url, { |
32 | method: "PUT", |
33 | headers: { |
34 | "Content-Type": "application/json", |
35 | Authorization: "Zoho-oauthtoken " + auth.token, |
36 | }, |
37 | body: JSON.stringify(body), |
38 | }); |
39 | if (!response.ok) { |
40 | const text = await response.text(); |
41 | throw new Error(`${response.status} ${text}`); |
42 | } |
43 | return await response.json(); |
44 | } |
45 |
|