Merged in fix/SW-3199-prod-users-are-displayed-with- (pull request #2592)
fix(SW-3199): Fixed redemption search for alternative hotels * fix(SW-3199): Fixed redemption search for alternative hotels * fix(SW-3199): User points validation included Approved-by: Anton Gunnarsson
This commit is contained in:
@@ -796,7 +796,8 @@ export async function getHotelsAvailabilityByCity(
|
||||
export async function getHotelsAvailabilityByHotelIds(
|
||||
input: HotelsByHotelIdsAvailabilityInputSchema,
|
||||
apiLang: string,
|
||||
serviceToken: string
|
||||
token: string,
|
||||
userPoints: number = 0
|
||||
) {
|
||||
const {
|
||||
hotelIds,
|
||||
@@ -805,6 +806,7 @@ export async function getHotelsAvailabilityByHotelIds(
|
||||
adults,
|
||||
children,
|
||||
bookingCode,
|
||||
redemption,
|
||||
} = input
|
||||
|
||||
const params = new URLSearchParams([
|
||||
@@ -813,6 +815,7 @@ export async function getHotelsAvailabilityByHotelIds(
|
||||
["adults", adults.toString()],
|
||||
["children", children ?? ""],
|
||||
["bookingCode", bookingCode],
|
||||
["isRedemption", redemption.toString()],
|
||||
["language", apiLang],
|
||||
])
|
||||
|
||||
@@ -829,6 +832,7 @@ export async function getHotelsAvailabilityByHotelIds(
|
||||
adults,
|
||||
children,
|
||||
bookingCode,
|
||||
redemption,
|
||||
})
|
||||
|
||||
metricsGetHotelsAvailabilityByHotelIds.start()
|
||||
@@ -853,7 +857,7 @@ export async function getHotelsAvailabilityByHotelIds(
|
||||
api.endpoints.v1.Availability.hotels(),
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${serviceToken}`,
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
},
|
||||
params
|
||||
@@ -873,13 +877,21 @@ export async function getHotelsAvailabilityByHotelIds(
|
||||
throw badRequestError()
|
||||
}
|
||||
|
||||
if (redemption) {
|
||||
validateAvailabilityData.data.data.forEach((data) => {
|
||||
data.attributes.productType?.redemptions?.forEach((r) => {
|
||||
r.hasEnoughPoints = userPoints >= r.localPrice.pointsPerStay
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
availability: validateAvailabilityData.data.data.flatMap(
|
||||
(hotels) => hotels.attributes
|
||||
),
|
||||
}
|
||||
},
|
||||
env.CACHE_TIME_CITY_SEARCH
|
||||
redemption ? "no cache" : env.CACHE_TIME_CITY_SEARCH
|
||||
)
|
||||
|
||||
metricsGetHotelsAvailabilityByHotelIds.success()
|
||||
|
||||
Reference in New Issue
Block a user