0

Update holiday

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
 * Update holiday
7
 *
8
 */
9
export async function main(
10
  auth: Zoho,
11
  holiday_id: string,
12
  body: {
13
    holidays?: {
14
      year: number;
15
      name: string;
16
      date: string;
17
      type: string;
18
      id: string;
19
      shift_hour: { name: string; id: string };
20
    }[];
21
  },
22
  X_CRM_ORG?: string,
23
) {
24
  const url = new URL(
25
    `https://zohoapis.com/crm/v8/settings/holidays/${holiday_id}`,
26
  );
27

28
  const response = await fetch(url, {
29
    method: "PUT",
30
    headers: {
31
      ...(X_CRM_ORG ? { "X-CRM-ORG": X_CRM_ORG } : {}),
32
      "Content-Type": "application/json",
33
      Authorization: "Zoho-oauthtoken " + auth.token,
34
    },
35
    body: JSON.stringify(body),
36
  });
37
  if (!response.ok) {
38
    const text = await response.text();
39
    throw new Error(`${response.status} ${text}`);
40
  }
41
  return await response.json();
42
}
43