Skip to content

Commit 0287bb9

Browse files
committed
add support for hotel booking v2
1 parent 2a25b36 commit 0287bb9

File tree

4 files changed

+179
-1
lines changed

4 files changed

+179
-1
lines changed

Diff for: src/main/java/com/amadeus/Booking.java

+10
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.amadeus.booking.FlightOrder;
44
import com.amadeus.booking.FlightOrders;
55
import com.amadeus.booking.HotelBookings;
6+
import com.amadeus.booking.HotelOrders;
67

78
public class Booking {
89
private Amadeus client;
@@ -31,6 +32,14 @@ public class Booking {
3132
*/
3233
public HotelBookings hotelBookings;
3334

35+
/**
36+
* <p>
37+
* A namespaced client for the
38+
* <code>/v1/booking/hotelOrders</code> endpoints.
39+
* </p>
40+
*/
41+
public HotelOrders hotelOrders;
42+
3443
/**
3544
* Constructor.
3645
* @hide
@@ -39,6 +48,7 @@ public Booking(Amadeus client) {
3948
this.client = client;
4049
this.flightOrders = new FlightOrders(client);
4150
this.hotelBookings = new HotelBookings(client);
51+
this.hotelOrders = new HotelOrders(client);
4252
}
4353

4454
public FlightOrder flightOrder(String flightOrderId) {

Diff for: src/main/java/com/amadeus/booking/HotelOrders.java

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package com.amadeus.booking;
2+
3+
import com.amadeus.Amadeus;
4+
import com.amadeus.Response;
5+
import com.amadeus.exceptions.ResponseException;
6+
import com.amadeus.resources.HotelOrder;
7+
import com.amadeus.resources.Resource;
8+
import com.google.gson.JsonObject;
9+
10+
/**
11+
* <p>
12+
* A namespaced client for the
13+
* <code>/v2/booking/hotel-orders</code> endpoints.
14+
* </p>
15+
*
16+
* <p>
17+
* Access via the Amadeus client object.
18+
* </p>
19+
*
20+
* <pre>
21+
* Amadeus amadeus = Amadeus.builder(API_KEY, API_SECRET).build();
22+
* amadeus.booking.HotelOrders;</pre>
23+
*/
24+
public class HotelOrders {
25+
private Amadeus client;
26+
27+
/**
28+
* Constructor.
29+
*
30+
* @hide
31+
*/
32+
public HotelOrders(Amadeus client) {
33+
this.client = client;
34+
}
35+
36+
/**
37+
* <p>
38+
* The Hotel Booking API allows you to perform hotel booking.
39+
* </p>
40+
*
41+
* <pre>
42+
* amadeus.booking.hotelOrders.post(body);</pre>
43+
*
44+
* @param body the parameters to send to the API as a JSonObject
45+
* @return an API resource
46+
* @throws ResponseException when an exception occurs
47+
*/
48+
public HotelOrder post(JsonObject body) throws ResponseException {
49+
Response response = client.post("/v2/booking/hotel-orders", body);
50+
return (HotelOrder) Resource.fromObject(response, HotelOrder.class);
51+
}
52+
53+
/**
54+
* <p>
55+
* The Hotel Booking API allows you to perform hotel booking.
56+
* </p>
57+
*
58+
* <pre>
59+
* amadeus.booking.hotelOrders.post(body);</pre>
60+
*
61+
* @param body the parameters to send to the API as a String
62+
* @return an API resource
63+
* @throws ResponseException when an exception occurs
64+
*/
65+
public HotelOrder post(String body) throws ResponseException {
66+
Response response = client.post("/v2/booking/hotel-orders", body);
67+
return (HotelOrder) Resource.fromObject(response, HotelOrder.class);
68+
}
69+
70+
/**
71+
* Convenience method for calling <code>post</code> without any parameters.
72+
*
73+
* @see HotelBookings#post()
74+
*/
75+
public HotelOrder post() throws ResponseException {
76+
return post((String) null);
77+
}
78+
}

Diff for: src/main/java/com/amadeus/resources/Hotel.java

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.amadeus.resources;
22

3-
import com.google.gson.annotations.SerializedName;
43
import lombok.Getter;
54
import lombok.ToString;
65

Diff for: src/main/java/com/amadeus/resources/HotelOrder.java

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
package com.amadeus.resources;
2+
3+
import com.amadeus.resources.HotelOfferSearch.Offer;
4+
import lombok.Getter;
5+
import lombok.ToString;
6+
7+
/**
8+
* An HotelOrder object as returned by the Hotel Booking v2 API.
9+
* @see com.amadeus.booking.HotelOrders#get()
10+
*/
11+
@ToString
12+
public class HotelOrder extends Resource {
13+
private @Getter String self;
14+
private @Getter String type;
15+
private @Getter String id;
16+
private @Getter HotelBooking[] hotelBookings;
17+
private @Getter AssociatedRecord[] associatedRecords;
18+
private @Getter Guest[] guests;
19+
20+
protected HotelOrder() {}
21+
22+
@ToString
23+
public static class HotelBooking {
24+
private @Getter String type;
25+
private @Getter String id;
26+
private @Getter String bookingStatus;
27+
private @Getter RoomAssociation[] roomAssociations;
28+
private @Getter Offer hotelOffer;
29+
private @Getter Hotel hotel;
30+
31+
protected HotelBooking() {}
32+
}
33+
34+
@ToString
35+
public static class RoomAssociation {
36+
private @Getter String hotelOfferId;
37+
private GuestReference[] guestReferences;
38+
private @Getter String specialRequest;
39+
40+
protected RoomAssociation() {}
41+
}
42+
43+
@ToString
44+
public static class GuestReference {
45+
private @Getter String guestReference;
46+
private @Getter String hotelLoyaltyId;
47+
48+
protected GuestReference() {}
49+
}
50+
51+
@ToString
52+
public static class Guest {
53+
private @Getter int tid;
54+
private @Getter int id;
55+
private @Getter FrequentTraveler[] frequentTraveler;
56+
private @Getter String phone;
57+
private @Getter String email;
58+
private @Getter String title;
59+
private @Getter String firstName;
60+
private @Getter String lastName;
61+
private @Getter Integer childAge;
62+
63+
protected Guest() {}
64+
}
65+
66+
@ToString
67+
public static class FrequentTraveler {
68+
private @Getter String airlineCode;
69+
private @Getter String frequentTravelerId;
70+
71+
protected FrequentTraveler() {}
72+
}
73+
74+
@ToString
75+
public static class AssociatedRecord {
76+
private @Getter String reference;
77+
private @Getter String originSystemCode;
78+
79+
protected AssociatedRecord() {}
80+
}
81+
82+
@ToString
83+
public static class Hotel {
84+
private @Getter String hotelId;
85+
private @Getter String chainCode;
86+
private @Getter String name;
87+
private @Getter String self;
88+
89+
protected Hotel() {}
90+
}
91+
}

0 commit comments

Comments
 (0)