Tarun Singh
3 years ago
29 changed files with 394 additions and 286 deletions
@ -0,0 +1,43 @@ |
|||
const NotificationProvider = require("./notification-provider"); |
|||
const axios = require("axios"); |
|||
|
|||
class ClickSendSMS extends NotificationProvider { |
|||
|
|||
name = "clicksendsms"; |
|||
|
|||
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { |
|||
let okMsg = "Sent Successfully."; |
|||
try { |
|||
console.log({ notification }); |
|||
let config = { |
|||
headers: { |
|||
"Content-Type": "application/json", |
|||
"Authorization": "Basic " + Buffer.from(notification.clicksendsmsLogin + ":" + notification.clicksendsmsPassword).toString('base64'), |
|||
"Accept": "text/json", |
|||
} |
|||
}; |
|||
let data = { |
|||
messages: [ |
|||
{ |
|||
"body": msg.replace(/[^\x00-\x7F]/g, ""), |
|||
// TODO: To phone number concept to be added
|
|||
"to": "+61411111111", |
|||
"source": "uptime-kuma", |
|||
"from": notification.clicksendsmsSenderName, |
|||
} |
|||
] |
|||
}; |
|||
let resp = await axios.post("https://rest.clicksend.com/v3/sms/send", data, config); |
|||
if (resp.data.http_code !== 200) { |
|||
let error = "Something gone wrong. Api returned " + resp.data.response.status + "."; |
|||
this.throwGeneralAxiosError(error); |
|||
} |
|||
|
|||
return okMsg; |
|||
} catch (error) { |
|||
this.throwGeneralAxiosError(error); |
|||
} |
|||
} |
|||
} |
|||
|
|||
module.exports = ClickSendSMS; |
@ -0,0 +1,35 @@ |
|||
<template> |
|||
<div class="mb-3"> |
|||
<label for="clicksendsms-login" class="form-label">API Username</label> |
|||
<div class="form-text"> |
|||
{{ $t("apiCredentials") }} |
|||
<a href="http://dashboard.clicksend.com/account/subaccounts" target="_blank">here</a> |
|||
</div> |
|||
<input id="clicksendsms-login" v-model="$parent.notification.clicksendsmsLogin" type="text" class="form-control" required> |
|||
<label for="clicksendsms-key" class="form-label">API Key</label> |
|||
<HiddenInput id="clicksendsms-key" v-model="$parent.notification.clicksendsmsPassword" :required="true" autocomplete="one-time-code"></HiddenInput> |
|||
</div> |
|||
<div class="mb-3"> |
|||
<div class="form-text"> |
|||
{{ $t("checkPrice", [$t("clicksendsms")]) }} |
|||
<a href="https://www.clicksend.com/us/pricing" target="_blank">here</a> |
|||
</div> |
|||
</div> |
|||
<div class="mb-3"> |
|||
<label for="clicksendsms-sender-name" class="form-label">From Name/Number - |
|||
<a href="https://help.clicksend.com/article/4kgj7krx00-what-is-a-sender-id-or-sender-number" target="_blank">More Info</a> |
|||
</label> |
|||
<input id="clicksendsms-sender-name" v-model="$parent.notification.clicksendsmsSenderName" type="text" minlength="3" maxlength="11" class="form-control"> |
|||
<div class="form-text">Leave blank to use a shared sender number.</div> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import HiddenInput from "../HiddenInput.vue"; |
|||
|
|||
export default { |
|||
components: { |
|||
HiddenInput, |
|||
}, |
|||
}; |
|||
</script> |
Loading…
Reference in new issue