ToolJet/marketplace/plugins/plivo/lib/index.ts
Arpit 636c4a62c5
[chore] Eslint fixes (#5988)
* 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/**
2023-04-11 15:34:58 +05:30

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,
};
}
}