1

Update Event

by
Published Jul 26, 2022
Script gcal Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 6 days ago
1
//native
2

3
type Gcal = {
4
  token: string;
5
};
6
export async function main(
7
  gcal_auth: Gcal,
8
  calendarId: string,
9
  eventId: string,
10
  start_date?: string,
11
  end_date?: string,
12
  description?: string,
13
  summary: string,
14
  location?: string,
15
  attendees?: Array<object>,
16
) {
17
  const alwaysIncludeEmail = true;
18
  const sendUpdates = "all";
19
  const supportsAttachments = true;
20
  const UPDATE_EVENT_URL = `https://www.googleapis.com/calendar/v3/calendars/${calendarId}/events/${eventId}/?alwaysIncludeEmail=${alwaysIncludeEmail}&sendUpdates=${sendUpdates}&supportsAttachments=${supportsAttachments}`;
21

22
  const token = gcal_auth["token"];
23

24
  const body = {
25
    summary: summary,
26
    description: description,
27
    location: location,
28
    end: {
29
      date: end_date,
30
    },
31
    start: {
32
      date: start_date,
33
    },
34
    attendees: attendees,
35
  };
36

37
  const response = await fetch(UPDATE_EVENT_URL, {
38
    method: "PUT",
39
    body: JSON.stringify(body),
40
    headers: {
41
      Authorization: "Bearer " + token,
42
      "Content-Type": "application/json",
43
    },
44
  });
45

46
  const result = await response.json();
47

48
  return result;
49
}
50

Other submissions
  • Submitted by rossmccrann Deno
    Created 398 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
      start_date?: string,
    9
      end_date?: string,
    10
      description?: string,
    11
      summary: string,
    12
      location?: string,
    13
      attendees?: Array<object>,
    14
    ) {
    15
      const alwaysIncludeEmail = true;
    16
      const sendUpdates = "all";
    17
      const supportsAttachments = true;
    18
      const UPDATE_EVENT_URL = `https://www.googleapis.com/calendar/v3/calendars/${calendarId}/events/${eventId}/?alwaysIncludeEmail=${alwaysIncludeEmail}&sendUpdates=${sendUpdates}&supportsAttachments=${supportsAttachments}`;
    19
    
    
    20
      const token = gcal_auth["token"];
    21
    
    
    22
      const body = {
    23
        summary: summary,
    24
        description: description,
    25
        location: location,
    26
        end: {
    27
          date: end_date,
    28
        },
    29
        start: {
    30
          date: start_date,
    31
        },
    32
        attendees: attendees,
    33
      };
    34
    
    
    35
      const response = await fetch(UPDATE_EVENT_URL, {
    36
        method: "PUT",
    37
        body: JSON.stringify(body),
    38
        headers: {
    39
          Authorization: "Bearer " + token,
    40
          "Content-Type": "application/json",
    41
        },
    42
      });
    43
    
    
    44
      const result = await response.json();
    45
    
    
    46
      return result;
    47
    }
    48