add webinars and registrants resource

This commit is contained in:
shraddha shaligram
2020-06-22 18:39:21 -07:00
parent c282a25876
commit 815f823f5a
5 changed files with 1198 additions and 137 deletions

View File

@@ -31,8 +31,6 @@ export async function zoomApiRequest(this: IExecuteFunctions | IExecuteSingleFun
if (Object.keys(query).length === 0) { if (Object.keys(query).length === 0) {
delete options.qs; delete options.qs;
} }
console.log("options");
console.log(options);
try { try {
if (authenticationMethod === 'accessToken') { if (authenticationMethod === 'accessToken') {
const credentials = this.getCredentials('zoomApi'); const credentials = this.getCredentials('zoomApi');
@@ -42,7 +40,6 @@ export async function zoomApiRequest(this: IExecuteFunctions | IExecuteSingleFun
options.headers!.Authorization = `Bearer ${credentials.accessToken}`; options.headers!.Authorization = `Bearer ${credentials.accessToken}`;
//@ts-ignore //@ts-ignore
return await this.helpers.request(options); return await this.helpers.request(options);
} else { } else {
//@ts-ignore //@ts-ignore
@@ -78,9 +75,10 @@ export async function zoomApiRequestAllItems(
): Promise<any> { ): Promise<any> {
// tslint:disable-line:no-any // tslint:disable-line:no-any
const returnData: IDataObject[] = []; const returnData: IDataObject[] = [];
let responseData; let responseData;
query.page = 1; //query.maxResults = 300;
query.count = 100;
do { do {
responseData = await zoomApiRequest.call( responseData = await zoomApiRequest.call(
this, this,
@@ -89,32 +87,14 @@ export async function zoomApiRequestAllItems(
body, body,
query query
); );
query.cursor = encodeURIComponent( query.page_number = responseData['page_number'];
_.get(responseData, 'response_metadata.next_cursor')
);
query.page++;
returnData.push.apply(returnData, responseData[propertyName]); returnData.push.apply(returnData, responseData[propertyName]);
} while ( } while (
(responseData.response_metadata !== undefined && responseData['page_number'] !== undefined &&
responseData.response_metadata.mext_cursor !== undefined && responseData['page_number'] !== ''
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)
); );
return returnData; 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;
}

View File

@@ -51,7 +51,7 @@ export const meetingFields = [
/* meeting:create */ /* meeting:create */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
{ {
displayName: 'Id', displayName: 'User Id',
name: 'userId', name: 'userId',
type: 'string', type: 'string',
default: '', default: '',
@@ -60,15 +60,13 @@ export const meetingFields = [
show: { show: {
operation: [ operation: [
'create', 'create',
], ],
resource: [ resource: [
'meeting', 'meeting',
], ],
}, },
}, },
description: 'User ID.', description: 'User ID or email address of user.',
}, },
{ {
displayName: 'Additional settings', displayName: 'Additional settings',
@@ -239,15 +237,13 @@ export const meetingFields = [
name: 'Disabled', name: 'Disabled',
value: 'none', value: 'none',
}, },
], ],
default: 'none', default: 'none',
description: 'Auto recording.', description: 'Auto recording.',
}, },
{ {
displayName: 'Audio', displayName: 'Audio',
name: 'auto_recording', name: 'audio',
type: 'options', type: 'options',
options: [ options: [
{ {
@@ -263,7 +259,6 @@ export const meetingFields = [
value: 'voip', value: 'voip',
}, },
], ],
default: 'both', default: 'both',
description: 'Determine how participants can join audio portion of the meeting.', 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', name: 'Attendees register once and can choose one or more occurences to attend',
value: 3, value: 3,
}, },
], ],
default: 1, default: 1,
description: 'Registration type. Used for recurring meetings with fixed time only', description: 'Registration type. Used for recurring meetings with fixed time only',
}, },
], ],
}, },
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* meeting:get */ /* meeting:get */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
{ {
displayName: 'Id', displayName: 'Meeting Id',
name: 'userId', name: 'meetingId',
type: 'string', type: 'string',
default: '', default: '',
required: true, 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 */ /* meeting:getAll */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
{ {
displayName: 'Id', displayName: 'User Id',
name: 'userId', name: 'userId',
type: 'string', type: 'string',
default: '', default: '',
@@ -335,7 +361,7 @@ export const meetingFields = [
], ],
}, },
}, },
description: 'User ID.', description: 'User ID or email-id.',
}, },
{ {
displayName: 'Return All', displayName: 'Return All',
@@ -393,7 +419,7 @@ export const meetingFields = [
resource: [ resource: [
'meeting', 'meeting',
], ],
} },
}, },
options: [ options: [
{ {
@@ -413,8 +439,6 @@ export const meetingFields = [
name: 'Upcoming', name: 'Upcoming',
value: 'upcoming', value: 'upcoming',
}, },
], ],
default: 'live', default: 'live',
description: `Meeting type.`, description: `Meeting type.`,
@@ -471,11 +495,8 @@ export const meetingFields = [
name: 'scheduleForReminder', name: 'scheduleForReminder',
type: 'boolean', type: 'boolean',
default: false, 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: { show: {
operation: [ operation: [
'update', 'update',
], ],
resource: [ resource: [
'meeting', 'meeting',
@@ -502,26 +521,6 @@ export const meetingFields = [
}, },
description: 'Meeting ID.', 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', displayName: 'Additional settings',
name: 'additionalFields', name: 'additionalFields',
@@ -531,15 +530,21 @@ export const meetingFields = [
displayOptions: { displayOptions: {
show: { show: {
operation: [ operation: [
'update', 'update',
], ],
resource: [ resource: [
'meeting', 'meeting',
], ],
} },
}, },
options: [ options: [
{
displayName: 'Occurence Id',
name: 'occurenceId',
type: 'string',
default: '',
description: 'Occurence ID.',
},
{ {
displayName: 'Meeting topic', displayName: 'Meeting topic',
name: 'topic', name: 'topic',
@@ -691,8 +696,6 @@ export const meetingFields = [
name: 'Disabled', name: 'Disabled',
value: 'none', value: 'none',
}, },
], ],
default: 'none', default: 'none',
description: 'Auto recording.', description: 'Auto recording.',
@@ -714,8 +717,6 @@ export const meetingFields = [
name: 'VOIP', name: 'VOIP',
value: 'voip', value: 'voip',
}, },
], ],
default: 'both', default: 'both',
description: 'Determine how participants can join audio portion of the meeting.', 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', name: 'Attendees register once and can choose one or more occurences to attend',
value: 3, value: 3,
}, },
], ],
default: 1, default: 1,
description: 'Registration type. Used for recurring meetings with fixed time only', description: 'Registration type. Used for recurring meetings with fixed time only',
}, },
], ],
}, },

View File

@@ -52,8 +52,6 @@ export const meetingRegistrantFields = [
show: { show: {
operation: [ operation: [
'create', 'create',
], ],
resource: [ resource: [
'meetingRegistrants', 'meetingRegistrants',
@@ -63,31 +61,21 @@ export const meetingRegistrantFields = [
description: 'Meeting ID.', description: 'Meeting ID.',
}, },
{ {
displayName: 'Occurence Id', displayName: 'Email',
name: 'occurenceId', name: 'email',
type: 'string', type: 'string',
default: '',
required: true, required: true,
default: '',
displayOptions: { displayOptions: {
show: { show: {
operation: [ operation: [
'create', 'create',
], ],
resource: [ resource: [
'meetingRegistrants', 'meetingRegistrants',
], ],
}, },
}, },
description: 'Occurence ID.',
},
{
displayName: 'Email',
name: 'email',
type: 'string',
required: true,
default: '',
description: 'Valid email-id of registrant.', description: 'Valid email-id of registrant.',
}, },
{ {
@@ -96,6 +84,16 @@ export const meetingRegistrantFields = [
required: true, required: true,
type: 'string', type: 'string',
default: '', default: '',
displayOptions: {
show: {
operation: [
'create',
],
resource: [
'meetingRegistrants',
],
},
},
description: 'First Name.', description: 'First Name.',
}, },
{ {
@@ -107,7 +105,7 @@ export const meetingRegistrantFields = [
displayOptions: { displayOptions: {
show: { show: {
operation: [ operation: [
'get', 'create',
], ],
resource: [ resource: [
@@ -116,6 +114,13 @@ export const meetingRegistrantFields = [
} }
}, },
options: [ options: [
{
displayName: 'Occurence Ids',
name: 'occurenceId',
type: 'string',
default: '',
description: 'Occurence IDs separated by comma.',
},
{ {
displayName: 'Last Name', displayName: 'Last Name',
name: 'lastName', name: 'lastName',
@@ -211,8 +216,6 @@ export const meetingRegistrantFields = [
name: 'No timeframe', name: 'No timeframe',
value: 'No timeframe', value: 'No timeframe',
}, },
], ],
default: '', default: '',
description: 'Meeting type.' description: 'Meeting type.'
@@ -258,8 +261,6 @@ export const meetingRegistrantFields = [
show: { show: {
operation: [ operation: [
'getAll', 'getAll',
], ],
resource: [ resource: [
'meetingRegistrants', 'meetingRegistrants',
@@ -318,7 +319,7 @@ export const meetingRegistrantFields = [
displayOptions: { displayOptions: {
show: { show: {
operation: [ operation: [
'get', 'getAll',
], ],
resource: [ resource: [
@@ -351,10 +352,8 @@ export const meetingRegistrantFields = [
name: 'Denied', name: 'Denied',
value: 'denied', value: 'denied',
}, },
], ],
default: '', default: 'approved',
description: `Registrant Status.`, description: `Registrant Status.`,
}, },
@@ -366,15 +365,13 @@ export const meetingRegistrantFields = [
{ {
displayName: 'Meeting Id', displayName: 'Meeting Id',
name: 'meetingId', name: 'meetingId',
type: 'number', type: 'string',
default: '', default: '',
required: true, required: true,
displayOptions: { displayOptions: {
show: { show: {
operation: [ operation: [
'update', 'update',
], ],
resource: [ resource: [
'meetingRegistrants', 'meetingRegistrants',
@@ -384,24 +381,63 @@ export const meetingRegistrantFields = [
description: 'Meeting ID.', description: 'Meeting ID.',
}, },
{ {
displayName: 'Occurence Id', displayName: 'Action',
name: 'occurenceId', name: 'action',
type: 'string', type: 'options',
default: '',
required: true, required: true,
displayOptions: { displayOptions: {
show: { show: {
operation: [ operation: [
'update', 'update',
], ],
resource: [ resource: [
'meetingRegistrants', '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[]; ] as INodeProperties[];

View File

@@ -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[];

View File

@@ -1,4 +1,6 @@
import { IExecuteFunctions } from 'n8n-core'; import {
IExecuteFunctions,
} from 'n8n-core';
import { import {
IDataObject, IDataObject,
INodeExecutionData, INodeExecutionData,
@@ -10,7 +12,6 @@ import {
import { import {
zoomApiRequest, zoomApiRequest,
zoomApiRequestAllItems, zoomApiRequestAllItems,
validateJSON,
} from './GenericFunctions'; } from './GenericFunctions';
import { import {
@@ -24,11 +25,16 @@ import {
} from './MeetingRegistrantDescription'; } from './MeetingRegistrantDescription';
import {
webinarOperations,
webinarFields,
} from './WebinarDescription';
import * as moment from 'moment-timezone'; import * as moment from 'moment-timezone';
interface Settings { interface Settings {
host_video?: boolean; host_video?: boolean;
participant_video?: boolean; participant_video?: boolean;
panelists_video?: boolean;
cn_meeting?: boolean; cn_meeting?: boolean;
in_meeting?: boolean; in_meeting?: boolean;
join_before_host?: boolean; join_before_host?: boolean;
@@ -38,6 +44,9 @@ interface Settings {
alternative_hosts?: string; alternative_hosts?: string;
auto_recording?: string; auto_recording?: string;
registration_type?: number; registration_type?: number;
approval_type?: number;
practice_session?: boolean;
} }
export class Zoom implements INodeType { export class Zoom implements INodeType {
@@ -107,17 +116,28 @@ export class Zoom implements INodeType {
value: 'meeting' value: 'meeting'
}, },
{ {
name: 'Meeting Registrants', name: 'Meeting Registrant',
value: 'meetingRegistrants' value: 'meetingRegistrants'
},
{
name: 'Webinar',
value: 'webinar'
} }
], ],
default: 'meeting', default: 'meeting',
description: 'The resource to operate on.' description: 'The resource to operate on.'
}, },
//MEETINGS
...meetingOperations, ...meetingOperations,
...meetingFields, ...meetingFields,
//MEETING REGISTRANTS
...meetingRegistrantOperations, ...meetingRegistrantOperations,
...meetingRegistrantFields, ...meetingRegistrantFields,
//WEBINARS
...webinarOperations,
...webinarFields,
] ]
}; };
@@ -149,20 +169,30 @@ export class Zoom implements INodeType {
let responseData; let responseData;
const resource = this.getNodeParameter('resource', 0) as string; const resource = this.getNodeParameter('resource', 0) as string;
const operation = this.getNodeParameter('operation', 0) as string; const operation = this.getNodeParameter('operation', 0) as string;
console.log(this.getCredentials('zoomOAuth2Api'));
let body: IDataObject = {}; let body: IDataObject = {};
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
qs = {}; qs = {};
//https://marketplace.zoom.us/docs/api-reference/zoom-api/
if (resource === 'meeting') { if (resource === 'meeting') {
if (operation === 'get') { if (operation === 'get') {
//https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meeting //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( responseData = await zoomApiRequest.call(
this, this,
'GET', 'GET',
`/meetings/${userId}`, `/meetings/${meetingId}`,
{}, {},
qs qs
); );
@@ -170,18 +200,30 @@ export class Zoom implements INodeType {
if (operation === 'getAll') { if (operation === 'getAll') {
//https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetings //https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetings
const userId = this.getNodeParameter('userId', i) as string; 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') { if (operation === 'delete') {
//https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingdelete //https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingdelete
const meetingId = this.getNodeParameter('meetingId', i) as string; 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( responseData = await zoomApiRequest.call(
this, this,
'DELETE', 'DELETE',
@@ -297,10 +339,6 @@ export class Zoom implements INodeType {
body.agenda = additionalFields.agenda as string; body.agenda = additionalFields.agenda as string;
} }
responseData = await zoomApiRequest.call( responseData = await zoomApiRequest.call(
this, this,
'POST', 'POST',
@@ -312,12 +350,16 @@ export class Zoom implements INodeType {
if (operation === 'update') { if (operation === 'update') {
//https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingupdate //https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingupdate
const meetingId = this.getNodeParameter('meetingId', i) as string; const meetingId = this.getNodeParameter('meetingId', i) as string;
qs.occurence_id = this.getNodeParameter('occurenceId', i) as string; const settings: Settings = {};
const additionalFields = this.getNodeParameter( const additionalFields = this.getNodeParameter(
'additionalFields', 'additionalFields',
i i
) as IDataObject; ) as IDataObject;
const settings: Settings = {};
if (additionalFields.occurenceId) {
qs.occurence_id = additionalFields.occurenceId as string;
}
if (additionalFields.cn_meeting) { if (additionalFields.cn_meeting) {
settings.cn_meeting = additionalFields.cn_meeting as boolean; settings.cn_meeting = additionalFields.cn_meeting as boolean;
@@ -423,16 +465,64 @@ export class Zoom implements INodeType {
body, body,
qs qs
); );
responseData = { updated: true };
} }
} }
if (resource === 'meetingRegistrant') { if (resource === 'meetingRegistrant') {
if (operation === 'create') { if (operation === 'create') {
//https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingregistrantcreate //https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingregistrantcreate
const meetingId = this.getNodeParameter('meetingId', i) as string; 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( responseData = await zoomApiRequest.call(
this, this,
'PATCH', 'POST',
`/meetings/${meetingId}/registrants`, `/meetings/${meetingId}/registrants`,
body, body,
qs qs
@@ -440,9 +530,282 @@ export class Zoom implements INodeType {
} }
if (operation === 'getAll') { if (operation === 'getAll') {
//https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingregistrants //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') { if (operation === 'update') {
//https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingregistrantstatus //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
);
} }
} }
} }