Skip to main content

gcal.googlecalendar.patchevent

Home > @runlightyear/gcal > GoogleCalendar > patchEvent

GoogleCalendar.patchEvent() method

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

Patch an event.

Signature:
patchEvent(props: PatchEventProps): Promise<PatchEventResponse>;

Parameters

ParameterTypeDescription
propsPatchEventProps
Returns:

Promise<PatchEventResponse>

Example 1

Patch event summary

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

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

const response = await gcal.patchEvent({
calendarId: variables.calendarId || "primary",
eventId: variables.eventId!,
event: {
summary: variables.summary!,
},
});

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

Example 2

Patch event attendees

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

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

const attendees = variables.attendees!.split(",");

const response = await gcal.patchEvent({
calendarId: variables.calendarId || "primary",
eventId: variables.eventId!,
event: {
attendees: attendees.map((email) => ({ email })),
},
});

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

Example 3

Add event attendee

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

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

const getEventResponse = await gcal.getEvent({
calendarId: variables.calendarId || "primary",
eventId: variables.eventId!,
});

const event = getEventResponse.data;

const response = await gcal.patchEvent({
calendarId: variables.calendarId || "primary",
eventId: variables.eventId!,
event: {
attendees: [...event.attendees, { email: variables.attendee! }],
},
});

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