0

Get zia people enrichments

by
Published Oct 17, 2025
Script zoho Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zoho = {
3
  token: string;
4
};
5
/**
6
 * Get zia people enrichments
7
 *
8
 */
9
export async function main(
10
  auth: Zoho,
11
  status: "COMPLETED" | "FAILED" | "DATA_NOT_FOUND" | "SCHEDULED" | undefined,
12
  sort_order: string | undefined,
13
  sort_by: string | undefined,
14
  page: string | undefined,
15
  per_page: string | undefined,
16
  count: string | undefined,
17
) {
18
  const url = new URL(`https://zohoapis.com/crm/v8/__zia_people_enrichment`);
19
  for (const [k, v] of [
20
    ["status", status],
21
    ["sort_order", sort_order],
22
    ["sort_by", sort_by],
23
    ["page", page],
24
    ["per_page", per_page],
25
    ["count", count],
26
  ]) {
27
    if (v !== undefined && v !== "" && k !== undefined) {
28
      url.searchParams.append(k, v);
29
    }
30
  }
31
  const response = await fetch(url, {
32
    method: "GET",
33
    headers: {
34
      Authorization: "Zoho-oauthtoken " + auth.token,
35
    },
36
    body: undefined,
37
  });
38
  if (!response.ok) {
39
    const text = await response.text();
40
    throw new Error(`${response.status} ${text}`);
41
  }
42
  return await response.json();
43
}
44