import {
    errorHandler, fetchRespHandler, getAuthHeaderOptions
} from "../utils/http";

const API_ENDPOINT = process.env.REACT_APP_OTA_SERVICE_URL;

const smsAPI = {
  /**
   * Sends an SMS to an ICCID
   * @param {*} data 
   * @param {*} token 
   * @returns 
   */
  send: async (data, token) =>
    fetch(`${API_ENDPOINT}/sms`, {
      method: "POST",
      headers: Object.assign(
        { "Content-Type": "application/json" },
        getAuthHeaderOptions(token)
      ),
      body: JSON.stringify(data),
    }).then(fetchRespHandler).catch(errorHandler),
};

export default smsAPI;