1 | |
2 | type Zoho = { |
3 | token: string; |
4 | baseUrl: string; |
5 | }; |
6 | |
7 | * Publish API Get Record Detail View |
8 | * This API fetches the data displayed in the detail view of a record, which is identified by the ID value passed. This API will not fetch the records displayed in the related data blocks of the detail view. |
9 | */ |
10 | export async function main( |
11 | auth: Zoho, |
12 | account_owner_name: string, |
13 | app_link_name: string, |
14 | report_link_name: string, |
15 | record_ID: string, |
16 | privatelink: string | undefined, |
17 | field_config: string | undefined, |
18 | fields: string | undefined, |
19 | ) { |
20 | const url = new URL( |
21 | `${auth.baseUrl}/creator/v2.1/publish/${account_owner_name}/${app_link_name}/report/${report_link_name}/${record_ID}`, |
22 | ); |
23 | for (const [k, v] of [ |
24 | ["privatelink", privatelink], |
25 | ["field_config", field_config], |
26 | ["fields", fields], |
27 | ]) { |
28 | if (v !== undefined && v !== "" && k !== undefined) { |
29 | url.searchParams.append(k, v); |
30 | } |
31 | } |
32 | const response = await fetch(url, { |
33 | method: "GET", |
34 | headers: { |
35 | Authorization: "Zoho-oauthtoken " + auth.token, |
36 | }, |
37 | body: undefined, |
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 |
|