From 5eb65f8721236893ea0f7b28a0bd7534bb492441 Mon Sep 17 00:00:00 2001 From: Ricardo Espinoza Date: Fri, 23 Oct 2020 02:00:00 -0400 Subject: [PATCH] :zap: Add Google Calendar conference link (#1085) --- .../nodes/Google/Calendar/EventDescription.ts | 31 +++++++++++ .../nodes/Google/Calendar/EventInterface.ts | 10 ++++ .../Google/Calendar/GoogleCalendar.node.ts | 51 +++++++++++++++++++ 3 files changed, 92 insertions(+) diff --git a/packages/nodes-base/nodes/Google/Calendar/EventDescription.ts b/packages/nodes-base/nodes/Google/Calendar/EventDescription.ts index 98ec3e04d2..5e178f143b 100644 --- a/packages/nodes-base/nodes/Google/Calendar/EventDescription.ts +++ b/packages/nodes-base/nodes/Google/Calendar/EventDescription.ts @@ -177,6 +177,37 @@ export const eventFields = [ default: '', description: 'The color of the event.', }, + { + displayName: 'Conference Data', + name: 'conferenceDataUi', + placeholder: 'Add Conference', + type: 'fixedCollection', + typeOptions: { + multipleValues: false, + }, + default: {}, + options: [ + { + displayName: 'Conference Link', + name: 'conferenceDataValues', + values: [ + { + displayName: 'Type', + name: 'conferenceSolution', + type: 'options', + typeOptions: { + loadOptionsMethod: 'getConferenceSolutations', + loadOptionsDependsOn: [ + 'calendar', + ], + }, + default: '', + }, + ], + }, + ], + description: 'Creates a conference link (Hangouts, Meet etc) and attachs it to the event', + }, { displayName: 'Description', name: 'description', diff --git a/packages/nodes-base/nodes/Google/Calendar/EventInterface.ts b/packages/nodes-base/nodes/Google/Calendar/EventInterface.ts index 14cda0fe41..2800333a1c 100644 --- a/packages/nodes-base/nodes/Google/Calendar/EventInterface.ts +++ b/packages/nodes-base/nodes/Google/Calendar/EventInterface.ts @@ -7,6 +7,15 @@ export interface IReminder { overrides?: IDataObject[]; } +export interface IConferenceData { + createRequest?: { + requestId: string, + conferenceSolution: { + type: string, + } + }; +} + export interface IEvent { attendees?: IDataObject[]; colorId?: string; @@ -25,4 +34,5 @@ export interface IEvent { summary?: string; transparency?: string; visibility?: string; + conferenceData?: IConferenceData; } diff --git a/packages/nodes-base/nodes/Google/Calendar/GoogleCalendar.node.ts b/packages/nodes-base/nodes/Google/Calendar/GoogleCalendar.node.ts index ad61540c5a..2d168eaf4d 100644 --- a/packages/nodes-base/nodes/Google/Calendar/GoogleCalendar.node.ts +++ b/packages/nodes-base/nodes/Google/Calendar/GoogleCalendar.node.ts @@ -27,6 +27,8 @@ import { import * as moment from 'moment-timezone'; +import * as uuid from 'uuid/v4'; + export class GoogleCalendar implements INodeType { description: INodeTypeDescription = { displayName: 'Google Calendar', @@ -69,6 +71,38 @@ export class GoogleCalendar implements INodeType { methods = { loadOptions: { + + + // "conferenceProperties": { + // "allowedConferenceSolutionTypes": [ + // "hangoutsMeet" + // ] + + // Get all the calendars to display them to user so that he can + // select them easily + async getConferenceSolutations( + this: ILoadOptionsFunctions + ): Promise { + const returnData: INodePropertyOptions[] = []; + const calendar = this.getCurrentNodeParameter('calendar') as string; + const posibleSolutions: IDataObject = { + 'eventHangout': 'Google Hangout', + 'eventNamedHangout': 'Google Hangout Classic', + 'hangoutsMeet': 'Google Meet', + }; + const { conferenceProperties: { allowedConferenceSolutionTypes } } = await googleApiRequest.call( + this, + 'GET', + `/calendar/v3/users/me/calendarList/${calendar}`, + ); + for (const solution of allowedConferenceSolutionTypes) { + returnData.push({ + name: posibleSolutions[solution] as string, + value: solution, + }); + } + return returnData; + }, // Get all the calendars to display them to user so that he can // select them easily async getCalendars( @@ -265,6 +299,23 @@ export class GoogleCalendar implements INodeType { if (body.recurrence.length !== 0) { body.recurrence = [`RRULE:${body.recurrence.join('')}`]; } + + if (additionalFields.conferenceDataUi) { + const conferenceData = (additionalFields.conferenceDataUi as IDataObject).conferenceDataValues as IDataObject; + if (conferenceData) { + + qs.conferenceDataVersion = 1; + body.conferenceData = { + createRequest: { + requestId: uuid(), + conferenceSolution: { + type: conferenceData.conferenceSolution as string, + } + }, + }; + } + } + responseData = await googleApiRequest.call( this, 'POST',