Add support for multiple brands?
This commit is contained in:
parent
83ec4c0475
commit
02b6143f10
18
index.js
18
index.js
|
@ -312,7 +312,7 @@ client.on("interactionCreate", async (interaction) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
app.post("/api/v1/alert", (req, res) => {
|
app.post("/api/v1/alert", (req, res) => { // Legacy alert endpoint
|
||||||
console.log(req.body);
|
console.log(req.body);
|
||||||
// send no content response
|
// send no content response
|
||||||
sendAlert(req.body.accountNumber, req.body.transaction, req.body.placeName, req.body.systemName, req.body.zoneNumber, req.body.zoneName, req.body.event).then(() => {
|
sendAlert(req.body.accountNumber, req.body.transaction, req.body.placeName, req.body.systemName, req.body.zoneNumber, req.body.zoneName, req.body.event).then(() => {
|
||||||
|
@ -322,6 +322,22 @@ app.post("/api/v1/alert", (req, res) => {
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
|
app.post("/api/v1/webhook/:brand/:accountNumber", (req, res) => {
|
||||||
|
switch(req.params.brand) {
|
||||||
|
case "kca":
|
||||||
|
// send alert to accountNumber
|
||||||
|
sendAlert(req.params.accountNumber, req.body.transaction, req.body.placeName, req.body.systemName, req.body.zoneNumber, req.body.zoneName, req.body.event).then(() => {
|
||||||
|
res.status(204).send();
|
||||||
|
}).catch((error) => {
|
||||||
|
res.status(500).send();
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(400).send("Brand not found");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// sendAlert("6371787150", generateTransactionNumber(), "KCA Product Showcase", "Building Security", 1, "Front Door", "alarm");
|
// sendAlert("6371787150", generateTransactionNumber(), "KCA Product Showcase", "Building Security", 1, "Front Door", "alarm");
|
||||||
startTime = new Date();
|
startTime = new Date();
|
||||||
client.login(process.env.DISCORD_TOKEN);
|
client.login(process.env.DISCORD_TOKEN);
|
Loading…
Reference in a new issue