1 | |
2 | type Zoho = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Get map dependencies |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Zoho, |
11 | layout_id: string, |
12 | _module: string | undefined, |
13 | page: string | undefined, |
14 | per_page: string | undefined, |
15 | filters: string | undefined, |
16 | ) { |
17 | const url = new URL( |
18 | `https://zohoapis.com/crm/v8/settings/layouts/${layout_id}/map_dependency`, |
19 | ); |
20 | for (const [k, v] of [ |
21 | ["module", _module], |
22 | ["page", page], |
23 | ["per_page", per_page], |
24 | ["filters", filters], |
25 | ]) { |
26 | if (v !== undefined && v !== "" && k !== undefined) { |
27 | url.searchParams.append(k, v); |
28 | } |
29 | } |
30 | const response = await fetch(url, { |
31 | method: "GET", |
32 | headers: { |
33 | Authorization: "Zoho-oauthtoken " + auth.token, |
34 | }, |
35 | body: undefined, |
36 | }); |
37 | if (!response.ok) { |
38 | const text = await response.text(); |
39 | throw new Error(`${response.status} ${text}`); |
40 | } |
41 | return await response.json(); |
42 | } |
43 |
|