Retención y reanudación de reservas
La función de "retener y reanudar" de Rapid te permite admitir un modelo de reserva en dos pasos.
Accede a este enlace para consultar más información sobre la función de "retener y reanudar".
1. Compra
Consulta la disponibilidad
GetAvailabilityOperationParams getAvailabilityOperationParams = GetAvailabilityOperationParams.builder()
.checkin("YYYY-MM-DD")
.checkout("YYYY-MM-DD")
.currency("USD")
.language("en_US")
.countryCode("US")
.occupancy(List.of("OCCUPANCY"))
.propertyId(List.of("PROPERTY ID"))
.customerIp("127.0.0.1")
.ratePlanCount(BigDecimal.ONE)
.salesChannel("SALES CHANNEL")
.salesEnvironment("SALES ENVIRONMENT")
.build();
GetAvailabilityOperation getAvailabilityOperation = new GetAvailabilityOperation(getAvailabilityOperationParams);
Response<List<Property>> propertiesResponse = rapidClient.execute(getAvailabilityOperation);
Consulta los precios de las habitaciones
Property property = propertiesResponse.getData().get(0);
if (!(property instanceof PropertyAvailability)) {
return;
}
PropertyAvailability propertyAvailability = (PropertyAvailability) property;
Link propertyAvailabilityLink = propertyAvailability.getRooms().get(0).getRates().get(0).getBedGroups().entrySet().stream().findFirst().get().getValue().getLinks().getPriceCheck(); // selecting the first rate for the first room
PriceCheckOperationContext priceCheckOperationContext = PriceCheckOperationContext.builder().customerIp("1.2.3.4").customerSessionId("12345").build(); // fill the context as needed
PriceCheckOperation priceCheckOperation = new PriceCheckOperation(propertyAvailabilityLink, priceCheckOperationContext);
Response<RoomPriceCheck> response = rapidClient.execute(priceCheckOperation);
RoomPriceCheck roomPriceCheck = response.getData();
2. Reserva
Crea un itinerario
Link postItineraryLink = roomPriceCheck.getLinks().getBook(); // from the previous step
PostItineraryOperationContext postItineraryOperationContext = PostItineraryOperationContext.builder().customerIp("1.2.3.4").customerSessionId("12345").build(); // fill the context as needed
PostItineraryOperation itineraryCreationOperation = new PostItineraryOperation(postItineraryLink, postItineraryOperationContext, createItineraryRequest(true));
Response<ItineraryCreation> response = rapidClient.execute(itineraryCreationOperation);
ItineraryCreation itineraryCreation = response.getData();
Reanuda la reserva retenida
Link resumeBookingLink = itineraryCreation.getLinks().getResume(); // from the previous step
PutResumeBookingOperationContext putResumeBookingOperationContext = PutResumeBookingOperationContext.builder().customerIp("1.2.3.4").customerSessionId("12345").build(); // fill the context as needed
PutResumeBookingOperation itineraryResumeOperation = new PutResumeBookingOperation(resumeBookingLink, putResumeBookingOperationContext);
rapidClient.execute(itineraryResumeOperation);