2023-01-27 03:22:44 -08:00
|
|
|
import type {
|
2021-07-23 13:28:18 -07:00
|
|
|
IDataObject,
|
2023-03-06 08:33:32 -08:00
|
|
|
IExecuteFunctions,
|
2021-07-23 13:28:18 -07:00
|
|
|
ILoadOptionsFunctions,
|
|
|
|
INodeExecutionData,
|
|
|
|
INodePropertyOptions,
|
|
|
|
INodeType,
|
|
|
|
INodeTypeDescription,
|
|
|
|
} from 'n8n-workflow';
|
|
|
|
|
2023-03-06 08:33:32 -08:00
|
|
|
import { getAttachments, webexApiRequest, webexApiRequestAllItems } from './GenericFunctions';
|
2021-07-23 13:28:18 -07:00
|
|
|
|
|
|
|
import {
|
|
|
|
meetingFields,
|
|
|
|
meetingOperations,
|
|
|
|
// meetingTranscriptFields,
|
|
|
|
// meetingTranscriptOperations,
|
|
|
|
messageFields,
|
|
|
|
messageOperations,
|
|
|
|
} from './descriptions';
|
|
|
|
|
2022-04-08 14:32:08 -07:00
|
|
|
import moment from 'moment-timezone';
|
2021-07-23 13:28:18 -07:00
|
|
|
|
|
|
|
export class CiscoWebex implements INodeType {
|
|
|
|
description: INodeTypeDescription = {
|
2021-08-07 00:46:33 -07:00
|
|
|
displayName: 'Webex by Cisco',
|
2021-07-23 13:28:18 -07:00
|
|
|
name: 'ciscoWebex',
|
2022-06-20 07:54:01 -07:00
|
|
|
// eslint-disable-next-line n8n-nodes-base/node-class-description-icon-not-svg
|
2021-08-05 10:06:28 -07:00
|
|
|
icon: 'file:ciscoWebex.png',
|
2021-07-23 13:28:18 -07:00
|
|
|
group: ['transform'],
|
|
|
|
version: 1,
|
|
|
|
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
|
|
description: 'Consume the Cisco Webex API',
|
|
|
|
defaults: {
|
feat(editor): Node creator actions (#4696)
* WIP: Node Actions List UI
* WIP: Recommended Actions and preseting of fields
* WIP: Resource category
* :art: Moved actions categorisation to the server
* :label: Add missing INodeAction type
* :sparkles: Improve SSR categorisation, fix adding of mixed actions
* :recycle: Refactor CategorizedItems to composition api, style fixes
* WIP: Adding multiple nodes
* :recycle: Refactor rest of the NodeCreator component to composition API, conver globalLinkActions to composable
* :sparkles: Allow actions dragging, fix search and refactor passing of actions to categorized items
* :lipstick: Fix node actions title
* Migrate to the pinia store, add posthog feature and various fixes
* :bug: Fix filtering of trigger actions when not merged
* fix: N8N-5439 — Do not use simple node item when at NodeHelperPanel root
* :bug: Design review fixes
* :bug: Fix disabling of merged actions
* Fix trigger root filtering
* :sparkles: Allow for custom node actions parser, introduce hubspot parser
* :bug: Fix initial node params validation, fix position of second added node
* :bug: Introduce operations category, removed canvas node names overrride, fix API actions display and prevent dragging of action nodes
* :sparkles: Prevent NDV auto-open feature flag
* :bug: Inject recommened action for trigger nodes without actions
* Refactored NodeCreatorNode to Storybook, change filtering of merged nodes for the trigger helper panel, minor fixes
* Improve rendering of app nodes and animation
* Cleanup, any only enable accordion transition on triggerhelperpanel
* Hide node creator scrollbars in Firefox
* Minor styles fixes
* Do not copy the array in rendering method
* Removed unused props
* Fix memory leak
* Fix categorisation of regular nodes with a single resource
* Implement telemetry calls for node actions
* Move categorization to FE
* Fix client side actions categorisation
* Skip custom action show
* Only load tooltip for NodeIcon if necessary
* Fix lodash startCase import
* Remove lodash.startcase
* Cleanup
* Fix node creator autofocus on "tab"
* Prevent posthog getFeatureFlag from crashing
* Debugging preview env search issues
* Remove logs
* Make sure the pre-filled params are update not overwritten
* Get rid of transition in itemiterator
* WIP: Rough version of NodeActions keyboard navigation, replace nodeCreator composable with Pinia store module
* Rewrite to add support for ActionItem to ItemIterator and make CategorizedItems accept items props
* Fix category item counter & cleanup
* Add APIHint to actions search no-result, clean up NodeCreatorNode
* Improve node actions no results message
* Remove logging, fix filtering of recommended placeholder category
* Remove unused NodeActions component and node merging feature falg
* Do not show regular nodes without actions
* Make sure to add manual trigger when adding http node via actions hint
* Fixed api hint footer line height
* Prevent pointer-events od NodeIcon img and remove "this" from template
* Address PR points
* Fix e2e specs
* Make sure canvas ia loaded
* Make sure canvas ia loaded before opening nodeCreator in e2e spec
* Fix flaky workflows tags e2e getter
* Imrpove node creator click outside UX, add manual node to regular nodes added from trigger panel
* Add manual trigger node if dragging regular from trigger panel
2022-12-09 01:56:36 -08:00
|
|
|
name: 'Webex by Cisco',
|
2021-07-23 13:28:18 -07:00
|
|
|
},
|
|
|
|
credentials: [
|
|
|
|
{
|
|
|
|
name: 'ciscoWebexOAuth2Api',
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
inputs: ['main'],
|
|
|
|
outputs: ['main'],
|
|
|
|
properties: [
|
|
|
|
{
|
|
|
|
displayName: 'Resource',
|
|
|
|
name: 'resource',
|
|
|
|
type: 'options',
|
2022-05-20 14:47:24 -07:00
|
|
|
noDataExpression: true,
|
2021-07-23 13:28:18 -07:00
|
|
|
options: [
|
|
|
|
{
|
|
|
|
name: 'Meeting',
|
|
|
|
value: 'meeting',
|
|
|
|
},
|
|
|
|
// {
|
|
|
|
// name: 'Meeeting Transcript',
|
|
|
|
// value: 'meetingTranscript',
|
|
|
|
// },
|
|
|
|
{
|
|
|
|
name: 'Message',
|
|
|
|
value: 'message',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
default: 'message',
|
|
|
|
},
|
|
|
|
...meetingOperations,
|
|
|
|
...meetingFields,
|
|
|
|
// ...meetingTranscriptOperations,
|
|
|
|
// ...meetingTranscriptFields,
|
|
|
|
...messageOperations,
|
|
|
|
...messageFields,
|
|
|
|
],
|
|
|
|
};
|
|
|
|
|
|
|
|
methods = {
|
|
|
|
loadOptions: {
|
|
|
|
async getRooms(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
|
|
|
const returnData: INodePropertyOptions[] = [];
|
|
|
|
const rooms = await webexApiRequestAllItems.call(this, 'items', 'GET', '/rooms');
|
|
|
|
for (const room of rooms) {
|
|
|
|
returnData.push({
|
|
|
|
name: room.title,
|
|
|
|
value: room.id,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return returnData;
|
|
|
|
},
|
|
|
|
async getSites(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
|
|
|
const returnData: INodePropertyOptions[] = [];
|
2022-08-01 13:47:55 -07:00
|
|
|
const sites = await webexApiRequestAllItems.call(
|
|
|
|
this,
|
|
|
|
'sites',
|
|
|
|
'GET',
|
|
|
|
'/meetingPreferences/sites',
|
|
|
|
);
|
2021-07-23 13:28:18 -07:00
|
|
|
for (const site of sites) {
|
|
|
|
returnData.push({
|
|
|
|
name: site.siteUrl,
|
|
|
|
value: site.siteUrl,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return returnData;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
|
|
|
const items = this.getInputData();
|
2022-08-30 08:55:33 -07:00
|
|
|
const returnData: INodeExecutionData[] = [];
|
2021-07-23 13:28:18 -07:00
|
|
|
const timezone = this.getTimezone();
|
2022-12-02 03:53:59 -08:00
|
|
|
const resource = this.getNodeParameter('resource', 0);
|
|
|
|
const operation = this.getNodeParameter('operation', 0);
|
2021-07-23 13:28:18 -07:00
|
|
|
|
|
|
|
let responseData;
|
|
|
|
|
|
|
|
for (let i = 0; i < items.length; i++) {
|
|
|
|
try {
|
|
|
|
if (resource === 'message') {
|
|
|
|
// **********************************************************************
|
|
|
|
// message
|
|
|
|
// **********************************************************************
|
|
|
|
|
|
|
|
if (operation === 'create') {
|
|
|
|
// ----------------------------------------
|
|
|
|
// message: create
|
|
|
|
// ----------------------------------------
|
|
|
|
|
|
|
|
// https://developer.webex.com/docs/api/v1/messages/create-a-message
|
|
|
|
const destination = this.getNodeParameter('destination', i);
|
2022-08-01 13:47:55 -07:00
|
|
|
const file = this.getNodeParameter(
|
|
|
|
'additionalFields.fileUi.fileValue',
|
|
|
|
i,
|
|
|
|
{},
|
|
|
|
) as IDataObject;
|
2021-07-23 13:28:18 -07:00
|
|
|
const markdown = this.getNodeParameter('additionalFields.markdown', i, '') as boolean;
|
|
|
|
const body = {} as IDataObject;
|
|
|
|
if (destination === 'room') {
|
2022-12-02 12:54:28 -08:00
|
|
|
body.roomId = this.getNodeParameter('roomId', i);
|
2021-07-23 13:28:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (destination === 'person') {
|
|
|
|
const specifyPersonBy = this.getNodeParameter('specifyPersonBy', 0) as string;
|
|
|
|
if (specifyPersonBy === 'id') {
|
2022-12-02 12:54:28 -08:00
|
|
|
body.toPersonId = this.getNodeParameter('toPersonId', i);
|
2021-07-23 13:28:18 -07:00
|
|
|
} else {
|
2022-12-02 12:54:28 -08:00
|
|
|
body.toPersonEmail = this.getNodeParameter('toPersonEmail', i);
|
2021-07-23 13:28:18 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (markdown) {
|
2022-12-02 12:54:28 -08:00
|
|
|
body.markdown = markdown;
|
2021-07-23 13:28:18 -07:00
|
|
|
}
|
|
|
|
|
2022-12-02 12:54:28 -08:00
|
|
|
body.text = this.getNodeParameter('text', i);
|
2021-07-23 13:28:18 -07:00
|
|
|
|
2023-03-06 08:33:32 -08:00
|
|
|
body.attachments = getAttachments(
|
2022-08-01 13:47:55 -07:00
|
|
|
this.getNodeParameter(
|
|
|
|
'additionalFields.attachmentsUi.attachmentValues',
|
|
|
|
i,
|
|
|
|
[],
|
|
|
|
) as IDataObject[],
|
|
|
|
);
|
2021-07-23 13:28:18 -07:00
|
|
|
|
|
|
|
if (Object.keys(file).length) {
|
|
|
|
const isBinaryData = file.fileLocation === 'binaryData' ? true : false;
|
|
|
|
|
|
|
|
if (isBinaryData) {
|
|
|
|
const binaryPropertyName = file.binaryPropertyName as string;
|
2023-03-06 08:33:32 -08:00
|
|
|
const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
|
2022-08-01 13:47:55 -07:00
|
|
|
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(
|
|
|
|
i,
|
|
|
|
binaryPropertyName,
|
|
|
|
);
|
2021-07-23 13:28:18 -07:00
|
|
|
|
|
|
|
const formData = {
|
|
|
|
files: {
|
2021-08-20 09:08:40 -07:00
|
|
|
value: binaryDataBuffer,
|
2021-07-23 13:28:18 -07:00
|
|
|
options: {
|
|
|
|
filename: binaryData.fileName,
|
|
|
|
contentType: binaryData.mimeType,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
Object.assign(body, formData);
|
|
|
|
} else {
|
|
|
|
const url = file.url as string;
|
|
|
|
Object.assign(body, { files: url });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (file.fileLocation === 'binaryData') {
|
2022-08-01 13:47:55 -07:00
|
|
|
responseData = await webexApiRequest.call(
|
|
|
|
this,
|
|
|
|
'POST',
|
|
|
|
'/messages',
|
|
|
|
{},
|
|
|
|
{},
|
|
|
|
undefined,
|
|
|
|
{ formData: body },
|
|
|
|
);
|
2021-07-23 13:28:18 -07:00
|
|
|
} else {
|
|
|
|
responseData = await webexApiRequest.call(this, 'POST', '/messages', body);
|
|
|
|
}
|
2022-08-30 08:55:33 -07:00
|
|
|
responseData = this.helpers.constructExecutionMetaData(
|
2023-02-27 19:39:43 -08:00
|
|
|
this.helpers.returnJsonArray(responseData as IDataObject[]),
|
2022-08-30 08:55:33 -07:00
|
|
|
{ itemData: { item: i } },
|
|
|
|
);
|
2021-07-23 13:28:18 -07:00
|
|
|
} else if (operation === 'delete') {
|
|
|
|
// ----------------------------------------
|
|
|
|
// message: delete
|
|
|
|
// ----------------------------------------
|
|
|
|
|
|
|
|
// https://developer.webex.com/docs/api/v1/messages/delete-a-message
|
|
|
|
const messageId = this.getNodeParameter('messageId', i);
|
|
|
|
|
|
|
|
const endpoint = `/messages/${messageId}`;
|
|
|
|
responseData = await webexApiRequest.call(this, 'DELETE', endpoint);
|
2022-08-30 08:55:33 -07:00
|
|
|
responseData = this.helpers.constructExecutionMetaData(
|
|
|
|
this.helpers.returnJsonArray({ success: true }),
|
|
|
|
{ itemData: { item: i } },
|
|
|
|
);
|
2021-07-23 13:28:18 -07:00
|
|
|
} else if (operation === 'get') {
|
|
|
|
// ----------------------------------------
|
|
|
|
// message: get
|
|
|
|
// ----------------------------------------
|
|
|
|
|
|
|
|
// https://developer.webex.com/docs/api/v1/messages/get-message-details
|
|
|
|
const messageId = this.getNodeParameter('messageId', i);
|
|
|
|
|
|
|
|
const endpoint = `/messages/${messageId}`;
|
|
|
|
responseData = await webexApiRequest.call(this, 'GET', endpoint);
|
2022-08-30 08:55:33 -07:00
|
|
|
responseData = this.helpers.constructExecutionMetaData(
|
2023-02-27 19:39:43 -08:00
|
|
|
this.helpers.returnJsonArray(responseData as IDataObject[]),
|
2022-08-30 08:55:33 -07:00
|
|
|
{ itemData: { item: i } },
|
|
|
|
);
|
2021-07-23 13:28:18 -07:00
|
|
|
} else if (operation === 'getAll') {
|
|
|
|
// ----------------------------------------
|
|
|
|
// message: getAll
|
|
|
|
// ----------------------------------------
|
|
|
|
|
|
|
|
// https://developer.webex.com/docs/api/v1/messages/list-messages
|
|
|
|
const qs: IDataObject = {
|
|
|
|
roomId: this.getNodeParameter('roomId', i),
|
|
|
|
};
|
2022-11-18 07:29:44 -08:00
|
|
|
const filters = this.getNodeParameter('filters', i);
|
2022-11-18 05:31:38 -08:00
|
|
|
const returnAll = this.getNodeParameter('returnAll', i);
|
2021-07-23 13:28:18 -07:00
|
|
|
|
|
|
|
if (Object.keys(filters).length) {
|
|
|
|
Object.assign(qs, filters);
|
|
|
|
}
|
|
|
|
|
2022-12-02 12:54:28 -08:00
|
|
|
if (returnAll) {
|
2022-08-01 13:47:55 -07:00
|
|
|
responseData = await webexApiRequestAllItems.call(
|
|
|
|
this,
|
|
|
|
'items',
|
|
|
|
'GET',
|
|
|
|
'/messages',
|
|
|
|
{},
|
|
|
|
qs,
|
|
|
|
);
|
2021-07-23 13:28:18 -07:00
|
|
|
} else {
|
2022-11-18 06:26:22 -08:00
|
|
|
qs.max = this.getNodeParameter('limit', i);
|
2021-07-23 13:28:18 -07:00
|
|
|
responseData = await webexApiRequest.call(this, 'GET', '/messages', {}, qs);
|
|
|
|
responseData = responseData.items;
|
|
|
|
}
|
2022-08-30 08:55:33 -07:00
|
|
|
responseData = this.helpers.constructExecutionMetaData(
|
2023-02-27 19:39:43 -08:00
|
|
|
this.helpers.returnJsonArray(responseData.items as IDataObject[]),
|
2022-08-30 08:55:33 -07:00
|
|
|
{ itemData: { item: i } },
|
|
|
|
);
|
2021-07-23 13:28:18 -07:00
|
|
|
} else if (operation === 'update') {
|
|
|
|
// ----------------------------------------
|
|
|
|
// message: update
|
|
|
|
// ----------------------------------------
|
|
|
|
|
|
|
|
// https://developer.webex.com/docs/api/v1/messages/edit-a-message
|
|
|
|
const messageId = this.getNodeParameter('messageId', i) as string;
|
|
|
|
const markdown = this.getNodeParameter('markdown', i) as boolean;
|
|
|
|
|
|
|
|
const endpoint = `/messages/${messageId}`;
|
|
|
|
|
|
|
|
responseData = await webexApiRequest.call(this, 'GET', endpoint);
|
|
|
|
|
|
|
|
const body = {
|
|
|
|
roomId: responseData.roomId,
|
|
|
|
} as IDataObject;
|
|
|
|
|
2022-12-02 12:54:28 -08:00
|
|
|
if (markdown) {
|
|
|
|
body.markdown = this.getNodeParameter('markdownText', i);
|
2021-07-23 13:28:18 -07:00
|
|
|
} else {
|
2022-12-02 12:54:28 -08:00
|
|
|
body.text = this.getNodeParameter('text', i);
|
2021-07-23 13:28:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
responseData = await webexApiRequest.call(this, 'PUT', endpoint, body);
|
2022-08-30 08:55:33 -07:00
|
|
|
responseData = this.helpers.constructExecutionMetaData(
|
2023-02-27 19:39:43 -08:00
|
|
|
this.helpers.returnJsonArray(responseData as IDataObject[]),
|
2022-08-30 08:55:33 -07:00
|
|
|
{ itemData: { item: i } },
|
|
|
|
);
|
2021-07-23 13:28:18 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (resource === 'meeting') {
|
|
|
|
if (operation === 'create') {
|
|
|
|
const title = this.getNodeParameter('title', i) as string;
|
|
|
|
const start = this.getNodeParameter('start', i) as string;
|
|
|
|
const end = this.getNodeParameter('end', i) as string;
|
2022-08-01 13:47:55 -07:00
|
|
|
const invitees = this.getNodeParameter(
|
|
|
|
'additionalFields.inviteesUi.inviteeValues',
|
|
|
|
i,
|
|
|
|
[],
|
|
|
|
) as IDataObject[];
|
2022-11-18 07:29:44 -08:00
|
|
|
const additionalFields = this.getNodeParameter('additionalFields', i);
|
2021-07-23 13:28:18 -07:00
|
|
|
|
|
|
|
const body: IDataObject = {
|
|
|
|
title,
|
|
|
|
start: moment.tz(start, timezone).format(),
|
|
|
|
end: moment.tz(end, timezone).format(),
|
|
|
|
...additionalFields,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (body.requireRegistrationInfo) {
|
2022-12-02 12:54:28 -08:00
|
|
|
body.registration = (body.requireRegistrationInfo as string[]).reduce(
|
2022-08-01 13:47:55 -07:00
|
|
|
(obj, value) => Object.assign(obj, { [`${value}`]: true }),
|
|
|
|
{},
|
|
|
|
);
|
2021-07-23 13:28:18 -07:00
|
|
|
delete body.requireRegistrationInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (invitees) {
|
2022-12-02 12:54:28 -08:00
|
|
|
body.invitees = invitees;
|
2021-07-23 13:28:18 -07:00
|
|
|
delete body.inviteesUi;
|
|
|
|
}
|
|
|
|
|
|
|
|
responseData = await webexApiRequest.call(this, 'POST', '/meetings', body);
|
2022-08-30 08:55:33 -07:00
|
|
|
responseData = this.helpers.constructExecutionMetaData(
|
2023-02-27 19:39:43 -08:00
|
|
|
this.helpers.returnJsonArray(responseData as IDataObject[]),
|
2022-08-30 08:55:33 -07:00
|
|
|
{ itemData: { item: i } },
|
|
|
|
);
|
2021-07-23 13:28:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (operation === 'delete') {
|
|
|
|
const meetingId = this.getNodeParameter('meetingId', i) as string;
|
2022-11-18 07:29:44 -08:00
|
|
|
const options = this.getNodeParameter('options', i);
|
2021-07-23 13:28:18 -07:00
|
|
|
|
|
|
|
const qs: IDataObject = {
|
|
|
|
...options,
|
|
|
|
};
|
|
|
|
|
2022-08-01 13:47:55 -07:00
|
|
|
responseData = await webexApiRequest.call(
|
|
|
|
this,
|
|
|
|
'DELETE',
|
|
|
|
`/meetings/${meetingId}`,
|
|
|
|
{},
|
|
|
|
qs,
|
|
|
|
);
|
2022-08-30 08:55:33 -07:00
|
|
|
responseData = this.helpers.constructExecutionMetaData(
|
|
|
|
this.helpers.returnJsonArray({ success: true }),
|
|
|
|
{ itemData: { item: i } },
|
|
|
|
);
|
2021-07-23 13:28:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (operation === 'get') {
|
|
|
|
const meetingId = this.getNodeParameter('meetingId', i) as string;
|
2022-11-18 07:29:44 -08:00
|
|
|
const options = this.getNodeParameter('options', i);
|
2021-07-23 13:28:18 -07:00
|
|
|
let headers = {};
|
|
|
|
|
|
|
|
const qs: IDataObject = {
|
|
|
|
...options,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (options.passsword) {
|
|
|
|
headers = {
|
|
|
|
passsword: options.passsword,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-08-01 13:47:55 -07:00
|
|
|
responseData = await webexApiRequest.call(
|
|
|
|
this,
|
|
|
|
'GET',
|
|
|
|
`/meetings/${meetingId}`,
|
|
|
|
{},
|
|
|
|
qs,
|
|
|
|
undefined,
|
|
|
|
{ headers },
|
|
|
|
);
|
2022-08-30 08:55:33 -07:00
|
|
|
responseData = this.helpers.constructExecutionMetaData(
|
2023-02-27 19:39:43 -08:00
|
|
|
this.helpers.returnJsonArray(responseData as IDataObject[]),
|
2022-08-30 08:55:33 -07:00
|
|
|
{ itemData: { item: i } },
|
|
|
|
);
|
2021-07-23 13:28:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (operation === 'getAll') {
|
2022-11-18 07:29:44 -08:00
|
|
|
const filters = this.getNodeParameter('filters', i);
|
2022-11-18 05:31:38 -08:00
|
|
|
const returnAll = this.getNodeParameter('returnAll', i);
|
2021-07-23 13:28:18 -07:00
|
|
|
|
|
|
|
const qs: IDataObject = {
|
|
|
|
...filters,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (qs.from) {
|
2022-08-01 13:47:55 -07:00
|
|
|
qs.from = moment(qs.from as string)
|
|
|
|
.utc(true)
|
|
|
|
.format();
|
2021-07-23 13:28:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (qs.to) {
|
2022-08-01 13:47:55 -07:00
|
|
|
qs.to = moment(qs.to as string)
|
|
|
|
.utc(true)
|
|
|
|
.format();
|
2021-07-23 13:28:18 -07:00
|
|
|
}
|
|
|
|
|
2022-12-02 12:54:28 -08:00
|
|
|
if (returnAll) {
|
2022-08-01 13:47:55 -07:00
|
|
|
responseData = await webexApiRequestAllItems.call(
|
|
|
|
this,
|
|
|
|
'items',
|
|
|
|
'GET',
|
|
|
|
'/meetings',
|
|
|
|
{},
|
|
|
|
qs,
|
|
|
|
);
|
2021-07-23 13:28:18 -07:00
|
|
|
} else {
|
2022-11-18 06:26:22 -08:00
|
|
|
qs.max = this.getNodeParameter('limit', i);
|
2021-07-23 13:28:18 -07:00
|
|
|
responseData = await webexApiRequest.call(this, 'GET', '/meetings', {}, qs);
|
|
|
|
responseData = responseData.items;
|
|
|
|
}
|
2022-08-30 08:55:33 -07:00
|
|
|
responseData = this.helpers.constructExecutionMetaData(
|
2023-02-27 19:39:43 -08:00
|
|
|
this.helpers.returnJsonArray(responseData as IDataObject[]),
|
2022-08-30 08:55:33 -07:00
|
|
|
{ itemData: { item: i } },
|
|
|
|
);
|
2021-07-23 13:28:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (operation === 'update') {
|
|
|
|
const meetingId = this.getNodeParameter('meetingId', i) as string;
|
2022-08-01 13:47:55 -07:00
|
|
|
const invitees = this.getNodeParameter(
|
|
|
|
'updateFields.inviteesUi.inviteeValues',
|
|
|
|
i,
|
|
|
|
[],
|
|
|
|
) as IDataObject[];
|
2022-11-18 07:29:44 -08:00
|
|
|
const updateFields = this.getNodeParameter('updateFields', i);
|
2021-07-23 13:28:18 -07:00
|
|
|
|
2022-08-01 13:47:55 -07:00
|
|
|
const { title, password, start, end } = await webexApiRequest.call(
|
|
|
|
this,
|
|
|
|
'GET',
|
|
|
|
`/meetings/${meetingId}`,
|
|
|
|
);
|
2021-07-23 13:28:18 -07:00
|
|
|
|
|
|
|
const body: IDataObject = {
|
|
|
|
...updateFields,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (body.requireRegistrationInfo) {
|
2022-12-02 12:54:28 -08:00
|
|
|
body.registration = (body.requireRegistrationInfo as string[]).reduce(
|
2022-08-01 13:47:55 -07:00
|
|
|
(obj, value) => Object.assign(obj, { [`${value}`]: true }),
|
|
|
|
{},
|
|
|
|
);
|
2021-07-23 13:28:18 -07:00
|
|
|
delete body.requireRegistrationInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (invitees.length) {
|
2022-12-02 12:54:28 -08:00
|
|
|
body.invitees = invitees;
|
2021-07-23 13:28:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (body.start) {
|
|
|
|
body.start = moment.tz(updateFields.start, timezone).format();
|
|
|
|
} else {
|
|
|
|
body.start = start;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (body.end) {
|
|
|
|
body.end = moment.tz(updateFields.end, timezone).format();
|
|
|
|
} else {
|
|
|
|
body.end = end;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!body.title) {
|
|
|
|
body.title = title;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!body.password) {
|
|
|
|
body.password = password;
|
|
|
|
}
|
|
|
|
|
|
|
|
responseData = await webexApiRequest.call(this, 'PUT', `/meetings/${meetingId}`, body);
|
2022-08-30 08:55:33 -07:00
|
|
|
responseData = this.helpers.constructExecutionMetaData(
|
2023-02-27 19:39:43 -08:00
|
|
|
this.helpers.returnJsonArray(responseData as IDataObject[]),
|
2022-08-30 08:55:33 -07:00
|
|
|
{ itemData: { item: i } },
|
|
|
|
);
|
2021-07-23 13:28:18 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-27 19:39:43 -08:00
|
|
|
returnData.push(...(responseData as INodeExecutionData[]));
|
2021-07-23 13:28:18 -07:00
|
|
|
} catch (error) {
|
|
|
|
if (this.continueOnFail()) {
|
2022-08-30 08:55:33 -07:00
|
|
|
returnData.push({ error: error.toString(), json: {}, itemIndex: i });
|
2021-07-23 13:28:18 -07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if (resource === 'meetingTranscript') {
|
|
|
|
|
|
|
|
// if (operation === 'download') {
|
|
|
|
// for (let i = 0; i < items.length; i++) {
|
|
|
|
// const transcriptId = this.getNodeParameter('transcriptId', i) as string;
|
2023-01-06 06:09:32 -08:00
|
|
|
// const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
|
2021-07-23 13:28:18 -07:00
|
|
|
// const meetingId = this.getNodeParameter('meetingId', i) as string;
|
2022-11-18 07:29:44 -08:00
|
|
|
// const options = this.getNodeParameter('options', i);
|
2021-07-23 13:28:18 -07:00
|
|
|
|
|
|
|
// const qs: IDataObject = {
|
|
|
|
// meetingId,
|
|
|
|
// ...options,
|
|
|
|
// };
|
|
|
|
// const transcription = await webexApiRequest.call(this, 'GET', `/meetingTranscripts/${transcriptId}/download`, {}, qs);
|
|
|
|
|
|
|
|
// responseData = {
|
|
|
|
// json: {},
|
|
|
|
// binary: {
|
|
|
|
// [binaryPropertyName]: {
|
|
|
|
// data: Buffer.from(transcription, BINARY_ENCODING),
|
|
|
|
// //contentType:
|
|
|
|
// //FILE
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (operation === 'getAll') {
|
|
|
|
// for (let i = 0; i < items.length; i++) {
|
|
|
|
// try {
|
|
|
|
// const meetingId = this.getNodeParameter('meetingId', i) as string;
|
2022-11-18 07:29:44 -08:00
|
|
|
// const filters = this.getNodeParameter('filters', i);
|
2022-11-18 05:31:38 -08:00
|
|
|
// const returnAll = this.getNodeParameter('returnAll', i);
|
2021-07-23 13:28:18 -07:00
|
|
|
|
|
|
|
// const qs: IDataObject = {
|
|
|
|
// meetingId,
|
|
|
|
// ...filters,
|
|
|
|
// };
|
|
|
|
|
|
|
|
// if (returnAll === true) {
|
|
|
|
// responseData = await webexApiRequestAllItems.call(this, 'items', 'GET', '/meetingTranscripts', {}, qs);
|
|
|
|
// returnData.push(...responseData);
|
|
|
|
// } else {
|
2022-11-18 06:26:22 -08:00
|
|
|
// qs.max = this.getNodeParameter('limit', i);
|
2021-07-23 13:28:18 -07:00
|
|
|
// responseData = await webexApiRequest.call(this, 'GET', '/meetingTranscripts', {}, qs);
|
|
|
|
// returnData.push(...responseData.items);
|
|
|
|
// }
|
|
|
|
// } catch (error) {
|
|
|
|
// if (this.continueOnFail()) {
|
|
|
|
// returnData.push({
|
|
|
|
// error: error.message,
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
2022-08-30 08:55:33 -07:00
|
|
|
return this.prepareOutputData(returnData);
|
2021-07-23 13:28:18 -07:00
|
|
|
}
|
|
|
|
}
|