Skip to content

Commit

Permalink
Added:Control Certer Backend APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyvishal committed Mar 29, 2024
1 parent 9319129 commit 547c043
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
24 changes: 22 additions & 2 deletions controllers/ControlCenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
{
Expand Down Expand Up @@ -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}`,
{
Expand All @@ -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 })
}
}
17 changes: 0 additions & 17 deletions controllers/Notification.js

This file was deleted.

4 changes: 4 additions & 0 deletions utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.`

0 comments on commit 547c043

Please sign in to comment.