1
Update Attendees of an Event
One script reply has been approved by the moderators Verified
Created by rossmccrann 851 days ago Viewed 9249 times
0
Submitted by rossmccrann Deno
Verified 851 days ago
1
type Gcal = {
2
  token: string;
3
};
4
export async function main(
5
  gcal_auth: Gcal,
6
  calendarId: string,
7
  eventId: string,
8
  attendees: Array<object>,
9
) {
10
  const alwaysIncludeEmail = true;
11
  const sendUpdates = "all";
12
  const supportsAttachments = true;
13
  const UPDATE_EVENT_ATTENDEES_URL = `https://www.googleapis.com/calendar/v3/calendars/${calendarId}/events/${eventId}/?alwaysIncludeEmail=${alwaysIncludeEmail}&sendUpdates=${sendUpdates}&supportsAttachments=${supportsAttachments}`;
14

15
  const token = gcal_auth["token"];
16

17
  const body = {
18
    attendees: attendees,
19
  };
20

21
  const response = await fetch(UPDATE_EVENT_ATTENDEES_URL, {
22
    method: "PUT",
23
    body: JSON.stringify(body),
24
    headers: {
25
      Authorization: "Bearer " + token,
26
      "Content-Type": "application/json",
27
    },
28
  });
29

30
  const result = await response.json();
31

32
  return result;
33
}
34