UNPKG

sms-ir-api

Version:

SMS.IR API client for JS/TS/ESM/Node.js

3 lines (2 loc) 2.07 kB
class e{constructor(e,i,t=null){return this.ApiKey=void 0,this.LineNumber=void 0,this.Username=void 0,this.ApiUrl="https://api.sms.ir/v1",this.ApiKey=e,this.LineNumber=i,this.Username=t,this}async Api(e,i="GET",t=undefined){const s=await fetch(`${this.ApiUrl}/${e}`,{headers:{Accept:"application/json","Content-Type":"application/json","X-API-KEY":this.ApiKey},method:i,body:t&&JSON.stringify(t)}),n=await s.json();return null==n?void 0:n.data}async Send(e,i,t=null,s=this.LineNumber){return this.SendBulk(e,[i],t,s)}async SendWithUsername(e,i,t=this.LineNumber,s=this.Username){return this.Api("send?"+new URLSearchParams({username:null!=s?s:"",password:this.ApiKey,line:""+t,mobile:i,text:e}),"GET")}async SendBulk(e,i,t=null,s=this.LineNumber){return this.Api("send/bulk","POST",{lineNumber:s,MessageText:e,Mobiles:i,SendDateTime:t})}async SendLikeToLike(e,i,t=null,s=this.LineNumber){return this.Api("send/likeToLike","POST",{lineNumber:s,MessageTexts:e,Mobiles:i,SendDateTime:t})}async DeleteScheduled(e){return this.Api(`send/scheduled/${e}`,"DELETE")}async SendVerifyCode(e,i,t){return this.Api("send/verify","POST",{Mobile:e,TemplateId:i,Parameters:t})}async ReportMessage(e){return this.Api(`send/${e}`)}async ReportTodayPacks(e=100,i=1){return this.Api("send/pack","GET",{pageSize:e,pageNumber:i})}async ReportPack(e){return this.Api(`send/pack/${e}`)}async ReportToday(e=100,i=1){return this.Api("send/live","GET",{pageSize:e,pageNumber:i})}async ReportArchived(e=null,i=null,t=100,s=1){return this.Api("send/archive","GET",{fromDate:e,toDate:i,pageSize:t,pageNumber:s})}async ReportLatestReceived(e=100){return this.Api("receive/latest","GET",{count:e})}async ReportTodayReceived(e=100,i=1){return this.Api("receive/live","GET",{pageSize:e,pageNumber:i})}async ReportArchivedReceived(e=null,i=null,t=100,s=1){return this.Api("receive/archive","GET",{fromDate:e,toDate:i,pageSize:t,pageNumber:s})}async GetCredit(){return this.Api("credit")}async GetLineNumbers(){return this.Api("line")}}export{e as Smsir,e as default}; //# sourceMappingURL=smsir.modern.js.map