1 | |
2 | type Zoho = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Get unassigned groups |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Zoho, |
11 | body: { |
12 | get_unassigned: { |
13 | feature: "user_groups"; |
14 | related_entity_id: string; |
15 | page?: number; |
16 | per_page?: number; |
17 | id?: string; |
18 | filters?: { |
19 | comparator: string; |
20 | field: { api_name: string; id: string }; |
21 | group_operator: "OR" | "AND"; |
22 | group: {}[]; |
23 | value: {}; |
24 | }; |
25 | }; |
26 | }, |
27 | ) { |
28 | const url = new URL( |
29 | `https://zohoapis.com/crm/v8/settings/user_groups/actions/get_unassigned`, |
30 | ); |
31 |
|
32 | const response = await fetch(url, { |
33 | method: "POST", |
34 | headers: { |
35 | "Content-Type": "application/json", |
36 | Authorization: "Zoho-oauthtoken " + auth.token, |
37 | }, |
38 | body: JSON.stringify(body), |
39 | }); |
40 | if (!response.ok) { |
41 | const text = await response.text(); |
42 | throw new Error(`${response.status} ${text}`); |
43 | } |
44 | return await response.json(); |
45 | } |
46 |
|