mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-02 02:47:27 +00:00
* lint fixes: frontend * lint fixes: marketplace * lint fixes: plugins-client js files * typo fix * eslint updates/fixes for marketplace * eslint updates/fixes for plugins * removing "@typescript-eslint/no-floating-promises for plugins" * ignore client.js and server.js * ignore client.js and server.js * ignore client.js and server.tss * Delete client.js * ignore cypress-test/**
27 lines
812 B
TypeScript
27 lines
812 B
TypeScript
import { QueryError, QueryService, QueryResult } from '@tooljet-marketplace/common';
|
|
const plivo = require('plivo');
|
|
|
|
export default class PlivoService implements QueryService {
|
|
getClient(authId: string, authToken: string): any {
|
|
return new plivo.Client(authId, authToken);
|
|
}
|
|
|
|
async run(sourceOptions: any, queryOptions: any): Promise<QueryResult> {
|
|
let result = {};
|
|
|
|
try {
|
|
const client = this.getClient(sourceOptions.authId, sourceOptions.authToken);
|
|
|
|
if (queryOptions.operation === 'send_sms') {
|
|
result = await client.messages.create(queryOptions.from, queryOptions.to, queryOptions.body);
|
|
}
|
|
} catch (error) {
|
|
throw new QueryError('Query could not be completed', error.message, {});
|
|
}
|
|
|
|
return {
|
|
status: 'ok',
|
|
data: result,
|
|
};
|
|
}
|
|
}
|