UNPKG

smscuba

Version:

API client for SMSCuba

32 lines (24 loc) 803 B
const request_promise = require('request-promise'); const url = 'https://us-central1-sms-cuba.cloudfunctions.net/sms_request'; module.exports = class SMSCuba { constructor(client_id, api_key) { this.client_id = client_id; this.api_key = api_key; } async send_message(recipient, message) { const propertiesObject = { client_id: this.client_id, api_key: this.api_key, recipient: recipient, message: message }; const options = {url:url, qs:propertiesObject, json: true}; let response; try { response = await request_promise(options); } catch (error) { response = error.error; } return response; } }