32 lines
736 B
TypeScript
32 lines
736 B
TypeScript
import { BackendVariables } from "@Common/config/variables/Variables";
|
|
import BaseService from "@Services/BaseService";
|
|
import { Service } from "typedi";
|
|
import axios from "axios";
|
|
|
|
@Service()
|
|
export default class SmsFactorService extends BaseService {
|
|
constructor(private variables: BackendVariables) {
|
|
super();
|
|
}
|
|
|
|
public async sendSms(phoneNumber: string, message: string){
|
|
axios
|
|
.get(
|
|
"https://api.smsfactor.com/send/simulate?to=" +
|
|
phoneNumber +
|
|
"&sender=LeCoffre&text=" +
|
|
message +
|
|
"&token=" +
|
|
this.variables.SMS_FACTOR_TOKEN,
|
|
{},
|
|
)
|
|
.then((response) => {
|
|
return true;
|
|
})
|
|
.catch((error) => {
|
|
console.error("Error sending Sms Factor SMS");
|
|
return false;
|
|
});
|
|
}
|
|
}
|