Developer Hub
これは自動生成された翻訳です。

リンクの使い方

概要

Rapidは、旅行者向けにend-to-endの予約体験を構築するために組み合わせて使用される、いくつかのAPIリソースで構成されています。これらのリソースを順番に活用して、でのショッピング での価格確認での予約、そして最後に、での予約管理といった、一連のトランザクションを構築します

こうした複数のステップからなる取引を効率化するため、Rapidでは「リンク」と呼ばれる強力なツールを活用しています。

リンクとは、関連リソースへの参照であり、トランザクションを円滑に進めるために必要な次の関連APIリソースへと、開発者を導く指針としての役割を果たします。

リンクを活用することで、開発者は通常のセットアッププロセスを省略し、新しい操作を迅速に作成・実行できるため、効率が大幅に向上します。

Information

注意

この機能は、rapid-sdk v5.1.0以降でご利用いただけます。

リンクを利用するメリット

リンクを使用すると、Rapid APIの操作間を、次の操作を手動で作成することなく、手軽に移動することができます。リンクは、各レスポンスの「links」セクションで定義されています。前の操作の応答からリンクを抽出し、それを使って次の操作を作成することができます。

リンクを使用すると、次のようなメリットがあります:

  • 時間の節約: リクエストパラメータや操作を設定して、次の操作を手動で作成する必要がなくなります。
  • プロセスを簡略化します: 必要な情報を手動で抽出する必要がなく、前の操作からのリンクを使用して、Rapid APIの操作を簡単に進めることができます。
  • エラーの削減: リンクを使用することで、手動で次の chase 操作を作成する際に発生しうるエラーを回避できます。

リンクの使い方について

操作の応答では、返された「links」セクションを探し、そのリンクを使用して、次に適切な操作を構築してください。 その後、operation から次のlink を作成し、RapidClient で実行することができます。

たとえば、PriceCheckOperationLink のレスポンスから GetAvailabilityOperation を作成して、以下のように PriceCheckOperation の作成に使用することができます。

// 1. Create and execute the GetAvailabilityOperation (The first operation)
GetAvailabilityOperation getAvailabilityOperation = new GetAvailabilityOperation(getAvailabilityOperationParams);
Response<List<Property>> propertiesResponse = rapidClient.execute(getAvailabilityOperation);

// 2a. Select the needed property from the response (Here, we select the first property)
Property property = propertiesResponse.getData().get(0);

// 2b. Make sure the property is an instance of PropertyAvailability
if (!(property instanceof PropertyAvailability)) {
    return;
}

PropertyAvailability propertyAvailability = (PropertyAvailability) property;

// 3a. Extract the PriceCheckOperationLink from PropertyAvailability operation (Here, we select the first rate for the first room, then get the PriceCheckOperationLink)
PriceCheckOperationLink priceCheckLink = propertyAvailability.getRooms().get(0).getRates().get(0).getBedGroups().entrySet().stream().findFirst().get().getValue().getLinks().getPriceCheck();

// 3b. Create the needed context for the PriceCheckOperation
PriceCheckOperationContext priceCheckOperationContext = PriceCheckOperationContext.builder().customerIp("1.2.3.4").build(); // fill the context as needed

// 4. Create and execute the PriceCheckOperation using the Link
PriceCheckOperation priceCheckOperation = new PriceCheckOperation(priceCheckLink, priceCheckOperationContext);
Response<RoomPriceCheck> roomPriceCheckResponse = rapidClient.execute(priceCheckOperation);
// ...

別の例としては、PriceCheckOperation のレスポンスから PostItineraryOperationLink を作成し、予約の作成に使用することもできます。

// 1. Get the RoomPriceCheck from the previous step
RoomPriceCheck roomPriceCheck = roomPriceCheckResponse.getData(); // from the previous step

// 2a. Extract the Link from the RoomPriceCheck
PostItineraryOperationLink postItineraryLink = roomPriceCheck.getLinks().getBook();

// 2b. Create the needed context for the PostItineraryOperation
PostItineraryOperationContext postItineraryOperationContext = PostItineraryOperationContext.builder().customerIp("1.2.3.4").build(); // fill the context as needed

// 2c. Create the CreateItineraryRequest
CreateItineraryRequest createItineraryRequest = CreateItineraryRequest.builder().build(); // fill the request as needed

// 3. Create and execute the PostItineraryOperation using the Link
PostItineraryOperation postItineraryOperation = new PostItineraryOperation(postItineraryLink, postItineraryOperationContext, createItineraryRequest);

// 4. Execute the PostItineraryOperation
Response<ItineraryCreation> itineraryCreationResponse = rapidClient.execute(postItineraryOperation);
ItineraryCreation itineraryCreation = itineraryCreationResponse.getData();

>> その他の使用例を見る

このページは役に立ちましたか ?
このコンテンツに改善が必要な点があれば、
サービス向上にご協力いただきありがとうございます。