S3 : add news
This commit is contained in:
+12
-7
@@ -1,18 +1,24 @@
|
||||
const axios = require("axios");
|
||||
|
||||
const SMS_API_KEY = "QkkNxhyXZ6GtEf1soOTtikomO3mA4LaNQDH8mol8huDIwh00";
|
||||
|
||||
module.exports.sms = async (phoneNumber, message) => {
|
||||
const smsService = new SmsService("QkkNxhyXZ6GtEf1soOTtikomO3mA4LaNQDH8mol8huDIwh00");
|
||||
const smsService = new SmsService(SMS_API_KEY);
|
||||
return smsService.sendMessage(phoneNumber, message);
|
||||
};
|
||||
|
||||
/** Sends login/verification OTP via sms.ir template (verify endpoint). */
|
||||
module.exports.sendOtpSms = async (phoneNumber, otp) => {
|
||||
const smsService = new SmsService(SMS_API_KEY);
|
||||
return smsService.sendOTPSms(otp, phoneNumber);
|
||||
};
|
||||
|
||||
class SmsService {
|
||||
constructor(apiKey) {
|
||||
this.API_URL = "https://api.sms.ir/v1";
|
||||
this.OTP_PATTERN = "83604";
|
||||
this.OTP_PATTERN = "628767";
|
||||
this.SMS_API_KEY = apiKey;
|
||||
}
|
||||
//******************************** */
|
||||
|
||||
//******************************** */
|
||||
|
||||
async sendMessage(phone, message) {
|
||||
try {
|
||||
@@ -32,7 +38,7 @@ class SmsService {
|
||||
console.error("Error in sending SMS", error);
|
||||
}
|
||||
}
|
||||
//******************************** */
|
||||
|
||||
async getLineNumber() {
|
||||
try {
|
||||
const { data } = await axios.get(`${this.API_URL}/line`, {
|
||||
@@ -45,7 +51,6 @@ class SmsService {
|
||||
console.error("Error in getting line number", error);
|
||||
}
|
||||
}
|
||||
//******************************** */
|
||||
|
||||
async sendOTPSms(otp, phone) {
|
||||
const smsData = {
|
||||
|
||||
Reference in New Issue
Block a user