This is an auto-generated translation

링크 사용

개요

Rapid는 다음과 같은 엔드투엔드 예약 환경을 만들기 위해 함께 사용되는 여러 API 리소스로 구성되어 있습니다. 여행자를 위한 이러한 리소스를 순차적으로 사용하여 완전한 거래를 구축합니다. 쇼핑, 가격 확인, 예약, 그리고 마지막으로 예약 관리.

이러한 다단계 트랜잭션을 간소화하기 위해 Rapid는 링크라는 강력한 도구를 사용합니다.

링크는 관련 리소스에 대한 참조로, 개발자가 트랜잭션을 원활하게 진행하는 데 필요한 다음 관련 API 리소스로 안내하는 가이드 역할을 합니다.

개발자는 링크를 활용하여 새로운 작업을 신속하게 생성하고 실행할 수 있으므로 일반적인 설정 프로세스를 생략하고 효율성을 크게 향상시킬 수 있습니다.

Information

참고

이 기능은 rapid-sdk v5.1.0 이상에서 사용할 수 있습니다.

링크 사용의 이점

링크는 다음 작업을 수동으로 만들지 않고도 Rapid API 작업을 탐색할 수 있는 편리한 방법입니다. 작업을 수동으로 만들지 않고도 편리하게 탐색할 수 있습니다. 링크는 각 응답의 links 섹션에 정의되어 있습니다. 이전 작업의 응답에서 링크를 추출하여 다음 작업을 만드는 데 사용할 수 있습니다.

링크를 사용하면 다음과 같은 이점이 있습니다:

  • 시간 절약: 요청 매개변수와 작업을 설정하여 다음 작업을 수동으로 생성할 필요가 없습니다.
  • 프로세스를 간소화합니다: 이전 작업의 링크를 사용하여 필요한 정보를 수동으로 추출할 필요 없이 이전 작업의 링크를 사용하여 필요한 정보를 수동으로 추출할 필요 없이 간편하게 탐색할 수 있습니다.
  • 오류를 줄입니다: 링크를 사용하면 다음 작업을 수동으로 만들 때 발생할 수 있는 오류를 방지할 수 있습니다. 작업을 수동으로 만들 때 발생할 수 있는 오류를 방지할 수 있습니다.

링크는 어떻게 사용하나요?

작업 응답에서 반환된 links 섹션을 찾은 다음 링크를 사용하여 다음 적합한 작업을 작성합니다. 그런 다음 operation 에서 다음 link 을 생성하고 RapidClient 로 실행할 수 있습니다.

예를 들어 GetAvailabilityOperation의 응답에서 PriceCheckOperationLink를 생성하고 이를 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();

링크 사용 방법에 대한 자세한 예는 사용 예 섹션을 참조하세요.

이 페이지가 도움이 되었나요?
이 콘텐츠를 어떻게 개선하면 좋을까요?
더 나은 Developer Hub를 만드는 데 도움을 주셔서 감사합니다!