即時預訂
這款模組化 API 能提供您和旅客完成旅宿預訂所需的所有資料點。
想進一步了解 Rapid API 的運作原理及其為合作夥伴提供的功能,請參閱這裡。
1. 購物
「購物 API」會針對指定旅宿傳回所有房型的房價和供應情況 (每項請求最多 250 家旅宿)。回應包含諸如促銷、房價是否為可退款、是否有取消費用和完整價格明細等房價詳情,以符合您市場的價格顯示規定。想進一步了解這項服務,請參閱這裡。
取得供應情況
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);
查看房價
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. 預訂
「預訂 API」可讓您預訂客房,且房型和房價已由價格檢查回應確認。想進一步了解 Rapid「預訂 API」,請參閱這裡。
建立行程
「預訂 API」的主要行程方式,會針對選取的旅宿、客房、房價和入住率建立預訂。要求當中會直接提供帳單/持卡人聯絡資訊等付款資訊。詳情請參閱這裡。
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(false));
Response<ItineraryCreation> response = rapidClient.execute(itineraryCreationOperation);
ItineraryCreation itineraryCreationResponse = response.getData();