Edits history of script submission #22375 for ' Update Attendees of an Event (gcal)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    type Gcal = {
      token: string;
    };
    export async function main(
      gcal_auth: Gcal,
      calendarId: string,
      eventId: string,
      attendees: Array<object>,
    ) {
      const alwaysIncludeEmail = true;
      const sendUpdates = "all";
      const supportsAttachments = true;
      const UPDATE_EVENT_ATTENDEES_URL = `https://www.googleapis.com/calendar/v3/calendars/${calendarId}/events/${eventId}/?alwaysIncludeEmail=${alwaysIncludeEmail}&sendUpdates=${sendUpdates}&supportsAttachments=${supportsAttachments}`;
    
      const token = gcal_auth["token"];
    
      const body = {
        attendees: attendees,
      };
    
      const response = await fetch(UPDATE_EVENT_ATTENDEES_URL, {
        method: "PUT",
        body: JSON.stringify(body),
        headers: {
          Authorization: "Bearer " + token,
          "Content-Type": "application/json",
        },
      });
    
      const result = await response.json();
    
      return result;
    }
    

    Submitted by hugo989 6 days ago