一般的なワークフローの使用例
Regions
Regions API は指定されたパラメータに一致する地域の地理的定義と施設マッピングを返します。
応答は改ページ処理された地域のリストであり、SDK を使用して結果の追加ページをフェッチできます。このサービスの詳細については、the Geography API documentationを参照してください。
GetRegionsOperationParams regionsOperationParams = GetRegionsOperationParams
.builder()
.language("en_US")
.include(List.of("details"))
/* ... */
.build();
GetRegionsOperation getRegionsOperation = new GetRegionsOperation(regionsOperationParams);
List<List<Region>> pages = new ArrayList<>();
rapidClient.getPaginator(getRegionsOperation).forEachRemaining(page -> pages.add(page.getData()));
上の例では、pages
には全地域が含まれており、必要に応じて全地域に対する反復処理を行うことができます。 もう 1 つの選択肢は、forEachRemaining
ラムダ関数に必要な機能を直接埋め込むことです。
即時予約
モジュラー型 API により、貴社とお客様が宿泊施設の予約を完了するために必要なデータポイントがすべて提供されます。 Rapid API の仕組みとパートナーにとってのメリットについては、こちらを参照してください。
1. ショップ
指定した施設 (1 回のリクエストで最大 250 施設) のすべての客室タイプの料金と空室状況が Shop API から返されます。応答には、プロモーション、料金が払い戻し可能かどうか、キャンセル料金、該当する市場での料金表示条件を満たす完全な料金内訳など、料金に関する詳細が表示されます。このサービスの詳細については、こちらを参照してください。
空室状況を取得する
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;
PriceCheckOperationLink priceCheckOperationLink = 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(priceCheckOperationLink, priceCheckOperationContext);
Response<RoomPriceCheck> response = rapidClient.execute(priceCheckOperation);
RoomPriceCheck roomPriceCheck = response.getData();
2. 予約
Booking API を使用して、Price Check 応答で確定した料金で客室を予約できます。Rapid Booking APIの詳細については、the Booking documentationをご覧ください。
旅程を作成する
Booking API のプライマリ旅程メソッドで、選択した施設、客室、料金、客室利用人数の予約を作成します。請求先やカード所有者の連絡先などの支払い情報は、このリクエストに直接入力します。詳しくはこちらをご覧ください。
PostItineraryOperationLink postItineraryOperationLink = 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(postItineraryOperationLink, postItineraryOperationContext, createItineraryRequest(false));
Response<ItineraryCreation> response = rapidClient.execute(itineraryCreationOperation);
ItineraryCreation itineraryCreationResponse = response.getData();
予約の保留と再開
Rapid の保留と再開機能によって 2 段階の予約モデルに対応できます。 保留と再開の詳細については、こちらをご覧ください。
1. ショップ
空室状況を取得する
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;
PriceCheckOperationLink priceCheckOperationLink = 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(priceCheckOperationLink, priceCheckOperationContext);
Response<RoomPriceCheck> response = rapidClient.execute(priceCheckOperation);
RoomPriceCheck roomPriceCheck = response.getData();
2. 予約
旅程を作成する
PostItineraryOperationLink postItineraryOperationLink = 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(postItineraryOperationLink, postItineraryOperationContext, createItineraryRequest(true));
Response<ItineraryCreation> response = rapidClient.execute(itineraryCreationOperation);
ItineraryCreation itineraryCreation = response.getData();
保留予約を再開する
PutResumeBookingOperationLink putResumeBookingOperationLink = 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(putResumeBookingOperationLink, putResumeBookingOperationContext);
rapidClient.execute(itineraryResumeOperation);
欧州 PSD2 規制の遵守
SDK を使用すると、PSD2 EEA 規制への準拠が容易になります。 決済サービス指令 2 (PSD2) は EEA の規制であり、EEA 加盟国で発行されたクレジットカードが含まれるすべての取引について、支払いと予約のプロセスの変更が求められます。PSD2 の詳細についてはこちらを参照してください。
1. ショップ
空室状況を取得する
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;
PriceCheckOperationLink priceCheckOperationLink = propertyAvailability.getRooms().get(0).getRates().get(0).getBedGroups().entrySet().stream().findFirst().get().getValue().getLinks().getPriceCheck(); // selecting the first rate for the first room
PriceCheckOperation priceCheckOperation = new PriceCheckOperation(priceCheckOperationLink);
Response<RoomPriceCheck> response = rapidClient.execute(priceCheckOperation);
RoomPriceCheck roomPriceCheck = response.getData();
2. 予約
支払いセッションを作成する
PostPaymentSessionsOperationLink postPaymentSessionsOperationLink = roomPriceCheck.getLinks().getPaymentSession();
PostPaymentSessionsOperationContext postPaymentSessionsOperationContext = PostPaymentSessionsOperationContext.builder().customerIp("1.2.3.4").customerSessionId("12345").build(); // fill the context as needed
PostPaymentSessionsOperation paymentSessionsOperation = new PostPaymentSessionsOperation(postPaymentSessionsOperationLink, postPaymentSessionsOperationContext, createPaymentSessionRequest());
Response<PaymentSessions> paymentSessionsResponse = rapidClient.execute(paymentSessionsOperation);
PaymentSessions paymentSessions = paymentSessionsResponse.getData();
JavaScript チャレンジを渡す
2FA が必要な場合は、レスポンスには encodedChallengeConfig
も含まれます。返された encodedChallengeConfig
と paymentSessionId
を、JavaScript の challenge メソッドにパラメータとして渡す必要があります。
旅程を作成する
PostItineraryOperationLink postItineraryOperationLink = roomPriceCheck.getLinks().getBook(); // from the first step
PostItineraryOperationContext postItineraryOperationContext = PostItineraryOperationContext.builder().customerIp("1.2.3.4").customerSessionId("12345").build(); // fill the context as needed
PostItineraryOperation itineraryCreationOperation = new PostItineraryOperation(postItineraryOperationLink, postItineraryOperationContext, createItineraryRequest(true));
Response<ItineraryCreation> response = rapidClient.execute(itineraryCreationOperation);
ItineraryCreation itineraryCreation = response.getData();
支払いセッションを完了する
PutCompletePaymentSessionOperation putCompletePaymentSessionOperation = itineraryCreation.getLinks().getCompletePaymentSession();
PutCompletePaymentSessionOperationContext putCompletePaymentSessionOperationContext = PutCompletePaymentSessionOperationContext.builder().customerIp("1.2.3.4").customerSessionId("12345").build(); // fill the context as needed
PutCompletePaymentSessionOperation completePaymentSessionOperation = new PutCompletePaymentSessionOperation(putCompletePaymentSessionOperation, putCompletePaymentSessionOperationContext);
Response<CompletePaymentSession> completePaymentSessionResponse = rapidClient.execute(completePaymentSessionOperation);
CompletePaymentSession completePaymentSession = completePaymentSessionResponse.getData();
保留予約を再開する
PutResumeBookingOperationLink putResumeBookingOperationLink = itineraryCreation.getLinks().getResume();
PutResumeBookingOperationContext putResumeBookingOperationContext = PutResumeBookingOperationContext.builder().customerIp("1.2.3.4").customerSessionId("12345").build(); // fill the context as needed
PutResumeBookingOperation putResumeBookingOperation = new PutResumeBookingOperation(putResumeBookingOperationLink, putResumeBookingOperationContext);
rapidClient.execute(putResumeBookingOperation);