Pushing up changes to main before I branch

This commit is contained in:
2023-11-11 12:29:37 -05:00
parent febbd1fa8e
commit e68272236f
8 changed files with 98 additions and 27 deletions

View File

@@ -31,18 +31,26 @@ async function doesCalendarExist(calendarName) {
return null;
}
// TODO This needs to be changed so that it uses the common callback
// format that I've created
async function getListOfCalendars(options, callback) {
const calendarReference = await getCalendarReference();
calendarReference.calendarList.list(options, callback);
calendarReference.calendarList.list(options, async (err, res) => {
if (err) {
callback(false, 'Failed to retrieve the list of calendars\nAsk Bradley to check Breadbot console');
stdout.write('[ERROR]:');
console.log(err.errors);
return;
}
callback(true, 'Calendar List', res.data.items);
});
}
async function addCalendar(calendarName, callback) {
async function addCalendar(calendarName, timezone, callback) {
const calendarReference = await getCalendarReference();
calendarReference.calendars.insert({
resource: {
summary: calendarName,
timeZone: timezone,
},
},
// eslint-disable-next-line no-unused-vars
@@ -83,6 +91,28 @@ async function deleteCalendar(calendarName, callback) {
}
}
async function addEvent(calendarName, eventName, location, description, startDate, startTime, endDate, endTime) {
const exists = await doesCalendarExist(calendarName);
if (exists) {
const calendarReference = await getCalendarReference();
calendarReference.events.insert({
calendarId: exists.id,
resource: {
summary: eventName,
location: location,
description: description,
start: {
}
},
})
}
else {
callback(false, 'The calendar name specified doesn\'t exist', null);
}
}
module.exports = {
getCalendarReference,
getListOfCalendars,