|
|
@ -9,27 +9,53 @@ class Octopush extends NotificationProvider {
|
|
|
|
let okMsg = "Sent Successfully. ";
|
|
|
|
let okMsg = "Sent Successfully. ";
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
let config = {
|
|
|
|
// Default - V2
|
|
|
|
headers: {
|
|
|
|
if (notification.octopushVersion == 2 || !notification.octopushVersion)
|
|
|
|
"api-key": notification.octopushAPIKey,
|
|
|
|
{
|
|
|
|
"api-login": notification.octopushLogin,
|
|
|
|
let config = {
|
|
|
|
"cache-control": "no-cache"
|
|
|
|
headers: {
|
|
|
|
}
|
|
|
|
"api-key": notification.octopushAPIKey,
|
|
|
|
};
|
|
|
|
"api-login": notification.octopushLogin,
|
|
|
|
let data = {
|
|
|
|
"cache-control": "no-cache"
|
|
|
|
"recipients": [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"phone_number": notification.octopushPhoneNumber
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
};
|
|
|
|
//octopush not supporting non ascii char
|
|
|
|
let data = {
|
|
|
|
"text": msg.replace(/[^\x00-\x7F]/g, ""),
|
|
|
|
"recipients": [
|
|
|
|
"type": notification.octopushSMSType,
|
|
|
|
{
|
|
|
|
"purpose": "alert",
|
|
|
|
"phone_number": notification.octopushPhoneNumber
|
|
|
|
"sender": notification.octopushSenderName
|
|
|
|
}
|
|
|
|
};
|
|
|
|
],
|
|
|
|
|
|
|
|
//octopush not supporting non ascii char
|
|
|
|
|
|
|
|
"text": msg.replace(/[^\x00-\x7F]/g, ""),
|
|
|
|
|
|
|
|
"type": notification.octopushSMSType,
|
|
|
|
|
|
|
|
"purpose": "alert",
|
|
|
|
|
|
|
|
"sender": notification.octopushSenderName
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
await axios.post("https://api.octopush.com/v1/public/sms-campaign/send", data, config)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (notification.octopushVersion == 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let data = {
|
|
|
|
|
|
|
|
"user_login": notification.octopushDMLogin,
|
|
|
|
|
|
|
|
"api_key": notification.octopushDMAPIKey,
|
|
|
|
|
|
|
|
"sms_recipients" : notification.octopushDMPhoneNumber,
|
|
|
|
|
|
|
|
"sms_sender": notification.octopushDMSenderName,
|
|
|
|
|
|
|
|
"sms_type": (notification.octopushDMSMSType == 'sms_premium')?'FR':'XXX',
|
|
|
|
|
|
|
|
"transactional": '1',
|
|
|
|
|
|
|
|
//octopush not supporting non ascii char
|
|
|
|
|
|
|
|
"sms_text": msg.replace(/[^\x00-\x7F]/g, ""),
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let config = {
|
|
|
|
|
|
|
|
headers: {
|
|
|
|
|
|
|
|
"cache-control": "no-cache"
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
params: data
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
await axios.post("https://www.octopush-dm.com/api/sms/json", {}, config)
|
|
|
|
|
|
|
|
} else
|
|
|
|
|
|
|
|
throw new Error('Unknown Octopush version !');
|
|
|
|
|
|
|
|
|
|
|
|
await axios.post("https://api.octopush.com/v1/public/sms-campaign/send", data, config)
|
|
|
|
|
|
|
|
return okMsg;
|
|
|
|
return okMsg;
|
|
|
|
} catch (error) {
|
|
|
|
} catch (error) {
|
|
|
|
this.throwGeneralAxiosError(error);
|
|
|
|
this.throwGeneralAxiosError(error);
|
|
|
|