Sms factor done in simulate mode

This commit is contained in:
Vins 2023-12-04 03:07:56 +01:00
parent 869a30fac0
commit 70845595df

View File

@ -5,24 +5,27 @@ import axios from "axios";
@Service() @Service()
export default class SmsFactorService extends BaseService { export default class SmsFactorService extends BaseService {
constructor(private variables: BackendVariables) { constructor(private variables: BackendVariables) {
super(); super();
} }
public async sendSms(phoneNumber: string, message: string): Promise<boolean> { public async sendSms(phoneNumber: string, message: string): Promise<boolean> {
axios.post('https://api.smsfactor.com/send/', { axios
token: this.variables.SMS_FACTOR_TOKEN, .get(
sender: "LeCoffre", "https://api.smsfactor.com/send/simulate?to=" +
to: phoneNumber, phoneNumber +
text: message, "&sender=LeCoffre&text=" +
}).then(response => { message +
console.log('SMS sent successfully via Sms Factor :', response.data); "token=" +
this.variables.SMS_FACTOR_TOKEN,
{},
)
.then((response) => {
console.log("SMS sent successfully via Sms Factor:", response.status);
return true; return true;
}) })
.catch(error => { .catch((error) => {
console.error('Error sending Sms Factor SMS:', error.response.data); console.error("Error sending Sms Factor SMS:", error);
return false; return false;
}); });
return false; return false;