{"size": 693, "ext": "js", "max_stars_repo_path": "twilio.js", "max_stars_repo_name": "Dresing/c19", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "twilio.js", "max_issues_repo_name": "Dresing/c19", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "twilio.js", "max_forks_repo_name": "Dresing/c19", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.6538461538, "max_line_length": 68, "alphanum_fraction": 0.6378066378}
import rollbar from './rollbar';

const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const phoneNo = process.env.TWILIO_PHONE_NO;
const client = require('twilio')(accountSid, authToken);

export async function sendSMS({ body, to }) {
  try {
    if (process.env.NODE_ENV === 'development') {
      console.log({ body, to });
      return {};
    }
    if (to === '+4599999999') return {};
    const result = await client.messages.create({
      body,
      from: phoneNo,
      to,
    });
    if (process.env.NODE_ENV === 'development') console.log(result);
    return result;
  } catch (error) {
    rollbar.error('sendSMS: ' + error);
  }
}
