1 | |
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 |
|