Skip to main content

gcal.googlecalendar.updateevent

Home > @runlightyear/gcal > GoogleCalendar > updateEvent

GoogleCalendar.updateEvent() method

This API is in beta and may contain contain bugs. Can be used in production with caution.

Updates an event. This method does not support patch semantics and always updates the entire event resource. To do a partial update, perform a get followed by an update using etags to ensure atomicity.

Signature:
updateEvent(props: UpdateEventProps): Promise<UpdateEventResponse>;

Parameters

ParameterTypeDescription
propsUpdateEventProps
Returns:

Promise<UpdateEventResponse>

Example

Update event

import { defineAction } from "@runlightyear/lightyear";
import { GoogleCalendar } from "@runlightyear/gcal";

function addHours(date: Date, hours: number) {
return new Date(date.getTime() + hours * 60 * 60 * 1000);
}

defineAction({
name: "updateEvent",
title: "Update Event",
apps: ["gcal"],
variables: ["calendarId?", "eventId", "summary"],
run: async ({ auths, variables }) => {
const gcal = new GoogleCalendar({
auth: auths.gcal,
});

const response = await gcal.updateEvent({
calendarId: variables.calendarId || "primary",
eventId: variables.eventId!,
event: {
summary: variables.summary!,
start: {
dateTime: addHours(new Date(), 2).toISOString(),
},
end: {
dateTime: addHours(new Date(), 3).toISOString(),
},
},
});

console.log("Response: ", response.data);
},
});