0

Get entity scores

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 entity scores
7
 *
8
 */
9
export async function main(
10
  auth: Zoho,
11
  fields: string | undefined,
12
  ids: string | undefined,
13
  sort_by: string | undefined,
14
  sort_order: string | undefined,
15
  page: string | undefined,
16
  per_page: string | undefined,
17
  page_token: string | undefined,
18
  cvid: string | undefined,
19
  If_Modified_Since?: string,
20
) {
21
  const url = new URL(`https://zohoapis.com/crm/v8/Entity_Scores__s`);
22
  for (const [k, v] of [
23
    ["fields", fields],
24
    ["ids", ids],
25
    ["sort_by", sort_by],
26
    ["sort_order", sort_order],
27
    ["page", page],
28
    ["per_page", per_page],
29
    ["page_token", page_token],
30
    ["cvid", cvid],
31
  ]) {
32
    if (v !== undefined && v !== "" && k !== undefined) {
33
      url.searchParams.append(k, v);
34
    }
35
  }
36
  const response = await fetch(url, {
37
    method: "GET",
38
    headers: {
39
      ...(If_Modified_Since ? { "If-Modified-Since": If_Modified_Since } : {}),
40
      Authorization: "Zoho-oauthtoken " + auth.token,
41
    },
42
    body: undefined,
43
  });
44
  if (!response.ok) {
45
    const text = await response.text();
46
    throw new Error(`${response.status} ${text}`);
47
  }
48
  return await response.json();
49
}
50