0

Get appointments rescheduled history

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