-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add gtx messaging Notification Provider
- Loading branch information
1 parent
0e7ef54
commit ac109d0
Showing
6 changed files
with
79 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const NotificationProvider = require("./notification-provider"); | ||
const axios = require("axios"); | ||
|
||
class GtxMessaging extends NotificationProvider { | ||
name = "gtxmessaging"; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { | ||
const okMsg = "Sent Successfully."; | ||
|
||
let authKey = notification.gtxMessagingApiKey; | ||
let from = notification.gtxMessagingFrom.trim(); | ||
let to = notification.gtxMessagingTo.trim(); | ||
let text = msg.replaceAll("🔴 ", "").replaceAll("✅ ", ""); | ||
|
||
try { | ||
|
||
let data = new URLSearchParams(); | ||
data.append("from", from); | ||
data.append("to", to); | ||
data.append("text", text); | ||
|
||
let url = `https://rest.gtx-messaging.net/smsc/sendsms/${authKey}/json`; | ||
|
||
console.log(`will post url: ${url}, data:`, data); | ||
|
||
await axios.post(url, data); | ||
|
||
return okMsg; | ||
} catch (error) { | ||
this.throwGeneralAxiosError(error); | ||
} | ||
} | ||
} | ||
|
||
module.exports = GtxMessaging; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<template> | ||
<div class="mb-3"> | ||
<label for="gtxmessaging-api-key" class="form-label">{{ $t("gtxMessagingApiKey") }}</label> | ||
<HiddenInput id="gtxmessaging-api-key" v-model="$parent.notification.gtxMessagingApiKey" :required="true"></HiddenInput> | ||
</div> | ||
<div class="mb-3"> | ||
<label for="gtxmessaging-from" class="form-label">{{ $t("gtxMessagingFrom") }}</label> | ||
<input id="gtxmessaging-from" v-model="$parent.notification.gtxMessagingFrom" type="text" class="form-control" required> | ||
</div> | ||
<div class="mb-3"> | ||
<label for="gtxmessaging-to" class="form-label">{{ $t("gtxMessagingTo") }}</label> | ||
<input id="gtxmessaging-to" v-model="$parent.notification.gtxMessagingTo" type="text" pattern="^[\d-]{10,31}(@[\w\.]{1,})?$" class="form-control" required> | ||
</div> | ||
<div class="mb-3"> | ||
<i18n-t tag="p" keypath="More info on:" style="margin-top: 8px;"> | ||
<a href="https://www.gtx-messaging.com/en/solutions/sms-gateway-api/" target="_blank">https://www.gtx-messaging.com/en/solutions/sms-gateway-api/</a> | ||
</i18n-t> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import HiddenInput from "../HiddenInput.vue"; | ||
export default { | ||
components: { | ||
HiddenInput | ||
} | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters