From 70460e5aba09ec02a99040c347cab0e3610f9c91 Mon Sep 17 00:00:00 2001 From: Fredrik Thorsson Date: Tue, 3 Sep 2024 17:12:45 +0200 Subject: [PATCH] feat(SW-176): add default values --- server/routers/hotels/input.ts | 8 ++++---- server/routers/hotels/output.ts | 4 ++-- server/routers/hotels/query.ts | 19 ++++++++++++++++++- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/server/routers/hotels/input.ts b/server/routers/hotels/input.ts index 2e35d0f1d..562a0e608 100644 --- a/server/routers/hotels/input.ts +++ b/server/routers/hotels/input.ts @@ -11,10 +11,10 @@ export const getAvailabilityInputSchema = z.object({ roomStayStartDate: z.string(), roomStayEndDate: z.string(), adults: z.number(), - children: z.number().optional(), - promotionCode: z.string().optional(), - reservationProfileType: z.string().optional(), - attachedProfileId: z.string().optional(), + children: z.number().optional().default(0), + promotionCode: z.string().optional().default(""), + reservationProfileType: z.string().optional().default(""), + attachedProfileId: z.string().optional().default(""), }) export const getRatesInputSchema = z.object({ diff --git a/server/routers/hotels/output.ts b/server/routers/hotels/output.ts index a652db503..7f059aefa 100644 --- a/server/routers/hotels/output.ts +++ b/server/routers/hotels/output.ts @@ -470,7 +470,7 @@ export const getHotelDataSchema = z.object({ const occupancySchema = z.object({ adults: z.number(), - children: z.number().optional(), + children: z.number(), }) const bestPricePerStaySchema = z.object({ @@ -512,7 +512,7 @@ const availabilitySchema = z.object({ attributes: z.object({ checkInDate: z.string(), checkOutDate: z.string(), - occupancy: occupancySchema, + occupancy: occupancySchema.optional(), status: z.string(), hotelId: z.number(), ratePlanSet: z.string().optional(), diff --git a/server/routers/hotels/query.ts b/server/routers/hotels/query.ts index f6bd0e098..731b08306 100644 --- a/server/routers/hotels/query.ts +++ b/server/routers/hotels/query.ts @@ -235,17 +235,25 @@ export const hotelQueryRouter = router({ reservationProfileType, attachedProfileId, } = input - // TODO: remove undefined type from params + const params: Record = { roomStayStartDate, roomStayEndDate, adults, + children, + promotionCode, + reservationProfileType, + attachedProfileId, } + availabilityCounter.add(1, { cityId, roomStayStartDate, roomStayEndDate, adults, + children, + promotionCode, + reservationProfileType, }) console.info( "api.hotels.availability start", @@ -267,6 +275,9 @@ export const hotelQueryRouter = router({ roomStayStartDate, roomStayEndDate, adults, + children, + promotionCode, + reservationProfileType, error_type: "http_error", error: JSON.stringify({ status: apiResponse.status, @@ -296,6 +307,9 @@ export const hotelQueryRouter = router({ roomStayStartDate, roomStayEndDate, adults, + children, + promotionCode, + reservationProfileType, error_type: "validation_error", error: JSON.stringify(validateAvailabilityData.error), }) @@ -313,6 +327,9 @@ export const hotelQueryRouter = router({ roomStayStartDate, roomStayEndDate, adults, + children, + promotionCode, + reservationProfileType, }) console.info( "api.hotels.availability success",