termii
Version:
A Javascript wrapper for termii messaging platform for businesses
1 lines • 2.35 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Termii=t():e.Termii=t()}(window,(function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(o,i,function(t){return e[t]}.bind(null,i));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";n.r(t);const o="https://termii.com/api/sms/send",i=()=>{const e=`Kindly visit ${o} to get your api key`;"undefined"!=typeof window?alert(e):console.log(e)};t.default=()=>{let e={type:"plain",media_url:"",api_key:"",notify_url:"",notify_id:""};return{setApi:t=>{e.api_key=t},send_sms:(t,n,r,p="generic")=>{""===e.api_key?i():fetch(o,{method:"POST",body:JSON.stringify({to:t,sms:n,from:r,...e,channel:p}),headers:{"Content-Type":"Application/json",Accept:"Application/json"}}).then(e=>e.json()).then(e=>e).catch(e=>e)},send_otp:(t,n,r="generic")=>{""===e.api_key?i():fetch(o+"/otp/send",{method:"POST",body:JSON.stringify({api_key:e.api_key,message_type:"NUMERIC",to:t,from:n,channel:r,pin_attempts:10,pin_time_to_live:5,pin_length:6,pin_placeholder:"< 1234 >",message_text:"Your pin is < 1234 >",pin_type:"NUMERIC"}),headers:{"Content-Type":"Application/json",Accept:"Application/json"}}).then(e=>e.json()).then(e=>e).catch(e=>e)},verify_otp:(t,n)=>{""===e.api_key?i():fetch(o+"/otp/verify",{method:"POST",body:JSON.stringify({api_key:e.api_key,pin_id:t,pin:n}),headers:{"Content-Type":"Application/json",Accept:"Application/json"}}).then(e=>e.json()).then(e=>e).catch(e=>e)}}}}])}));