Skip to content

Commit 225bfea

Browse files
authored
Merge pull request #20 from anthonyroux/hotel_v2
Migration from the hotel v1 to hotel v2
2 parents 11e0637 + b892d01 commit 225bfea

File tree

10 files changed

+143
-163
lines changed

10 files changed

+143
-163
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ build
66
.classpath
77
.idea
88
out
9-
.DS_Store
9+
.DS_Store
10+
amadeus-java.iml

README.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ amadeus.referenceData.urls.checkinLinks.get(Params.with("airlineCode", "BA"));
131131

132132
Similarly, to select a resource by ID, you can pass in the ID to the **singular** path.
133133

134-
For example, `GET /v1/shopping/hotel/ABC123/offers/DEF234` would be:
134+
For example, `GET /v2/shopping/hotel-offers/XXX` would be:
135135

136136
```java
137-
amadeus.hotel("ABC123").offer("DEF234").get(...);
137+
amadeus.hotelOffer("XXX").get(...);
138138
```
139139

140140
You can make any arbitrary API call as well directly with the `.get` method.
@@ -281,13 +281,10 @@ Period[] busiestPeriods = amadeus.travel.analytics.airTraffic.busiestPeriod.get(
281281
HotelOffer[] offers = amadeus.shopping.hotelOffers.get(Params
282282
.with("cityCode", "MAD"));
283283
// Get list of offers for a specific hotel
284+
HotelOffer hotelOffer = amadeus.shopping.hotelOffersByHotel.get(Params.with("hotelId", "BGLONBGB");
285+
// Confirm the availability of a specific offer
284286
HotelOffer offer = amadeus.shopping
285-
.hotel("SMPARCOL")
286-
.hotelOffers.get();
287-
// Confirm the availability of a specific offer for a specific hotel
288-
Offer offer = amadeus.shopping
289-
.hotel("SMPARCOL")
290-
.offer("4BA070CE929E135B3268A9F2D0C51E9D4A6CF318BA10485322FA2C7E78C7852E").get();
287+
.hotelOffer("4BA070CE929E135B3268A9F2D0C51E9D4A6CF318BA10485322FA2C7E78C7852E").get();
291288
```
292289

293290
## Development & Contributing

src/main/java/com/amadeus/Shopping.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
import com.amadeus.shopping.FlightDates;
44
import com.amadeus.shopping.FlightDestinations;
55
import com.amadeus.shopping.FlightOffers;
6-
import com.amadeus.shopping.Hotel;
6+
import com.amadeus.shopping.HotelOffer;
77
import com.amadeus.shopping.HotelOffers;
8+
import com.amadeus.shopping.HotelOffersByHotel;
89

910
/**
1011
* <p>
@@ -52,11 +53,19 @@ public class Shopping {
5253
/**
5354
* <p>
5455
* A namespaced client for the
55-
* <code>/v1/shopping/hotel-offers</code> endpoints.
56+
* <code>/v2/shopping/hotel-offers</code> endpoints.
5657
* </p>
5758
*/
5859
public HotelOffers hotelOffers;
5960

61+
/**
62+
* <p>
63+
* A namespaced client for the
64+
* <code>/v2/shopping/hotel-offers/by-hotel</code> endpoints.
65+
* </p>
66+
*/
67+
public HotelOffersByHotel hotelOffersByHotel;
68+
6069
/**
6170
* Constructor.
6271
* @hide
@@ -67,6 +76,7 @@ public Shopping(Amadeus client) {
6776
this.flightDestinations = new FlightDestinations(client);
6877
this.flightOffers = new FlightOffers(client);
6978
this.hotelOffers = new HotelOffers(client);
79+
this.hotelOffersByHotel = new HotelOffersByHotel(client);
7080
}
7181

7282
/**
@@ -75,7 +85,7 @@ public Shopping(Amadeus client) {
7585
* <code>/v1/shopping/hotel/:hotel_id</code> endpoints.
7686
* </p>
7787
*/
78-
public Hotel hotel(String hotelId) {
79-
return new Hotel(client, hotelId);
88+
public HotelOffer hotelOffer(String hotelId) {
89+
return new HotelOffer(client, hotelId);
8090
}
8191
}

src/main/java/com/amadeus/resources/HotelOffer.java

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ protected Hotel() {}
3737
private @Getter String cityCode;
3838
private @Getter double latitude;
3939
private @Getter double longitude;
40+
private @Getter HotelDistance hotelDistance;
4041
private @Getter AddressType address;
4142
private @Getter HotelContact contact;
4243
}
@@ -52,7 +53,6 @@ protected Offer() {}
5253
private @Getter String type;
5354
private @Getter String id;
5455
private @Getter Integer roomQuantity;
55-
private @Getter String bookingCode;
5656
private @Getter String rateCode;
5757
private @Getter RateFamily rateFamilyEstimated;
5858
private @Getter String category;
@@ -65,6 +65,19 @@ protected Offer() {}
6565
private @Getter PolicyDetails policies;
6666
}
6767

68+
/**
69+
* An HotelOffer-related object as returned by the HotelOffers API.
70+
* @see com.amadeus.shopping.HotelOffers#get()
71+
*/
72+
@ToString
73+
public class HotelDistance {
74+
protected HotelDistance() {}
75+
76+
private @Getter String description;
77+
private @Getter double distance;
78+
private @Getter String distanceUnit;
79+
}
80+
6881
/**
6982
* An HotelOffer-related object as returned by the HotelOffers API.
7083
* @see com.amadeus.shopping.HotelOffers#get()
@@ -220,6 +233,7 @@ public class MediaURI {
220233
protected MediaURI() {}
221234

222235
private @Getter String uri;
236+
private @Getter String category;
223237
}
224238

225239
/**
@@ -262,6 +276,22 @@ protected PolicyDetails() {}
262276
private @Getter GuaranteePolicy prepay;
263277
private @Getter GuaranteePolicy holdTime;
264278
private @Getter CancellationPolicy cancellation;
279+
private @Getter CheckInOutPolicy checkInOut;
280+
}
281+
282+
/**
283+
* An HotelOffer-related object as returned by the HotelOffers API.
284+
* @see com.amadeus.shopping.HotelOffers#get()
285+
*/
286+
@ToString
287+
public class CheckInOutPolicy {
288+
289+
protected CheckInOutPolicy() {}
290+
291+
private @Getter String checkIn;
292+
private @Getter TextWithLanguageType checkInDescription;
293+
private @Getter String checkOut;
294+
private @Getter TextWithLanguageType checkOutDescription;
265295
}
266296

267297
/**

src/main/java/com/amadeus/shopping/Hotel.java

Lines changed: 0 additions & 52 deletions
This file was deleted.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package com.amadeus.shopping;
2+
3+
import com.amadeus.Amadeus;
4+
import com.amadeus.Params;
5+
import com.amadeus.Response;
6+
import com.amadeus.exceptions.ResponseException;
7+
import com.amadeus.resources.Resource;
8+
9+
/**
10+
* <p>
11+
* A namespaced client for the
12+
* <code>/v2/shopping/hotel-offers/:offer_id</code> endpoints.
13+
* </p>
14+
*
15+
* <p>
16+
* Access via the Amadeus client object
17+
* </p>
18+
*
19+
* <pre>
20+
* Amadeus amadeus = Amadeus.builder(API_KEY, API_SECRET).build();
21+
* amadeus.shopping.HotelOffer(offerId);</pre>
22+
*
23+
* @hide
24+
*/
25+
public class HotelOffer {
26+
private Amadeus client;
27+
private String offerId;
28+
29+
/**
30+
* Constructor.
31+
* @hide
32+
*/
33+
public HotelOffer(Amadeus client, String offerId) {
34+
this.offerId = offerId;
35+
this.client = client;
36+
}
37+
38+
/**
39+
* <p>
40+
* Returns details for a specific offer.
41+
* </p>
42+
*
43+
* <pre>
44+
* amadeus.shopping.HotelOffer("XXX").get();</pre>
45+
*
46+
* @param params the parameters to send to the API
47+
* @return an API response object
48+
* @throws ResponseException when an exception occurs
49+
*/
50+
public com.amadeus.resources.HotelOffer get(Params params) throws ResponseException {
51+
String path = String.format("/v2/shopping/hotel-offers/%s", offerId);
52+
Response response = client.get(path, params);
53+
return (com.amadeus.resources.HotelOffer) Resource.fromObject(
54+
response, com.amadeus.resources.HotelOffer.class);
55+
}
56+
57+
/**
58+
* Convenience method for calling <code>get</code> without any parameters.
59+
* @see com.amadeus.resources.HotelOffer#get()
60+
*/
61+
public com.amadeus.resources.HotelOffer get() throws ResponseException {
62+
return get(null);
63+
}
64+
}

src/main/java/com/amadeus/shopping/HotelOffers.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public HotelOffers(Amadeus client) {
4747
* @throws ResponseException when an exception occurs
4848
*/
4949
public HotelOffer[] get(Params params) throws ResponseException {
50-
Response response = client.get("/v1/shopping/hotel-offers", params);
50+
Response response = client.get("/v2/shopping/hotel-offers", params);
5151
return (HotelOffer[]) Resource.fromArray(response, HotelOffer[].class);
5252
}
5353

src/main/java/com/amadeus/shopping/hotel/HotelOffers.java renamed to src/main/java/com/amadeus/shopping/HotelOffersByHotel.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
package com.amadeus.shopping.hotel;
1+
package com.amadeus.shopping;
22

33
import com.amadeus.Amadeus;
44
import com.amadeus.Params;
55
import com.amadeus.Response;
66
import com.amadeus.exceptions.ResponseException;
77
import com.amadeus.resources.HotelOffer;
88
import com.amadeus.resources.Resource;
9-
import com.google.gson.Gson;
109

1110
/**
1211
* <p>
1312
* A namespaced client for the
14-
* <code>/v1/shopping/hotels/:hotel_id/hotel-offers</code> endpoints.
13+
* <code>/v2/shopping/hotel-offers/by-hotel</code> endpoints.
1514
* </p>
1615
*
1716
* <p>
@@ -20,42 +19,40 @@
2019
*
2120
* <pre>
2221
* Amadeus amadeus = Amadeus.builder("clientId", "secret").build();
23-
* amadeus.shopping.hotel(hotelId).hotelOffers;</pre>
22+
* amadeus.shopping.HotelOffersByHotel;</pre>
2423
*/
25-
public class HotelOffers {
24+
public class HotelOffersByHotel {
2625
private Amadeus client;
27-
private String hotelId;
2826

2927
/**
3028
* Constructor.
3129
* @hide
3230
*/
33-
public HotelOffers(Amadeus client, String hotelId) {
31+
public HotelOffersByHotel(Amadeus client) {
3432
this.client = client;
35-
this.hotelId = hotelId;
3633
}
3734

3835
/**
3936
* <p>
40-
* Get one hotel and its available offers.
37+
* Get all offers for a dedicated hotel.
4138
* </p>
4239
*
4340
* <pre>
44-
* amadeus.shopping.hotel("SMPARCOL").hotelOffers.get();</pre>
41+
* amadeus.shopping.HotelOffersByHotel.get(Params
42+
* .with("hotelId", "XKPARC12"));</pre>
4543
*
4644
* @param params the parameters to send to the API
4745
* @return an API response object
4846
* @throws ResponseException when an exception occurs
4947
*/
5048
public HotelOffer get(Params params) throws ResponseException {
51-
String path = String.format("/v1/shopping/hotels/%s/hotel-offers", hotelId);
52-
Response response = client.get(path, params);
49+
Response response = client.get("/v2/shopping/hotel-offers/by-hotel", params);
5350
return (HotelOffer) Resource.fromObject(response, HotelOffer.class);
5451
}
5552

5653
/**
5754
* Convenience method for calling <code>get</code> without any parameters.
58-
* @see HotelOffers#get()
55+
* @see HotelOffersByHotel#get()
5956
*/
6057
public HotelOffer get() throws ResponseException {
6158
return get(null);

0 commit comments

Comments
 (0)