The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/tests/data/integration.helper.ts

48 lines
1.1 KiB

import type { Credentials } from '@rocket.chat/api-client';
import type { IIntegration } from '@rocket.chat/core-typings';
import type { IntegrationsCreateProps } from '@rocket.chat/rest-typings';
import { api, credentials, request } from './api-data';
export const createIntegration = (integration: IntegrationsCreateProps, userCredentials: Credentials) =>
new Promise<IIntegration>((resolve, reject) => {
void request
.post(api('integrations.create'))
.set(userCredentials)
.send(integration)
.end((err, res) => {
if (err) {
reject(err);
return;
}
if (!res.body.success) {
reject(res.body);
return;
}
resolve(res.body.integration);
});
});
export const removeIntegration = (integrationId: IIntegration['_id'], type: 'incoming' | 'outgoing') =>
new Promise<void>((resolve) => {
void request
.post(api('integrations.remove'))
.set(credentials)
.send({
type: `webhook-${type}`,
integrationId,
})
.end((err, res) => {
if (err) {
console.warn(err);
}
if (!res.body.success) {
console.warn(res.body);
}
resolve();
});
});