Skip to content

Commit a2690cd

Browse files
authored
Merge pull request #164 from xianqiliu/add-hotel-offer-v3
Add support for Hotel Search v3 and keep v2
2 parents 7c26377 + 54de266 commit a2690cd

File tree

10 files changed

+858
-0
lines changed

10 files changed

+858
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,18 @@ Hotel[] hotels = amadeus.referenceData.locations.hotels.byCity.get(Params
426426
Hotel[] hotels = amadeus.referenceData.locations.hotels.byGeocode.get(Params
427427
.with("longitude", 2.160873)
428428
.and("latitude", 41.397158));
429+
430+
// Hotel Offers Search API v3
431+
// Get multiple hotel offers
432+
HotelOfferSearch[] offers = amadeus.shopping.hotelOffersSearch.get(Params
433+
.with("hotelIds", "MCLONGHM")
434+
.and("adults", 1)
435+
.and("checkInDate", "2022-11-22")
436+
.and("roomQuantity", 1)
437+
.and("paymentPolicy", "NONE")
438+
.and("bestRateOnly", true));
439+
// Get hotel offer pricing by offer id
440+
HotelOfferSearch offer = amadeus.shopping.hotelOfferSearch("QF3MNOBDQ8").get();
429441
```
430442

431443
## Development & Contributing

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
import com.amadeus.shopping.FlightOffers;
99
import com.amadeus.shopping.FlightOffersSearch;
1010
import com.amadeus.shopping.HotelOffer;
11+
import com.amadeus.shopping.HotelOfferSearch;
1112
import com.amadeus.shopping.HotelOffers;
1213
import com.amadeus.shopping.HotelOffersByHotel;
14+
import com.amadeus.shopping.HotelOffersSearch;
1315
import com.amadeus.shopping.SeatMaps;
1416

1517

@@ -72,6 +74,14 @@ public class Shopping {
7274
*/
7375
public HotelOffers hotelOffers;
7476

77+
/**
78+
* <p>
79+
* A namespaced client for the
80+
* <code>/v3/shopping/hotel-offers</code> endpoints.
81+
* </p>
82+
*/
83+
public HotelOffersSearch hotelOffersSearch;
84+
7585
/**
7686
* <p>
7787
* A namespaced client for the
@@ -122,6 +132,7 @@ public Shopping(Amadeus client) {
122132
this.flightDestinations = new FlightDestinations(client);
123133
this.flightOffers = new FlightOffers(client);
124134
this.hotelOffers = new HotelOffers(client);
135+
this.hotelOffersSearch = new HotelOffersSearch(client);
125136
this.hotelOffersByHotel = new HotelOffersByHotel(client);
126137
this.flightOffersSearch = new FlightOffersSearch(client);
127138
this.seatMaps = new SeatMaps(client);
@@ -139,6 +150,16 @@ public HotelOffer hotelOffer(String hotelId) {
139150
return new HotelOffer(client, hotelId);
140151
}
141152

153+
/**
154+
* <p>
155+
* A namespaced client for the
156+
* <code>/v3/shopping/hotel/:hotel_id</code> endpoints.
157+
* </p>
158+
*/
159+
public HotelOfferSearch hotelOfferSearch(String offerId) {
160+
return new HotelOfferSearch(client, offerId);
161+
}
162+
142163
/**
143164
* <p>
144165
* A namespaced client for the
Lines changed: 323 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,323 @@
1+
package com.amadeus.resources;
2+
3+
import lombok.Getter;
4+
import lombok.ToString;
5+
6+
/**
7+
* An HotelOfferSearch object as returned by the HotelOffers API v3.
8+
* @see com.amadeus.shopping.HotelOffers#get()
9+
*/
10+
@ToString
11+
public class HotelOfferSearch extends Resource {
12+
protected HotelOfferSearch() {}
13+
14+
private @Getter String type;
15+
private @Getter Hotel hotel;
16+
private @Getter boolean available;
17+
private @Getter Offer[] offers;
18+
private @Getter String self;
19+
20+
/**
21+
* An HotelOffer-related object as returned by the HotelOffers API v3.
22+
* @see com.amadeus.shopping.HotelOffers#get()
23+
*/
24+
@ToString
25+
public class Hotel {
26+
protected Hotel() {}
27+
28+
private @Getter String hotelId;
29+
private @Getter String chainCode;
30+
private @Getter String brandCode;
31+
private @Getter String dupeId;
32+
private @Getter String name;
33+
private @Getter String cityCode;
34+
}
35+
36+
/**
37+
* An HotelOffer-related object as returned by the HotelOffers API v3.
38+
* @see com.amadeus.shopping.HotelOffers#get()
39+
*/
40+
@ToString
41+
public class Offer extends Resource {
42+
protected Offer() {}
43+
44+
private @Getter String type;
45+
private @Getter String id;
46+
private @Getter String checkInDate;
47+
private @Getter String checkOutDate;
48+
private @Getter Integer roomQuantity;
49+
private @Getter String rateCode;
50+
private @Getter RateFamily rateFamilyEstimated;
51+
private @Getter String category;
52+
private @Getter QualifiedFreeText description;
53+
private @Getter Commission commission;
54+
private @Getter String boardType;
55+
private @Getter RoomDetails room;
56+
private @Getter Guests guests;
57+
private @Getter HotelPrice price;
58+
private @Getter PolicyDetails policies;
59+
private @Getter String self;
60+
}
61+
62+
/**
63+
* An HotelOffer-related object as returned by the HotelOffers API v3.
64+
* @see com.amadeus.shopping.HotelOffers#get()
65+
*/
66+
@ToString
67+
public class RateFamily {
68+
protected RateFamily() {}
69+
70+
private @Getter String code;
71+
private @Getter String type;
72+
}
73+
74+
/**
75+
* An HotelOffer-related object as returned by the HotelOffers API v3.
76+
* @see com.amadeus.shopping.HotelOffers#get()
77+
*/
78+
@ToString
79+
public class Commission {
80+
protected Commission() {}
81+
82+
private @Getter String percentage;
83+
private @Getter String amount;
84+
private @Getter QualifiedFreeText description;
85+
}
86+
87+
/**
88+
* An HotelOffer-related object as returned by the HotelOffers API v3.
89+
* @see com.amadeus.shopping.HotelOffers#get()
90+
*/
91+
@ToString
92+
public class RoomDetails {
93+
protected RoomDetails() {}
94+
95+
private @Getter String type;
96+
private @Getter EstimatedRoomType typeEstimated;
97+
private @Getter QualifiedFreeText description;
98+
}
99+
100+
/**
101+
* An HotelOffer-related object as returned by the HotelOffers API v3.
102+
* @see com.amadeus.shopping.HotelOffers#get()
103+
*/
104+
@ToString
105+
public class EstimatedRoomType {
106+
protected EstimatedRoomType() {}
107+
108+
private @Getter String category;
109+
private @Getter Integer beds;
110+
private @Getter String bedType;
111+
}
112+
113+
/**
114+
* An HotelOffer-related object as returned by the HotelOffers API v3.
115+
* @see com.amadeus.shopping.HotelOffers#get()
116+
*/
117+
@ToString
118+
public class HotelPrice {
119+
protected HotelPrice() {}
120+
121+
private @Getter String currency;
122+
private @Getter String sellingTotal;
123+
private @Getter String total;
124+
private @Getter String base;
125+
private @Getter HotelTax[] taxes;
126+
private @Getter Markup[] markups;
127+
private @Getter PriceVariations variations;
128+
}
129+
130+
/**
131+
* An HotelOffer-related object as returned by the HotelOffers API v3.
132+
* @see com.amadeus.shopping.HotelOffers#get()
133+
*/
134+
@ToString
135+
public class HotelTax {
136+
protected HotelTax() {}
137+
138+
private @Getter String currency;
139+
private @Getter String amount;
140+
private @Getter String code;
141+
private @Getter String percentage;
142+
private @Getter boolean included;
143+
private @Getter String description;
144+
private @Getter String pricingFrequency;
145+
private @Getter String pricingMode;
146+
}
147+
148+
/**
149+
* An HotelOffer-related object as returned by the HotelOffers API v3.
150+
* @see com.amadeus.shopping.HotelOffers#get()
151+
*/
152+
@ToString
153+
public class PriceVariations {
154+
protected PriceVariations() {}
155+
156+
private @Getter Price average;
157+
private @Getter PriceVariation[] changes;
158+
}
159+
160+
/**
161+
* An HotelOffer-related object as returned by the HotelOffers API v3.
162+
* @see com.amadeus.shopping.HotelOffers#get()
163+
*/
164+
@ToString
165+
public class PriceVariation {
166+
protected PriceVariation() {}
167+
168+
private @Getter String startDate;
169+
private @Getter String endDate;
170+
private @Getter String currency;
171+
private @Getter String sellingTotal;
172+
private @Getter String base;
173+
private @Getter String total;
174+
private @Getter Markup[] markups;
175+
}
176+
177+
/**
178+
* An HotelOffer-related object as returned by the HotelOffers API v3.
179+
* @see com.amadeus.shopping.HotelOffers#get()
180+
*/
181+
@ToString
182+
public class Price {
183+
protected Price() {}
184+
185+
private @Getter String currency;
186+
private @Getter String sellingTotal;
187+
private @Getter String base;
188+
private @Getter String total;
189+
private @Getter Markup[] markups;
190+
}
191+
192+
/**
193+
* An HotelOffer-related object as returned by the HotelOffers API v3.
194+
* @see com.amadeus.shopping.HotelOffers#get()
195+
*/
196+
@ToString
197+
public class Guests {
198+
protected Guests() {}
199+
200+
private @Getter Integer adults;
201+
private @Getter Integer[] childAges;
202+
}
203+
204+
/**
205+
* An HotelOffer-related object as returned by the HotelOffers API v3.
206+
* @see com.amadeus.shopping.HotelOffers#get()
207+
*/
208+
@ToString
209+
public class QualifiedFreeText {
210+
protected QualifiedFreeText() {}
211+
212+
private @Getter String lang;
213+
private @Getter String text;
214+
}
215+
216+
/**
217+
* An HotelOffer-related object as returned by the HotelOffers API v3.
218+
* @see com.amadeus.shopping.HotelOffers#get()
219+
*/
220+
@ToString
221+
public class PolicyDetails {
222+
protected PolicyDetails() {}
223+
224+
private @Getter String paymentType;
225+
private @Getter GuaranteePolicy guarantee;
226+
private @Getter DepositPolicy deposit;
227+
private @Getter DepositPolicy prepay;
228+
private @Getter HoldPolicy holdTime;
229+
private @Getter CancellationPolicy cancellation;
230+
private @Getter CheckInOutPolicy checkInOut;
231+
}
232+
233+
/**
234+
* An HotelOffer-related object as returned by the HotelOffers API v3.
235+
* @see com.amadeus.shopping.HotelOffers#get()
236+
*/
237+
@ToString
238+
public class DepositPolicy {
239+
protected DepositPolicy() {}
240+
241+
private @Getter String amount;
242+
private @Getter String deadline;
243+
private @Getter QualifiedFreeText description;
244+
private @Getter PaymentPolicy acceptedPayments;
245+
}
246+
247+
/**
248+
* An HotelOffer-related object as returned by the HotelOffers API v3.
249+
* @see com.amadeus.shopping.HotelOffers#get()
250+
*/
251+
@ToString
252+
public class HoldPolicy {
253+
protected HoldPolicy() {}
254+
255+
private @Getter String deadline;
256+
}
257+
258+
/**
259+
* An HotelOffer-related object as returned by the HotelOffers API v3.
260+
* @see com.amadeus.shopping.HotelOffers#get()
261+
*/
262+
@ToString
263+
public class CheckInOutPolicy {
264+
265+
protected CheckInOutPolicy() {}
266+
267+
private @Getter String checkIn;
268+
private @Getter QualifiedFreeText checkInDescription;
269+
private @Getter String checkOut;
270+
private @Getter QualifiedFreeText checkOutDescription;
271+
}
272+
273+
/**
274+
* An HotelOffer-related object as returned by the HotelOffers API v3.
275+
* @see com.amadeus.shopping.HotelOffers#get()
276+
*/
277+
@ToString
278+
public class GuaranteePolicy {
279+
protected GuaranteePolicy() {}
280+
281+
private @Getter QualifiedFreeText description;
282+
private @Getter PaymentPolicy acceptedPayments;
283+
}
284+
285+
/**
286+
* An HotelOffer-related object as returned by the HotelOffers API v3.
287+
* @see com.amadeus.shopping.HotelOffers#get()
288+
*/
289+
@ToString
290+
public class CancellationPolicy {
291+
protected CancellationPolicy() {}
292+
293+
private @Getter String type;
294+
private @Getter String amount;
295+
private @Getter Integer numberOfNights;
296+
private @Getter String percentage;
297+
private @Getter String deadline;
298+
private @Getter QualifiedFreeText description;
299+
}
300+
301+
/**
302+
* An HotelOffer-related object as returned by the HotelOffers API v3.
303+
* @see com.amadeus.shopping.HotelOffers#get()
304+
*/
305+
@ToString
306+
public class PaymentPolicy {
307+
protected PaymentPolicy() {}
308+
309+
private @Getter String[] creditCards;
310+
private @Getter String[] method;
311+
}
312+
313+
/**
314+
* An HotelOffer-related object as returned by the HotelOffers API v3.
315+
* @see com.amadeus.shopping.HotelOffers#get()
316+
*/
317+
@ToString
318+
public class Markup {
319+
protected Markup() {}
320+
321+
private @Getter String amount;
322+
}
323+
}

0 commit comments

Comments
 (0)