@icapps/tree-house-communication
Version:
Tree House communication module
24 lines (23 loc) • 810 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.sendTextMessage = void 0;
const twilio = require("twilio");
const client_config_1 = require("../config/client-config");
function getClient() {
const accountSid = (0, client_config_1.getTwilioAccountSid)();
const authToken = (0, client_config_1.getTwilioAuthToken)();
if (!accountSid)
throw new Error('No twilio accountSid provided');
if (!authToken)
throw new Error('No twilio authToken provided');
return twilio(accountSid, authToken);
}
function sendTextMessage(fromNumber, toNumber, message) {
const client = getClient();
return client.messages.create({
body: message,
from: fromNumber,
to: toNumber,
});
}
exports.sendTextMessage = sendTextMessage;