diff --git a/controllers/ControlCenter.js b/controllers/ControlCenter.js index 5582af6..914da10 100644 --- a/controllers/ControlCenter.js +++ b/controllers/ControlCenter.js @@ -6,14 +6,18 @@ import { ITEM_NAME, CAT_ATTR_TAG_RELATIONS, STRAPI_TOURISM_TOKEN, + NEW_CATALOG_AVAILABLE, + TRIGGER_BLIZZARD_MESSAGE, + CANCEL_BOOKING_MESSAGE } from '../utils/constants.js' + const action = new Actions() const TOURISM_STRAPI_URL = process.env.TOURISM_STRAPI_URL || '' const TWILIO_RECEPIENT_NUMBER = process.env.TOURISM_STRAPI_URL export const cancelBookingController = async (req, res) => { try { - const { messageBody, orderId } = req.body - console.log(orderId) + const { orderId } = req.body + const messageBody = CANCEL_BOOKING_MESSAGE; const getOrderFulfillmentDetails = await axios.get( `${TOURISM_STRAPI_URL}/order-fulfillments?order_id=${orderId}`, { @@ -51,6 +55,7 @@ export const cancelBookingController = async (req, res) => { export const updateCatalog = async (req, res) => { try { + const messageBody = NEW_CATALOG_AVAILABLE; await axios.put( `${TOURISM_STRAPI_URL}/items/${ITEM_ID}`, { @@ -72,3 +77,18 @@ export const updateCatalog = async (req, res) => { return res.send({ message: error.message }) } } + + +export const notificationController = async (req, res) => { + try { + const messageBody = TRIGGER_BLIZZARD_MESSAGE; + const sendWhatsappNotificationResponse = await action.send_message( + TWILIO_RECEPIENT_NUMBER, + messageBody + ) + return res.send(sendWhatsappNotificationResponse) + } catch (error) { + logger.error(error.message) + return res.send({ message: error.message }) + } +} \ No newline at end of file diff --git a/controllers/Notification.js b/controllers/Notification.js deleted file mode 100644 index 66fb16d..0000000 --- a/controllers/Notification.js +++ /dev/null @@ -1,17 +0,0 @@ -import Actions from '../services/Actions.js' -import logger from '../utils/logger.js' -const action = new Actions() -const TWILIO_RECEPIENT_NUMBER = process.env.TOURISM_STRAPI_URL -export const notificationController = async (req, res) => { - try { - const { messageBody } = req.body - const sendWhatsappNotificationResponse = await action.send_message( - TWILIO_RECEPIENT_NUMBER, - messageBody - ) - return res.send(sendWhatsappNotificationResponse) - } catch (error) { - logger.error(error.message) - return res.send({ message: error.message }) - } -} diff --git a/utils/constants.js b/utils/constants.js index 761136b..af20826 100644 --- a/utils/constants.js +++ b/utils/constants.js @@ -5,3 +5,7 @@ export const ITEM_ID = '4' export const ITEM_NAME = 'Ticket Pass-Mueseum' export const CAT_ATTR_TAG_RELATIONS = [2, 3, 4, 5] +export const TRIGGER_BLIZZARD_MESSAGE = "Hey, Triggering a Blizzard"; +export const CANCEL_BOOKING_MESSAGE = `Dear Guest,\n\nApologies, but your hotel booking with us has been canceled due to unforeseen circumstances. \nWe understand the inconvenience and are here to assist you with any alternative arrangements needed. \n\nPlease contact us for further assistance.`; +export const NEW_CATALOG_AVAILABLE = `Dear Guest,\n\n Checkout this new place to visit.` +