-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCode.gs
45 lines (43 loc) · 1.04 KB
/
Code.gs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* HTML functions
*/
function doGet() {
return HtmlService.createHtmlOutputFromFile('index');
}
function parseBooleanFormValue(str) {
if (!str) {
return false;
}
if (typeof str == 'string') {
str = str.trim().toLowerCase();
}
if (str == 'false' || str == '0') {
return false;
}
return !!str;
}
/**
* Lists the calendars shown in the user's calendar list.
* @see https://developers.google.com/calendar/api/v3/reference/calendarList/list
*/
function listCalendars() {
var calendars;
var response = {};
var pageToken;
do {
calendars = Calendar.CalendarList.list({
maxResults: 100,
pageToken: pageToken
});
if (!calendars.items || calendars.items.length === 0) {
Logger.log('No calendars found.');
} else {
for (const calendar of calendars.items) {
response[calendar.id] = calendar.summary;
Logger.log('%s (ID: %s)', calendar.summary, calendar.id);
}
}
pageToken = calendars.nextPageToken;
} while (pageToken);
return response;
}