mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
add webinars and registrants resource
This commit is contained in:
@@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user