diff --git a/packages/nodes-base/nodes/Zoom/GenericFunctions.ts b/packages/nodes-base/nodes/Zoom/GenericFunctions.ts index 9cde3e67e2..d361a9761a 100644 --- a/packages/nodes-base/nodes/Zoom/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Zoom/GenericFunctions.ts @@ -31,8 +31,6 @@ export async function zoomApiRequest(this: IExecuteFunctions | IExecuteSingleFun if (Object.keys(query).length === 0) { delete options.qs; } - console.log("options"); - console.log(options); try { if (authenticationMethod === 'accessToken') { const credentials = this.getCredentials('zoomApi'); @@ -42,7 +40,6 @@ export async function zoomApiRequest(this: IExecuteFunctions | IExecuteSingleFun options.headers!.Authorization = `Bearer ${credentials.accessToken}`; //@ts-ignore - return await this.helpers.request(options); } else { //@ts-ignore @@ -78,9 +75,10 @@ export async function zoomApiRequestAllItems( ): Promise { // tslint:disable-line:no-any const returnData: IDataObject[] = []; + let responseData; - query.page = 1; - query.count = 100; + //query.maxResults = 300; + do { responseData = await zoomApiRequest.call( this, @@ -89,32 +87,14 @@ export async function zoomApiRequestAllItems( body, query ); - query.cursor = encodeURIComponent( - _.get(responseData, 'response_metadata.next_cursor') - ); - query.page++; + query.page_number = responseData['page_number']; returnData.push.apply(returnData, responseData[propertyName]); } while ( - (responseData.response_metadata !== undefined && - responseData.response_metadata.mext_cursor !== undefined && - responseData.response_metadata.next_cursor !== '' && - responseData.response_metadata.next_cursor !== null) || - (responseData.paging !== undefined && - responseData.paging.pages !== undefined && - responseData.paging.page !== undefined && - responseData.paging.page < responseData.paging.pages) + responseData['page_number'] !== undefined && + responseData['page_number'] !== '' ); return returnData; } -export function validateJSON(json: string | undefined): any { - // tslint:disable-line:no-any - let result; - try { - result = JSON.parse(json!); - } catch (exception) { - result = undefined; - } - return result; -} + diff --git a/packages/nodes-base/nodes/Zoom/MeetingDescription.ts b/packages/nodes-base/nodes/Zoom/MeetingDescription.ts index bd4b8ce271..274b48ff97 100644 --- a/packages/nodes-base/nodes/Zoom/MeetingDescription.ts +++ b/packages/nodes-base/nodes/Zoom/MeetingDescription.ts @@ -51,7 +51,7 @@ export const meetingFields = [ /* meeting:create */ /* -------------------------------------------------------------------------- */ { - displayName: 'Id', + displayName: 'User Id', name: 'userId', type: 'string', default: '', @@ -60,15 +60,13 @@ export const meetingFields = [ show: { operation: [ 'create', - - ], resource: [ 'meeting', ], }, }, - description: 'User ID.', + description: 'User ID or email address of user.', }, { displayName: 'Additional settings', @@ -239,15 +237,13 @@ export const meetingFields = [ name: 'Disabled', value: 'none', }, - - ], default: 'none', description: 'Auto recording.', }, { displayName: 'Audio', - name: 'auto_recording', + name: 'audio', type: 'options', options: [ { @@ -263,7 +259,6 @@ export const meetingFields = [ value: 'voip', }, - ], default: 'both', description: 'Determine how participants can join audio portion of the meeting.', @@ -285,22 +280,19 @@ export const meetingFields = [ name: 'Attendees register once and can choose one or more occurences to attend', value: 3, }, - - ], default: 1, description: 'Registration type. Used for recurring meetings with fixed time only', }, - ], }, /* -------------------------------------------------------------------------- */ /* meeting:get */ /* -------------------------------------------------------------------------- */ { - displayName: 'Id', - name: 'userId', + displayName: 'Meeting Id', + name: 'meetingId', type: 'string', default: '', required: true, @@ -314,13 +306,47 @@ export const meetingFields = [ ], }, }, - description: 'User ID.', + description: 'Meeting ID.', + }, + { + displayName: 'Additional settings', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', + default: {}, + displayOptions: { + show: { + operation: [ + 'get', + + ], + resource: [ + 'meeting', + ], + }, + }, + options: [ + { + displayName: 'Occurence Id', + name: 'occurenceId', + type: 'string', + default: '', + description: 'To view meeting details of a particular occurence of the recurring meeting.', + }, + { + displayName: 'Show Previous Occurences', + name: 'showPreviousOccurences', + type: 'boolean', + default: '', + description: 'To view meeting details of all previous occurences of the recurring meeting.', + }, + ], }, /* -------------------------------------------------------------------------- */ /* meeting:getAll */ /* -------------------------------------------------------------------------- */ { - displayName: 'Id', + displayName: 'User Id', name: 'userId', type: 'string', default: '', @@ -335,7 +361,7 @@ export const meetingFields = [ ], }, }, - description: 'User ID.', + description: 'User ID or email-id.', }, { displayName: 'Return All', @@ -393,7 +419,7 @@ export const meetingFields = [ resource: [ 'meeting', ], - } + }, }, options: [ { @@ -413,8 +439,6 @@ export const meetingFields = [ name: 'Upcoming', value: 'upcoming', }, - - ], default: 'live', description: `Meeting type.`, @@ -471,11 +495,8 @@ export const meetingFields = [ name: 'scheduleForReminder', type: 'boolean', default: false, - description: 'Schedule a reminder via email', + description: 'Notify hosts and alternative hosts about meeting cancellation via email', }, - - - ], }, @@ -492,8 +513,6 @@ export const meetingFields = [ show: { operation: [ 'update', - - ], resource: [ 'meeting', @@ -502,26 +521,6 @@ export const meetingFields = [ }, description: 'Meeting ID.', }, - { - displayName: 'Occurence Id', - name: 'occurenceId', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'update', - - - ], - resource: [ - 'meeting', - ], - }, - }, - description: 'Occurence ID.', - }, { displayName: 'Additional settings', name: 'additionalFields', @@ -531,15 +530,21 @@ export const meetingFields = [ displayOptions: { show: { operation: [ - 'update', ], resource: [ 'meeting', ], - } + }, }, options: [ + { + displayName: 'Occurence Id', + name: 'occurenceId', + type: 'string', + default: '', + description: 'Occurence ID.', + }, { displayName: 'Meeting topic', name: 'topic', @@ -691,8 +696,6 @@ export const meetingFields = [ name: 'Disabled', value: 'none', }, - - ], default: 'none', description: 'Auto recording.', @@ -714,8 +717,6 @@ export const meetingFields = [ name: 'VOIP', value: 'voip', }, - - ], default: 'both', description: 'Determine how participants can join audio portion of the meeting.', @@ -737,14 +738,10 @@ export const meetingFields = [ name: 'Attendees register once and can choose one or more occurences to attend', value: 3, }, - - ], default: 1, description: 'Registration type. Used for recurring meetings with fixed time only', }, - - ], }, diff --git a/packages/nodes-base/nodes/Zoom/MeetingRegistrantDescription.ts b/packages/nodes-base/nodes/Zoom/MeetingRegistrantDescription.ts index b062786892..592c7a285a 100644 --- a/packages/nodes-base/nodes/Zoom/MeetingRegistrantDescription.ts +++ b/packages/nodes-base/nodes/Zoom/MeetingRegistrantDescription.ts @@ -52,8 +52,6 @@ export const meetingRegistrantFields = [ show: { operation: [ 'create', - - ], resource: [ 'meetingRegistrants', @@ -63,31 +61,21 @@ export const meetingRegistrantFields = [ description: 'Meeting ID.', }, { - displayName: 'Occurence Id', - name: 'occurenceId', + displayName: 'Email', + name: 'email', type: 'string', - default: '', required: true, + default: '', displayOptions: { show: { operation: [ 'create', - - ], resource: [ 'meetingRegistrants', ], }, }, - description: 'Occurence ID.', - }, - { - displayName: 'Email', - name: 'email', - type: 'string', - required: true, - default: '', description: 'Valid email-id of registrant.', }, { @@ -96,6 +84,16 @@ export const meetingRegistrantFields = [ required: true, type: 'string', default: '', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'meetingRegistrants', + ], + }, + }, description: 'First Name.', }, { @@ -107,7 +105,7 @@ export const meetingRegistrantFields = [ displayOptions: { show: { operation: [ - 'get', + 'create', ], resource: [ @@ -116,6 +114,13 @@ export const meetingRegistrantFields = [ } }, options: [ + { + displayName: 'Occurence Ids', + name: 'occurenceId', + type: 'string', + default: '', + description: 'Occurence IDs separated by comma.', + }, { displayName: 'Last Name', name: 'lastName', @@ -211,8 +216,6 @@ export const meetingRegistrantFields = [ name: 'No timeframe', value: 'No timeframe', }, - - ], default: '', description: 'Meeting type.' @@ -258,8 +261,6 @@ export const meetingRegistrantFields = [ show: { operation: [ 'getAll', - - ], resource: [ 'meetingRegistrants', @@ -318,7 +319,7 @@ export const meetingRegistrantFields = [ displayOptions: { show: { operation: [ - 'get', + 'getAll', ], resource: [ @@ -351,10 +352,8 @@ export const meetingRegistrantFields = [ name: 'Denied', value: 'denied', }, - - ], - default: '', + default: 'approved', description: `Registrant Status.`, }, @@ -366,15 +365,13 @@ export const meetingRegistrantFields = [ { displayName: 'Meeting Id', name: 'meetingId', - type: 'number', + type: 'string', default: '', required: true, displayOptions: { show: { operation: [ 'update', - - ], resource: [ 'meetingRegistrants', @@ -384,24 +381,63 @@ export const meetingRegistrantFields = [ description: 'Meeting ID.', }, { - displayName: 'Occurence Id', - name: 'occurenceId', - type: 'string', - default: '', + displayName: 'Action', + name: 'action', + type: 'options', required: true, displayOptions: { show: { operation: [ 'update', - - ], resource: [ 'meetingRegistrants', ], }, }, - description: 'Occurence ID.', + options: [ + { + name: 'Cancel', + value: 'cancel', + }, + { + name: 'Approved', + value: 'approve', + }, + { + name: 'Deny', + value: 'deny', + }, + ], + default: '', + description: `Registrant Status.`, }, + { + displayName: 'Additional settings', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', + default: {}, + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'meetingRegistrants', + ], + }, + }, + options: [ + { + displayName: 'Occurence Id', + name: 'occurenceId', + type: 'string', + default: '', + description: 'Occurence ID.', + }, + + ], + } ] as INodeProperties[]; diff --git a/packages/nodes-base/nodes/Zoom/WebinarDescription.ts b/packages/nodes-base/nodes/Zoom/WebinarDescription.ts new file mode 100644 index 0000000000..5cefbdace8 --- /dev/null +++ b/packages/nodes-base/nodes/Zoom/WebinarDescription.ts @@ -0,0 +1,685 @@ +import { + INodeProperties, +} from 'n8n-workflow'; + +export const webinarOperations = [ + { + displayName: 'Operation', + name: 'operation', + type: 'options', + displayOptions: { + show: { + resource: [ + 'webinar', + ], + }, + }, + options: [ + { + name: 'Create', + value: 'create', + description: 'Create a webinar', + }, + { + name: 'Delete', + value: 'delete', + description: 'Delete a webinar', + }, + { + name: 'Get', + value: 'get', + description: 'Retrieve a webinar', + }, + { + name: 'Get All', + value: 'getAll', + description: 'Retrieve all webinars', + }, + { + name: 'Update', + value: 'update', + description: 'Update a webinar', + } + ], + default: 'create', + description: 'The operation to perform.', + } +] as INodeProperties[]; + +export const webinarFields = [ + /* -------------------------------------------------------------------------- */ + /* webinar:create */ + /* -------------------------------------------------------------------------- */ + { + displayName: 'User Id', + name: 'userId', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'webinar', + ], + }, + }, + description: 'User ID or email address of user.', + }, + { + displayName: 'Additional settings', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', + default: {}, + displayOptions: { + show: { + operation: [ + 'create', + + ], + resource: [ + 'webinar', + ], + } + }, + options: [ + { + displayName: 'Webinar topic', + name: 'topic', + type: 'string', + default: '', + description: `Webinar topic.`, + }, + { + displayName: 'Webinar type', + name: 'type', + type: 'options', + options: [ + { + name: 'Webinar', + value: 5, + }, + { + name: 'Recurring webinar with no fixed time', + value: 6, + }, + { + name: 'Recurring webinar with fixed time', + value: 9, + }, + ], + default: 5, + description: 'Webinar type.' + }, + { + displayName: 'Start time', + name: 'startTime', + type: 'dateTime', + default: '', + description: 'Start time should be used only for scheduled or recurring webinar with fixed time', + }, + { + displayName: 'Duration', + name: 'duration', + type: 'string', + default: '', + description: 'Duration.', + }, + { + displayName: 'Timezone', + name: 'timeZone', + type: 'options', + typeOptions: { + loadOptionsMethod: 'getTimezones', + }, + default: '', + description: `Time zone used in the response. The default is the time zone of the calendar.`, + }, + { + displayName: 'Password', + name: 'password', + type: 'string', + default: '', + description: 'Password to join the webinar with maximum 10 characters.', + }, + { + displayName: 'Agenda', + name: 'agenda', + type: 'string', + default: '', + description: 'Webinar agenda.', + }, + { + displayName: 'Host Video', + name: 'host_video', + type: 'boolean', + default: false, + description: 'Start video when host joins the webinar.', + }, + { + displayName: 'Panelists Video', + name: 'panelists_video', + type: 'boolean', + default: false, + description: 'Start video when panelists joins the webinar.', + }, + { + displayName: 'Practice Session', + name: 'practice_session', + type: 'boolean', + default: false, + description: 'Enable Practice session.', + }, + { + displayName: 'Alternative Hosts', + name: 'alternative_hosts', + type: 'string', + default: '', + description: 'Alternative hosts email ids.', + }, + { + displayName: 'Approval type', + name: 'approval_type', + type: 'options', + options: [ + { + name: 'Automatically approve', + value: 0, + }, + { + name: 'Manually approve', + value: 1, + }, + { + name: 'No registration required', + value: 2, + }, + ], + default: 2, + description: 'Approval type.', + }, + { + displayName: 'Auto recording', + name: 'auto_recording', + type: 'options', + options: [ + { + name: 'Record on local', + value: 'local', + }, + { + name: 'Record on cloud', + value: 'cloud', + }, + { + name: 'Disabled', + value: 'none', + }, + ], + default: 'none', + description: 'Auto recording.', + }, + { + displayName: 'Audio', + name: 'audio', + type: 'options', + options: [ + { + name: 'Both Telephony and VoiP', + value: 'both', + }, + { + name: 'Telephony', + value: 'telephony', + }, + { + name: 'VOIP', + value: 'voip', + }, + + ], + default: 'both', + description: 'Determine how participants can join audio portion of the webinar.', + }, + { + displayName: 'Registration type', + name: 'registration_type', + type: 'options', + options: [ + { + name: 'Attendees register once and can attend any of the occurences', + value: 1, + }, + { + name: 'Attendees need to register for every occurence', + value: 2, + }, + { + name: 'Attendees register once and can choose one or more occurences to attend', + value: 3, + }, + ], + default: 1, + description: 'Registration type. Used for recurring webinar with fixed time only', + }, + + ], + }, + /* -------------------------------------------------------------------------- */ + /* webinar:get */ + /* -------------------------------------------------------------------------- */ + { + displayName: 'Webinar Id', + name: 'webinarId', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'get', + ], + resource: [ + 'webinar', + ], + }, + }, + description: 'Webinar ID.', + }, + { + displayName: 'Additional settings', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', + default: {}, + displayOptions: { + show: { + operation: [ + 'get', + + ], + resource: [ + 'webinar', + ], + }, + }, + options: [ + { + displayName: 'Occurence Id', + name: 'occurenceId', + type: 'string', + default: '', + description: 'To view webinar details of a particular occurence of the recurring webinar.', + }, + { + displayName: 'Show Previous Occurences', + name: 'showPreviousOccurences', + type: 'boolean', + default: '', + description: 'To view webinar details of all previous occurences of the recurring webinar.', + }, + ], + }, + /* -------------------------------------------------------------------------- */ + /* webinar:getAll */ + /* -------------------------------------------------------------------------- */ + { + displayName: 'User Id', + name: 'userId', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'webinar', + ], + }, + }, + description: 'User ID or email-id.', + }, + { + displayName: 'Return All', + name: 'returnAll', + type: 'boolean', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'webinar', + ], + }, + }, + default: false, + description: 'If all results should be returned or only up to a given limit.', + }, + { + displayName: 'Limit', + name: 'limit', + type: 'number', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'webinar', + ], + returnAll: [ + false, + ], + }, + }, + typeOptions: { + minValue: 1, + maxValue: 300 + }, + default: 30, + description: 'How many results to return.', + }, + { + displayName: 'Additional settings', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', + default: {}, + displayOptions: { + show: { + operation: [ + 'getAll', + + ], + resource: [ + 'webinar', + ], + }, + }, + + }, + /* -------------------------------------------------------------------------- */ + /* webina:delete */ + /* -------------------------------------------------------------------------- */ + { + displayName: 'Webinar Id', + name: 'webinarId', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'delete' + ], + resource: [ + 'webinarId', + ], + }, + }, + description: 'WebinarId ID.', + }, + { + displayName: 'Additional Fields', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', + default: {}, + displayOptions: { + show: { + operation: [ + 'delete', + ], + resource: [ + 'webinar', + ], + }, + }, + options: [ + { + displayName: 'Occurence Id', + name: 'occurenceId', + type: 'string', + default: '', + description: 'Webinar occurence Id.', + }, + + ], + + }, + /* -------------------------------------------------------------------------- */ + /* webinar:update */ + /* -------------------------------------------------------------------------- */ + { + displayName: 'User Id', + name: 'userId', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'webinar', + ], + }, + }, + description: 'User ID or email address of user.', + }, + { + displayName: 'Additional settings', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', + default: {}, + displayOptions: { + show: { + operation: [ + 'update', + + ], + resource: [ + 'webinar', + ], + } + }, + options: [ + { + displayName: 'Occurence Id', + name: 'occurence_id', + type: 'string', + default: '', + description: `Webinar occurence Id.`, + }, + { + displayName: 'Webinar topic', + name: 'topic', + type: 'string', + default: '', + description: `Webinar topic.`, + }, + { + displayName: 'Webinar type', + name: 'type', + type: 'options', + options: [ + { + name: 'Webinar', + value: 5, + }, + { + name: 'Recurring webinar with no fixed time', + value: 6, + }, + { + name: 'Recurring webinar with fixed time', + value: 9, + }, + ], + default: 5, + description: 'Webinar type.' + }, + { + displayName: 'Start time', + name: 'startTime', + type: 'dateTime', + default: '', + description: 'Start time should be used only for scheduled or recurring webinar with fixed time', + }, + { + displayName: 'Duration', + name: 'duration', + type: 'string', + default: '', + description: 'Duration.', + }, + { + displayName: 'Timezone', + name: 'timeZone', + type: 'options', + typeOptions: { + loadOptionsMethod: 'getTimezones', + }, + default: '', + description: `Time zone used in the response. The default is the time zone of the calendar.`, + }, + { + displayName: 'Password', + name: 'password', + type: 'string', + default: '', + description: 'Password to join the webinar with maximum 10 characters.', + }, + { + displayName: 'Agenda', + name: 'agenda', + type: 'string', + default: '', + description: 'Webinar agenda.', + }, + { + displayName: 'Host Video', + name: 'host_video', + type: 'boolean', + default: false, + description: 'Start video when host joins the webinar.', + }, + { + displayName: 'Panelists Video', + name: 'panelists_video', + type: 'boolean', + default: false, + description: 'Start video when panelists joins the webinar.', + }, + { + displayName: 'Practice Session', + name: 'practice_session', + type: 'boolean', + default: false, + description: 'Enable Practice session.', + }, + { + displayName: 'Alternative Hosts', + name: 'alternative_hosts', + type: 'string', + default: '', + description: 'Alternative hosts email ids.', + }, + { + displayName: 'Approval type', + name: 'approval_type', + type: 'options', + options: [ + { + name: 'Automatically approve', + value: 0, + }, + { + name: 'Manually approve', + value: 1, + }, + { + name: 'No registration required', + value: 2, + }, + ], + default: 2, + description: 'Approval type.', + }, + { + displayName: 'Auto recording', + name: 'auto_recording', + type: 'options', + options: [ + { + name: 'Record on local', + value: 'local', + }, + { + name: 'Record on cloud', + value: 'cloud', + }, + { + name: 'Disabled', + value: 'none', + }, + ], + default: 'none', + description: 'Auto recording.', + }, + { + displayName: 'Audio', + name: 'audio', + type: 'options', + options: [ + { + name: 'Both Telephony and VoiP', + value: 'both', + }, + { + name: 'Telephony', + value: 'telephony', + }, + { + name: 'VOIP', + value: 'voip', + }, + + ], + default: 'both', + description: 'Determine how participants can join audio portion of the webinar.', + }, + { + displayName: 'Registration type', + name: 'registration_type', + type: 'options', + options: [ + { + name: 'Attendees register once and can attend any of the occurences', + value: 1, + }, + { + name: 'Attendees need to register for every occurence', + value: 2, + }, + { + name: 'Attendees register once and can choose one or more occurences to attend', + value: 3, + }, + ], + default: 1, + description: 'Registration type. Used for recurring webinars with fixed time only', + }, + + ], + }, + +] as INodeProperties[]; diff --git a/packages/nodes-base/nodes/Zoom/Zoom.node.ts b/packages/nodes-base/nodes/Zoom/Zoom.node.ts index c1915d4ab4..fb3b7565f7 100644 --- a/packages/nodes-base/nodes/Zoom/Zoom.node.ts +++ b/packages/nodes-base/nodes/Zoom/Zoom.node.ts @@ -1,4 +1,6 @@ -import { IExecuteFunctions } from 'n8n-core'; +import { + IExecuteFunctions, +} from 'n8n-core'; import { IDataObject, INodeExecutionData, @@ -10,7 +12,6 @@ import { import { zoomApiRequest, zoomApiRequestAllItems, - validateJSON, } from './GenericFunctions'; import { @@ -24,11 +25,16 @@ import { } from './MeetingRegistrantDescription'; +import { + webinarOperations, + webinarFields, +} from './WebinarDescription'; import * as moment from 'moment-timezone'; interface Settings { host_video?: boolean; participant_video?: boolean; + panelists_video?: boolean; cn_meeting?: boolean; in_meeting?: boolean; join_before_host?: boolean; @@ -38,6 +44,9 @@ interface Settings { alternative_hosts?: string; auto_recording?: string; registration_type?: number; + approval_type?: number; + practice_session?: boolean; + } export class Zoom implements INodeType { @@ -107,17 +116,28 @@ export class Zoom implements INodeType { value: 'meeting' }, { - name: 'Meeting Registrants', + name: 'Meeting Registrant', value: 'meetingRegistrants' + }, + { + name: 'Webinar', + value: 'webinar' } ], default: 'meeting', description: 'The resource to operate on.' }, + //MEETINGS ...meetingOperations, ...meetingFields, + + //MEETING REGISTRANTS ...meetingRegistrantOperations, ...meetingRegistrantFields, + + //WEBINARS + ...webinarOperations, + ...webinarFields, ] }; @@ -149,20 +169,30 @@ export class Zoom implements INodeType { let responseData; const resource = this.getNodeParameter('resource', 0) as string; const operation = this.getNodeParameter('operation', 0) as string; - console.log(this.getCredentials('zoomOAuth2Api')); let body: IDataObject = {}; for (let i = 0; i < length; i++) { qs = {}; + //https://marketplace.zoom.us/docs/api-reference/zoom-api/ if (resource === 'meeting') { if (operation === 'get') { //https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meeting - const userId = this.getNodeParameter('userId', i) as string; + const meetingId = this.getNodeParameter('meetingId', i) as string; + + const additionalFields = this.getNodeParameter( + 'additionalFields', + i + ) as IDataObject; + if (additionalFields.showPreviousOccurences) + qs.show_previous_occurences = additionalFields.showPreviousOccurences as boolean; + + if (additionalFields.occurenceId) + qs.occurence_id = additionalFields.occurenceId as string; responseData = await zoomApiRequest.call( this, 'GET', - `/meetings/${userId}`, + `/meetings/${meetingId}`, {}, qs ); @@ -170,18 +200,30 @@ export class Zoom implements INodeType { if (operation === 'getAll') { //https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetings const userId = this.getNodeParameter('userId', i) as string; + const returnAll = this.getNodeParameter('returnAll', i) as boolean; + if (returnAll) { + responseData = await zoomApiRequestAllItems.call(this, 'results', 'GET', `/users/${userId}/meetings`, {}, qs); + } else { + const limit = this.getNodeParameter('limit', i) as number; + qs.page_size = limit; + responseData = await zoomApiRequest.call(this, 'GET', `/users/${userId}/meetings`, {}, qs); + responseData = responseData.results; + } - responseData = await zoomApiRequest.call( - this, - 'GET', - `/users/${userId}/meetings`, - {}, - qs - ); } if (operation === 'delete') { //https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingdelete const meetingId = this.getNodeParameter('meetingId', i) as string; + const additionalFields = this.getNodeParameter( + 'additionalFields', + i + ) as IDataObject; + if (additionalFields.scheduleForReminder) + qs.schedule_for_reminder = additionalFields.scheduleForReminder as boolean; + + if (additionalFields.occurenceId) + qs.occurence_id = additionalFields.occurenceId; + responseData = await zoomApiRequest.call( this, 'DELETE', @@ -297,10 +339,6 @@ export class Zoom implements INodeType { body.agenda = additionalFields.agenda as string; } - - - - responseData = await zoomApiRequest.call( this, 'POST', @@ -312,12 +350,16 @@ export class Zoom implements INodeType { if (operation === 'update') { //https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingupdate const meetingId = this.getNodeParameter('meetingId', i) as string; - qs.occurence_id = this.getNodeParameter('occurenceId', i) as string; + const settings: Settings = {}; const additionalFields = this.getNodeParameter( 'additionalFields', i ) as IDataObject; - const settings: Settings = {}; + + if (additionalFields.occurenceId) { + qs.occurence_id = additionalFields.occurenceId as string; + } + if (additionalFields.cn_meeting) { settings.cn_meeting = additionalFields.cn_meeting as boolean; @@ -423,16 +465,64 @@ export class Zoom implements INodeType { body, qs ); + responseData = { updated: true }; + } } if (resource === 'meetingRegistrant') { if (operation === 'create') { //https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingregistrantcreate const meetingId = this.getNodeParameter('meetingId', i) as string; - qs.occurence_id = this.getNodeParameter('occurenceId', i) as string; + const emailId = this.getNodeParameter('email', i) as string; + body.email = emailId; + const firstName = this.getNodeParameter('firstName', i) as string; + body.first_name = firstName; + const additionalFields = this.getNodeParameter( + 'additionalFields', + i + ) as IDataObject; + if (additionalFields.occurenceId) { + qs.occurence_ids = additionalFields.occurenceId as string; + } + if (additionalFields.lastName) { + body.last_name = additionalFields.lastName as string; + } + if (additionalFields.address) { + body.address = additionalFields.address as string; + } + if (additionalFields.city) { + body.city = additionalFields.city as string; + } + if (additionalFields.state) { + body.state = additionalFields.state as string; + } + if (additionalFields.country) { + body.country = additionalFields.country as string; + } + if (additionalFields.zip) { + body.zip = additionalFields.zip as string; + } + if (additionalFields.phone) { + body.phone = additionalFields.phone as string; + } + if (additionalFields.comments) { + body.comments = additionalFields.comments as string; + } + if (additionalFields.org) { + body.org = additionalFields.org as string; + } + if (additionalFields.job_title) { + body.job_title = additionalFields.job_title as string; + } + if (additionalFields.purchasing_time_frame) { + body.purchasing_time_frame = additionalFields.purchasing_time_frame as string; + } + if (additionalFields.role_in_purchase_process) { + body.role_in_purchase_process = additionalFields.role_in_purchase_process as string; + } responseData = await zoomApiRequest.call( this, - 'PATCH', + 'POST', `/meetings/${meetingId}/registrants`, body, qs @@ -440,9 +530,282 @@ export class Zoom implements INodeType { } if (operation === 'getAll') { //https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingregistrants + const meetingId = this.getNodeParameter('meetingId', i) as string; + const additionalFields = this.getNodeParameter( + 'additionalFields', + i + ) as IDataObject; + if (additionalFields.occurenceId) { + qs.occurence_id = additionalFields.occurenceId as string; + } + if (additionalFields.status) { + qs.status = additionalFields.status as string; + } + const returnAll = this.getNodeParameter('returnAll', i) as boolean; + if (returnAll) { + responseData = await zoomApiRequestAllItems.call(this, 'results', 'GET', `/meetings/${meetingId}/registrants`, {}, qs); + } else { + const limit = this.getNodeParameter('limit', i) as number; + qs.page_size = limit; + responseData = await zoomApiRequest.call(this, 'GET', `/meetings/${meetingId}/registrants`, {}, qs); + responseData = responseData.results; + } + } if (operation === 'update') { //https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingregistrantstatus + const meetingId = this.getNodeParameter('meetingId', i) as string; + const additionalFields = this.getNodeParameter( + 'additionalFields', + i + ) as IDataObject; + if (additionalFields.occurenceId) { + qs.occurence_id = additionalFields.occurenceId as string; + } + responseData = await zoomApiRequest.call( + this, + 'PUT', + `/meetings/${meetingId}/registrants/status`, + body, + qs + ); + } + } + if (resource === 'webinar') { + if (operation === 'create') { + //https://marketplace.zoom.us/docs/api-reference/zoom-api/webinars/webinarcreate + const userId = this.getNodeParameter('userId', i) as string; + const additionalFields = this.getNodeParameter( + 'additionalFields', + i + ) as IDataObject; + const settings: Settings = {}; + + + if (additionalFields.audio) { + settings.audio = additionalFields.audio as string; + + } + + if (additionalFields.alternative_hosts) { + settings.alternative_hosts = additionalFields.alternative_hosts as string; + + } + + if (additionalFields.panelists_video) { + settings.panelists_video = additionalFields.panelists_video as boolean; + + } + if (additionalFields.practice_session) { + settings.practice_session = additionalFields.practice_session as boolean; + + } + if (additionalFields.auto_recording) { + settings.auto_recording = additionalFields.auto_recording as string; + + } + + if (additionalFields.registration_type) { + settings.registration_type = additionalFields.registration_type as number; + + } + if (additionalFields.approval_type) { + settings.approval_type = additionalFields.approval_type as number; + + } + + body = { + settings, + }; + + if (additionalFields.topic) { + body.topic = additionalFields.topic as string; + + } + + if (additionalFields.type) { + body.type = additionalFields.type as string; + + } + + if (additionalFields.startTime) { + body.start_time = additionalFields.startTime as string; + + } + + if (additionalFields.duration) { + body.duration = additionalFields.duration as number; + + } + + + if (additionalFields.timeZone) { + body.timezone = additionalFields.timeZone as string; + + } + + if (additionalFields.password) { + body.password = additionalFields.password as string; + + } + + if (additionalFields.agenda) { + body.agenda = additionalFields.agenda as string; + + } + responseData = await zoomApiRequest.call( + this, + 'POST', + `/users/${userId}/webinars`, + body, + qs + ); + } + if (operation === 'get') { + //https://marketplace.zoom.us/docs/api-reference/zoom-api/webinars/webinar + const webinarId = this.getNodeParameter('webinarId', i) as string; + + const additionalFields = this.getNodeParameter( + 'additionalFields', + i + ) as IDataObject; + if (additionalFields.showPreviousOccurences) + qs.show_previous_occurences = additionalFields.showPreviousOccurences as boolean; + + if (additionalFields.occurenceId) + qs.occurence_id = additionalFields.occurenceId as string; + + responseData = await zoomApiRequest.call( + this, + 'GET', + `/webinars/${webinarId}`, + {}, + qs + ); + } + if (operation === 'getAll') { + //https://marketplace.zoom.us/docs/api-reference/zoom-api/webinars/webinars + const userId = this.getNodeParameter('userId', i) as string; + const returnAll = this.getNodeParameter('returnAll', i) as boolean; + if (returnAll) { + responseData = await zoomApiRequestAllItems.call(this, 'results', 'GET', `/users/${userId}/webinars`, {}, qs); + } else { + const limit = this.getNodeParameter('limit', i) as number; + qs.page_size = limit; + responseData = await zoomApiRequest.call(this, 'GET', `/users/${userId}/webinars`, {}, qs); + responseData = responseData.results; + } + } + if (operation === 'delete') { + //https://marketplace.zoom.us/docs/api-reference/zoom-api/webinars/webinardelete + const webinarId = this.getNodeParameter('webinarId', i) as string; + const additionalFields = this.getNodeParameter( + 'additionalFields', + i + ) as IDataObject; + + + if (additionalFields.occurenceId) + qs.occurence_id = additionalFields.occurenceId; + + responseData = await zoomApiRequest.call( + this, + 'DELETE', + `/webinars/${webinarId}`, + {}, + qs + ); + responseData = { success: true }; + } + if (operation === 'update') { + //https://marketplace.zoom.us/docs/api-reference/zoom-api/webinars/webinarupdate + const webinarId = this.getNodeParameter('webinarId', i) as string; + const additionalFields = this.getNodeParameter( + 'additionalFields', + i + ) as IDataObject; + if (additionalFields.occurence_id) { + qs.occurence_id = additionalFields.occurence_id as string; + + } + const settings: Settings = {}; + if (additionalFields.audio) { + settings.audio = additionalFields.audio as string; + + } + if (additionalFields.alternative_hosts) { + settings.alternative_hosts = additionalFields.alternative_hosts as string; + + } + + if (additionalFields.panelists_video) { + settings.panelists_video = additionalFields.panelists_video as boolean; + + } + if (additionalFields.practice_session) { + settings.practice_session = additionalFields.practice_session as boolean; + + } + if (additionalFields.auto_recording) { + settings.auto_recording = additionalFields.auto_recording as string; + + } + + if (additionalFields.registration_type) { + settings.registration_type = additionalFields.registration_type as number; + + } + if (additionalFields.approval_type) { + settings.approval_type = additionalFields.approval_type as number; + + } + + body = { + settings, + }; + + if (additionalFields.topic) { + body.topic = additionalFields.topic as string; + + } + + if (additionalFields.type) { + body.type = additionalFields.type as string; + + } + + if (additionalFields.startTime) { + body.start_time = additionalFields.startTime as string; + + } + + if (additionalFields.duration) { + body.duration = additionalFields.duration as number; + + } + + + if (additionalFields.timeZone) { + body.timezone = additionalFields.timeZone as string; + + } + + if (additionalFields.password) { + body.password = additionalFields.password as string; + + } + + if (additionalFields.agenda) { + body.agenda = additionalFields.agenda as string; + + } + responseData = await zoomApiRequest.call( + this, + 'PATCH', + `/users/${webinarId}/webinars`, + body, + qs + ); } } }