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,26 +5,29 @@ 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=" +
return true; this.variables.SMS_FACTOR_TOKEN,
{},
}) )
.catch(error => { .then((response) => {
console.error('Error sending Sms Factor SMS:', error.response.data); console.log("SMS sent successfully via Sms Factor:", response.status);
return false; return true;
}); })
return false; .catch((error) => {
} console.error("Error sending Sms Factor SMS:", error);
} return false;
});
return false;
}
}