0

Get users unavailability

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 users unavailability
7
 *
8
 */
9
export async function main(
10
  auth: Zoho,
11
  include_inner_details: string | undefined,
12
  group_ids: string | undefined,
13
  role_ids: string | undefined,
14
  territory_ids: string | undefined,
15
  filters: string | undefined,
16
) {
17
  const url = new URL(
18
    `https://zohoapis.com/crm/v8/settings/users_unavailability`,
19
  );
20
  for (const [k, v] of [
21
    ["include_inner_details", include_inner_details],
22
    ["group_ids", group_ids],
23
    ["role_ids", role_ids],
24
    ["territory_ids", territory_ids],
25
    ["filters", filters],
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