Skip to content

Commit cc10c23

Browse files
authored
fix: update okhttpclient and links pages after feedback (#253)
1 parent f662e7a commit cc10c23

File tree

6 files changed

+41
-44
lines changed

6 files changed

+41
-44
lines changed

docs/java/links.md

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
---
2-
intro: Introducing Links
3-
shortTitle: Introducing Links
4-
title: Introducing Links
2+
intro: Using Links
3+
shortTitle: Links
4+
title: Using Links
55
tags:
66
- new
77
---
88

9-
# Introducing Links
10-
11-
## What is a Link?
9+
# Using Links
1210

1311
RapidAPI consists of several API resources that enable you to create an end-to-end booking experience for your
1412
travelers.
@@ -27,10 +25,10 @@ operations, bypassing the typical setup process and significantly enhancing effi
2725
{% messageCardHeader %}
2826
Note
2927
{% /messageCardHeader %}
30-
This feature is available in the `rapid-sdk` v4.3.0 and later.
28+
This feature is available in the `rapid-sdk` v5.1.0 and later.
3129
{% /messageCard %}
3230

33-
## Why to use a Link?
31+
## Benefits of using Links
3432

3533
`Link` is a convenient way to navigate through the Rapid API operations, without having to manually create the next
3634
operation. You can extract a `Link` from the response of the previous operation and use it to create the next operation.
@@ -46,10 +44,10 @@ A link will benefit you in the following ways:
4644

4745
## How to use a Link?
4846

49-
To get a `Link`, you need to extract it from the previous `Operation` response.
47+
In an operation response, look for the returned links, use the link to build the next suitable operation.
5048
Then, you can create the next `Operation` from the `Link` and execute it with the `RapidClient`.
5149

52-
For example, you can create a `Link` from the response of a `GetAvailabilityOperation` and use it in creating
50+
For example, you can create a `PriceCheckOperationLink` from the response of a `GetAvailabilityOperation` and use it in creating
5351
a `PriceCheckOperation`:
5452

5553
```java
@@ -67,8 +65,8 @@ if (!(property instanceof PropertyAvailability)) {
6765

6866
PropertyAvailability propertyAvailability = (PropertyAvailability) property;
6967

70-
// 3a. Extract the priceCheck link from PropertyAvailability operation (Here, we select the first rate for the first room, then get the priceCheck link)
71-
Link priceCheckLink = propertyAvailability.getRooms().get(0).getRates().get(0).getBedGroups().entrySet().stream().findFirst().get().getValue().getLinks().getPriceCheck();
68+
// 3a. Extract the PriceCheckOperationLink from PropertyAvailability operation (Here, we select the first rate for the first room, then get the PriceCheckOperationLink)
69+
PriceCheckOperationLink priceCheckLink = propertyAvailability.getRooms().get(0).getRates().get(0).getBedGroups().entrySet().stream().findFirst().get().getValue().getLinks().getPriceCheck();
7270

7371
// 3b. Create the needed context for the PriceCheckOperation
7472
PriceCheckOperationContext priceCheckOperationContext = PriceCheckOperationContext.builder().customerIp("1.2.3.4").build(); // fill the context as needed
@@ -79,15 +77,15 @@ Response<RoomPriceCheck> roomPriceCheckResponse = rapidClient.execute(priceCheck
7977
// ...
8078
```
8179

82-
Another example would be to create a `Link` from the response of a `PriceCheckOperation` and use it in creating a
80+
Another example would be to create a `PostItineraryOperationLink` from the response of a `PriceCheckOperation` and use it in creating a
8381
booking.
8482

8583
```java
8684
// 1. Get the RoomPriceCheck from the previous step
8785
RoomPriceCheck roomPriceCheck = roomPriceCheckResponse.getData(); // from the previous step
8886

8987
// 2a. Extract the Link from the RoomPriceCheck
90-
Link postItineraryLink = roomPriceCheck.getLinks().getBook();
88+
PostItineraryOperationLink postItineraryLink = roomPriceCheck.getLinks().getBook();
9189

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

docs/java/okhttpclient.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
---
2-
intro: Introducing Configurable HTTP Client
3-
shortTitle: Introducing Configurable HTTP Client
4-
title: Introducing Configurable HTTP Client
2+
intro: Configurable HTTP Client
3+
shortTitle: Configurable HTTP Client
4+
title: Configurable HTTP Client
55
tags:
66
- new
77
---
88

9-
# Introducing Configurable HTTP Client
9+
# Configurable HTTP Client
1010

11-
The RAPID SDK is built on top of an OkHttpClient that is not open for you to configure and tune. Lately, we've come to
12-
realize your need to tune and optimize the HTTP client to your needs. So in order to give developers using the Rapid SDK
13-
more control over the underlying HTTP client of the SDK, we're introducing a new builder which you can use to pass your
14-
own HTTP client for the SDK to use internally.
11+
The SDK uses an underlying HTTP client to execute API calls. In order to give developers using the Rapid SDK
12+
more control over the HTTP client of the SDK, a builder is provided which you can use to pass your
13+
own HTTP client for the SDK to use.
1514

1615
Using this builder, you can build an HTTP client with your own configurations and pass it to the SDK, or even pass a
1716
client you're already using in your application.
@@ -51,9 +50,9 @@ For more information on configuring the `OkHttpClient`, refer to the [OkHttp doc
5150
#### 2. Pass the `OkHttpClient` instance to the `RapidClient` builder `builderWithHttpClient`
5251
```java
5352
RapidClient rapidClient = RapidClient.builderWithHttpClient()
53+
.okHttpClient(customClient)
5454
.key("YOUR_API_KEY")
5555
.secret("YOUR_API_SECRET")
56-
.okHttpClient(customClient)
5756
.build();
5857
```
5958

docs/java/quick-start.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@ For more information on configuring the `OkHttpClient`, refer to the [OkHttp doc
171171

172172
```java
173173
RapidClient rapidClient = RapidClient.builderWithHttpClient()
174+
.okHttpClient(customClient)
174175
.key("YOUR_API_KEY")
175176
.secret("YOUR_API_SECRET")
176-
.okHttpClient(customClient)
177177
.build();
178178
```
179179

docs/java/usage-examples/hold-resume-booking.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ if (!(property instanceof PropertyAvailability)) {
3939
}
4040

4141
PropertyAvailability propertyAvailability = (PropertyAvailability) property;
42-
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
42+
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
4343
PriceCheckOperationContext priceCheckOperationContext = PriceCheckOperationContext.builder().customerIp("1.2.3.4").customerSessionId("12345").build(); // fill the context as needed
44-
PriceCheckOperation priceCheckOperation = new PriceCheckOperation(propertyAvailabilityLink, priceCheckOperationContext);
44+
PriceCheckOperation priceCheckOperation = new PriceCheckOperation(priceCheckOperationLink, priceCheckOperationContext);
4545
Response<RoomPriceCheck> response = rapidClient.execute(priceCheckOperation);
4646
RoomPriceCheck roomPriceCheck = response.getData();
4747
```
@@ -121,17 +121,17 @@ CreateItineraryRequest createItineraryRequest(boolean hold) {
121121

122122
#### Create itinerary
123123
```java
124-
Link postItineraryLink = roomPriceCheck.getLinks().getBook(); // from the previous step
124+
PostItineraryOperationLink postItineraryOperationLink = roomPriceCheck.getLinks().getBook(); // from the previous step
125125
PostItineraryOperationContext postItineraryOperationContext = PostItineraryOperationContext.builder().customerIp("1.2.3.4").customerSessionId("12345").build(); // fill the context as needed
126-
PostItineraryOperation itineraryCreationOperation = new PostItineraryOperation(postItineraryLink, postItineraryOperationContext, createItineraryRequest(true));
126+
PostItineraryOperation itineraryCreationOperation = new PostItineraryOperation(postItineraryOperationLink, postItineraryOperationContext, createItineraryRequest(true));
127127
Response<ItineraryCreation> response = rapidClient.execute(itineraryCreationOperation);
128128
ItineraryCreation itineraryCreation = response.getData();
129129
```
130130

131131
#### Resume on-hold booking
132132
```java
133-
Link resumeBookingLink = itineraryCreation.getLinks().getResume(); // from the previous step
133+
PutResumeBookingOperationLink putResumeBookingOperationLink = itineraryCreation.getLinks().getResume(); // from the previous step
134134
PutResumeBookingOperationContext putResumeBookingOperationContext = PutResumeBookingOperationContext.builder().customerIp("1.2.3.4").customerSessionId("12345").build(); // fill the context as needed
135-
PutResumeBookingOperation itineraryResumeOperation = new PutResumeBookingOperation(resumeBookingLink, putResumeBookingOperationContext);
135+
PutResumeBookingOperation itineraryResumeOperation = new PutResumeBookingOperation(putResumeBookingOperationLink, putResumeBookingOperationContext);
136136
rapidClient.execute(itineraryResumeOperation);
137137
```

docs/java/usage-examples/instant-booking.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ if (!(property instanceof PropertyAvailability)) {
4242
}
4343

4444
PropertyAvailability propertyAvailability = (PropertyAvailability) property;
45-
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
45+
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
4646
PriceCheckOperationContext priceCheckOperationContext = PriceCheckOperationContext.builder().customerIp("1.2.3.4").customerSessionId("12345").build(); // fill the context as needed
47-
PriceCheckOperation priceCheckOperation = new PriceCheckOperation(propertyAvailabilityLink, priceCheckOperationContext);
47+
PriceCheckOperation priceCheckOperation = new PriceCheckOperation(priceCheckOperationLink, priceCheckOperationContext);
4848
Response<RoomPriceCheck> response = rapidClient.execute(priceCheckOperation);
4949
RoomPriceCheck roomPriceCheck = response.getData();
5050

@@ -130,9 +130,9 @@ CreateItineraryRequest createItineraryRequest(boolean hold) {
130130
The primary itinerary method of the Booking API creates a reservation for the selected property, room, rate, and occupancy. Payment information, including billing/cardholder contact information, is provided directly within the request. See [here](products/rapid/lodging/booking) for more details.
131131

132132
```java
133-
Link postItineraryLink = roomPriceCheck.getLinks().getBook(); // from the previous step
133+
PostItineraryOperationLink postItineraryOperationLink = roomPriceCheck.getLinks().getBook(); // from the previous step
134134
PostItineraryOperationContext postItineraryOperationContext = PostItineraryOperationContext.builder().customerIp("1.2.3.4").customerSessionId("12345").build(); // fill the context as needed
135-
PostItineraryOperation itineraryCreationOperation = new PostItineraryOperation(postItineraryLink, postItineraryOperationContext, createItineraryRequest(false));
135+
PostItineraryOperation itineraryCreationOperation = new PostItineraryOperation(postItineraryOperationLink, postItineraryOperationContext, createItineraryRequest(false));
136136
Response<ItineraryCreation> response = rapidClient.execute(itineraryCreationOperation);
137137
ItineraryCreation itineraryCreationResponse = response.getData();
138138
```

docs/java/usage-examples/psd2-booking.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ if (!(property instanceof PropertyAvailability)) {
3939
}
4040

4141
PropertyAvailability propertyAvailability = (PropertyAvailability) property;
42-
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
43-
PriceCheckOperation priceCheckOperation = new PriceCheckOperation(propertyAvailabilityLink);
42+
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
43+
PriceCheckOperation priceCheckOperation = new PriceCheckOperation(priceCheckOperationLink);
4444
Response<RoomPriceCheck> response = rapidClient.execute(priceCheckOperation);
4545
RoomPriceCheck roomPriceCheck = response.getData();
4646
```
@@ -113,9 +113,9 @@ PaymentSessionsRequest createPaymentSessionRequest() {
113113

114114
#### Create payment session
115115
```java
116-
Link paymentSessionLink = roomPriceCheck.getLinks().getPaymentSession();
116+
PostPaymentSessionsOperationLink postPaymentSessionsOperationLink = roomPriceCheck.getLinks().getPaymentSession();
117117
PostPaymentSessionsOperationContext postPaymentSessionsOperationContext = PostPaymentSessionsOperationContext.builder().customerIp("1.2.3.4").customerSessionId("12345").build(); // fill the context as needed
118-
PostPaymentSessionsOperation paymentSessionsOperation = new PostPaymentSessionsOperation(paymentSessionLink, postPaymentSessionsOperationContext, createPaymentSessionRequest());
118+
PostPaymentSessionsOperation paymentSessionsOperation = new PostPaymentSessionsOperation(postPaymentSessionsOperationLink, postPaymentSessionsOperationContext, createPaymentSessionRequest());
119119
Response<PaymentSessions> paymentSessionsResponse = rapidClient.execute(paymentSessionsOperation);
120120
PaymentSessions paymentSessions = paymentSessionsResponse.getData();
121121
```
@@ -198,27 +198,27 @@ CreateItineraryRequest createItineraryRequest(boolean hold) {
198198

199199
#### Create itinerary
200200
```java
201-
Link postItineraryLink = roomPriceCheck.getLinks().getBook(); // from the first step
201+
PostItineraryOperationLink postItineraryOperationLink = roomPriceCheck.getLinks().getBook(); // from the first step
202202
PostItineraryOperationContext postItineraryOperationContext = PostItineraryOperationContext.builder().customerIp("1.2.3.4").customerSessionId("12345").build(); // fill the context as needed
203-
PostItineraryOperation itineraryCreationOperation = new PostItineraryOperation(postItineraryLink, postItineraryOperationContext, createItineraryRequest(true));
203+
PostItineraryOperation itineraryCreationOperation = new PostItineraryOperation(postItineraryOperationLink, postItineraryOperationContext, createItineraryRequest(true));
204204
Response<ItineraryCreation> response = rapidClient.execute(itineraryCreationOperation);
205205
ItineraryCreation itineraryCreation = response.getData();
206206
```
207207

208208
#### Complete payment session
209209
```java
210-
Link completePaymentSessionLink = itineraryCreation.getLinks().getCompletePaymentSession();
210+
PutCompletePaymentSessionOperation putCompletePaymentSessionOperation = itineraryCreation.getLinks().getCompletePaymentSession();
211211
PutCompletePaymentSessionOperationContext putCompletePaymentSessionOperationContext = PutCompletePaymentSessionOperationContext.builder().customerIp("1.2.3.4").customerSessionId("12345").build(); // fill the context as needed
212-
PutCompletePaymentSessionOperation completePaymentSessionOperation = new PutCompletePaymentSessionOperation(completePaymentSessionLink, putCompletePaymentSessionOperationContext);
212+
PutCompletePaymentSessionOperation completePaymentSessionOperation = new PutCompletePaymentSessionOperation(putCompletePaymentSessionOperation, putCompletePaymentSessionOperationContext);
213213
Response<CompletePaymentSession> completePaymentSessionResponse = rapidClient.execute(completePaymentSessionOperation);
214214
CompletePaymentSession completePaymentSession = completePaymentSessionResponse.getData();
215215
```
216216

217217
#### Resume on-hold booking
218218
```java
219-
Link resumeLink = itineraryCreation.getLinks().getResume();
219+
PutResumeBookingOperationLink putResumeBookingOperationLink = itineraryCreation.getLinks().getResume();
220220
PutResumeBookingOperationContext putResumeBookingOperationContext = PutResumeBookingOperationContext.builder().customerIp("1.2.3.4").customerSessionId("12345").build(); // fill the context as needed
221-
PutResumeBookingOperation putResumeBookingOperation = new PutResumeBookingOperation(resumeLink, putResumeBookingOperationContext);
221+
PutResumeBookingOperation putResumeBookingOperation = new PutResumeBookingOperation(putResumeBookingOperationLink, putResumeBookingOperationContext);
222222
rapidClient.execute(putResumeBookingOperation);
223223
```
224224

0 commit comments

Comments
 (0)