Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Commit

Permalink
Update Code.js to account for changes from Calendar API
Browse files Browse the repository at this point in the history
Worked with the Calendar API team to update this code sample.
  • Loading branch information
danielatgoogle authored Dec 6, 2023
1 parent 271015e commit f09cce6
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions vacation-calendar/src/Code.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,32 @@ function sync() {
* calendar.
* @param {string} username The team member that is attending the event.
* @param {Calendar.Event} event The event to import.
* @return {boolean} True if the event was imported.
*/
function importEvent(username, event) {
event.summary = '[' + username + '] ' + event.summary;
event.organizer = {
id: TEAM_CALENDAR_ID,
};
event.attendees = [];

// If the event is not of type 'default', it can't be imported, so it needs
// to be changed.
if (event.eventType != 'default') {
event.eventType = 'default';
delete event.outOfOfficeProperties;
delete event.focusTimeProperties;
}

console.log('Importing: %s', event.summary);
try {
Calendar.Events.import(event, TEAM_CALENDAR_ID);
return true;
} catch (e) {
console.error('Error attempting to import event: %s. Skipping.',
e.toString());
return false;
}
}


/**
* In a given user's calendar, look for occurrences of the given keyword
* in events within the specified date range and return any such events
Expand Down

0 comments on commit f09cce6

Please sign in to comment.