This is an auto-generated translation

リンクの使用

概要

Rapidは、旅行者のためのエンドツーエンドの予約体験を作成するために一緒に使用されるいくつかのAPIリソースで構成されています。 旅行者これらのリソースを順番に使用して、完全なトランザクションを構築します。例えば、ショッピング 価格チェック予約 、そして最後に予約管理

このような多段階の取引を合理化するために、Rapidはリンクと呼ばれる強力なツールを使用しています。

リンクは関連リソースへの参照であり、トランザクションをシームレスに進めるために必要な次の関連APIリソースへ開発者を導くガイドとして機能します。 リソースに誘導するガイドの役割を果たします。

リンクを活用することで、開発者は新しいオペレーションを迅速に作成・実行することができ、一般的なセットアッププロセスを回避し、効率を大幅に向上させることができます。

Information

注意

この機能は、rapid-sdk v5.1.0以降で利用可能です。

リンクを使うメリット

リンクは、次の操作を手動で作成することなく Rapid API 操作をナビゲートする便利な方法です。 操作に移動する便利な方法です。リンクは、各回答のlinks セクションで定義されています。前の操作のレスポンスからリンクを抽出し、次の操作の作成に使用することができます。

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

  • 時間を節約 : リクエスト パラメーターとオペレーションを設定することで、次のオペレーションを手動で作成する必要がありません。
  • プロセスを簡素化します: 前の操作からのリンクを使用して、Rapid API 操作を簡単にナビゲートできます。 必要な情報を手動で抽出する必要がありません。
  • エラーを減らします: リンクを使用することで、手動で次の操作を作成する際に発生する可能性のあるエラーを回避できます。 を手動で作成する際に発生する可能性のあるエラーを回避できます。

リンクの使い方は?

オペレーションのレスポンスで、返された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();

リンクの使用例については、使用例 セクションを参照してください。

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