Kubessandra / react-google-calendar-api

An api to manage your google calendar
MIT License
215 stars 88 forks source link

problem trying to create meets link and sending mail notification when creating a new event #55

Closed Sockshead closed 2 years ago

Sockshead commented 3 years ago

Hi,

i'm using the api to manage the creation of events but i'm failing to auto generate a google meets link, also failing to send the invitation to the event to the attendees, is there any way to do so using this api?

i'll attach the method i have written this far trying to solve this issue

export function setNewEvents(event) {
    let r = Math.random().toString(36).substring(7);
    let options = {
        summary: event.summary,
        start: {
            dateTime: event.start,
        },
        end: {
            dateTime: event.end,
        },
        attendees: [{ email: "my-email@gmail.com", responseStatus: "needsAction" }],
        conferenceData: {
            createRequest: { conferenceSolutionKey: { type: "hangoutsMeet" }, requestId: r },
        },
        reminders: {
            useDefault: false,
            overrides: [
                { method: "email", minutes: 24 * 60 },
                { method: "popup", minutes: 15 },
            ],
        },
        visibility: "public",
    };

    ApiCalendar.createEvent(options, CALENDAR_ID, { conferenceDataVersion: 1 })
        .then((result) => console.log(result))
        .catch((error) => {
            console.log(error);
        });
}
muhdlaziem commented 3 years ago

Is this issue solved?

Kubessandra commented 3 years ago

Hello, You are missing the param sendUpdates he is set at 'none' by default, you can set it to 'all'.

  /**
   * Create Calendar event
   * @param {string} calendarId for the event.
   * @param {object} event with start and end dateTime
   * @param {string} sendUpdates Acceptable values are: "all", "externalOnly", "none"
   * @returns {any}
   */
  public createEvent(event: object, calendarId: string = this.calendar, sendUpdates: string = 'none' ): any {
    if (this.gapi) {
      return this.gapi.client.calendar.events.insert({
        calendarId: calendarId,
        resource: event,
        sendUpdates: sendUpdates,
      });
    } else {
      console.log('Error: this.gapi not loaded');
      return false;
    }
  }

The purpose of the param:

Whether to send notifications about the creation of the new event. Note that some emails might still be sent. The default is false.

Acceptable values are:
"all": Notifications are sent to all guests.
"externalOnly": Notifications are sent to non-Google Calendar guests only.
"none": No notifications are sent. For calendar migration tasks, consider using the Events.import method instead.
Kubessandra commented 3 years ago

@Sockshead @Sockshead does this solve your problem?