Merged in feat/SW-1090-amenities-meetings-sidepeeks (pull request #1114)
Feat/SW-1090: Sidepeek amenities and meetings Approved-by: Erik Tiekstra Approved-by: Fredrik Thorsson
This commit is contained in:
@@ -21,6 +21,7 @@ import {
|
||||
getHotelDataInputSchema,
|
||||
getHotelsAvailabilityInputSchema,
|
||||
getHotelsInput,
|
||||
getMeetingRoomsInputSchema,
|
||||
getRatesInputSchema,
|
||||
getRoomPackagesInputSchema,
|
||||
getRoomsAvailabilityInputSchema,
|
||||
@@ -31,6 +32,7 @@ import {
|
||||
breakfastPackagesSchema,
|
||||
getHotelDataSchema,
|
||||
getHotelsAvailabilitySchema,
|
||||
getMeetingRoomsSchema,
|
||||
getRatesSchema,
|
||||
getRoomPackagesSchema,
|
||||
getRoomsAvailabilitySchema,
|
||||
@@ -51,6 +53,9 @@ import {
|
||||
hotelsAvailabilityCounter,
|
||||
hotelsAvailabilityFailCounter,
|
||||
hotelsAvailabilitySuccessCounter,
|
||||
meetingRoomsCounter,
|
||||
meetingRoomsFailCounter,
|
||||
meetingRoomsSuccessCounter,
|
||||
roomsAvailabilityCounter,
|
||||
roomsAvailabilityFailCounter,
|
||||
roomsAvailabilitySuccessCounter,
|
||||
@@ -1168,4 +1173,82 @@ export const hotelQueryRouter = router({
|
||||
return location
|
||||
}),
|
||||
}),
|
||||
meetingRooms: safeProtectedServiceProcedure
|
||||
.input(getMeetingRoomsInputSchema)
|
||||
.query(async function ({ ctx, input }) {
|
||||
const { hotelId, language } = input
|
||||
|
||||
const params: Record<string, string | string[]> = {
|
||||
hotelId,
|
||||
language,
|
||||
}
|
||||
const metricsData = { ...params, hotelId: input.hotelId }
|
||||
meetingRoomsCounter.add(1, metricsData)
|
||||
console.info(
|
||||
"api.hotels.meetingRooms start",
|
||||
JSON.stringify({ query: { hotelId, params } })
|
||||
)
|
||||
|
||||
const apiResponse = await api.get(
|
||||
api.endpoints.v1.Hotel.Hotels.meetingRooms(input.hotelId),
|
||||
{
|
||||
cache: undefined,
|
||||
headers: {
|
||||
Authorization: `Bearer ${ctx.serviceToken}`,
|
||||
},
|
||||
next: {
|
||||
revalidate: TWENTYFOUR_HOURS,
|
||||
},
|
||||
},
|
||||
params
|
||||
)
|
||||
|
||||
if (!apiResponse.ok) {
|
||||
const text = await apiResponse.text()
|
||||
meetingRoomsFailCounter.add(1, {
|
||||
...metricsData,
|
||||
error_type: "http_error",
|
||||
error: JSON.stringify({
|
||||
status: apiResponse.status,
|
||||
statusText: apiResponse.statusText,
|
||||
text,
|
||||
}),
|
||||
})
|
||||
console.error(
|
||||
"api.hotels.meetingRooms error",
|
||||
JSON.stringify({
|
||||
query: { params },
|
||||
error: {
|
||||
status: apiResponse.status,
|
||||
statusText: apiResponse.statusText,
|
||||
text,
|
||||
},
|
||||
})
|
||||
)
|
||||
return null
|
||||
}
|
||||
|
||||
const apiJson = await apiResponse.json()
|
||||
const validatedMeetingRooms = getMeetingRoomsSchema.safeParse(apiJson)
|
||||
|
||||
if (!validatedMeetingRooms.success) {
|
||||
console.error(
|
||||
"api.hotels.meetingRooms validation error",
|
||||
JSON.stringify({
|
||||
query: { params },
|
||||
error: validatedMeetingRooms.error,
|
||||
})
|
||||
)
|
||||
throw badRequestError()
|
||||
}
|
||||
meetingRoomsSuccessCounter.add(1, {
|
||||
hotelId,
|
||||
})
|
||||
console.info(
|
||||
"api.hotels.meetingRooms success",
|
||||
JSON.stringify({ query: { params } })
|
||||
)
|
||||
|
||||
return validatedMeetingRooms.data.data
|
||||
}),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user