diff --git a/src/main/java/com/amadeus/Booking.java b/src/main/java/com/amadeus/Booking.java index a6d5c40d..d88fc362 100644 --- a/src/main/java/com/amadeus/Booking.java +++ b/src/main/java/com/amadeus/Booking.java @@ -3,6 +3,7 @@ import com.amadeus.booking.FlightOrder; import com.amadeus.booking.FlightOrders; import com.amadeus.booking.HotelBookings; +import com.amadeus.booking.HotelOrders; public class Booking { private Amadeus client; @@ -31,6 +32,14 @@ public class Booking { */ public HotelBookings hotelBookings; + /** + *

+ * A namespaced client for the + * /v1/booking/hotelOrders endpoints. + *

+ */ + public HotelOrders hotelOrders; + /** * Constructor. * @hide @@ -39,6 +48,7 @@ public Booking(Amadeus client) { this.client = client; this.flightOrders = new FlightOrders(client); this.hotelBookings = new HotelBookings(client); + this.hotelOrders = new HotelOrders(client); } public FlightOrder flightOrder(String flightOrderId) { diff --git a/src/main/java/com/amadeus/booking/HotelOrders.java b/src/main/java/com/amadeus/booking/HotelOrders.java new file mode 100644 index 00000000..00b47060 --- /dev/null +++ b/src/main/java/com/amadeus/booking/HotelOrders.java @@ -0,0 +1,78 @@ +package com.amadeus.booking; + +import com.amadeus.Amadeus; +import com.amadeus.Response; +import com.amadeus.exceptions.ResponseException; +import com.amadeus.resources.HotelOrder; +import com.amadeus.resources.Resource; +import com.google.gson.JsonObject; + +/** + *

+ * A namespaced client for the + * /v2/booking/hotel-orders endpoints. + *

+ * + *

+ * Access via the Amadeus client object. + *

+ * + *
+ * Amadeus amadeus = Amadeus.builder(API_KEY, API_SECRET).build();
+ * amadeus.booking.HotelOrders;
+ */ +public class HotelOrders { + private Amadeus client; + + /** + * Constructor. + * + * @hide + */ + public HotelOrders(Amadeus client) { + this.client = client; + } + + /** + *

+ * The Hotel Booking API allows you to perform hotel booking. + *

+ * + *
+   * amadeus.booking.hotelOrders.post(body);
+ * + * @param body the parameters to send to the API as a JSonObject + * @return an API resource + * @throws ResponseException when an exception occurs + */ + public HotelOrder post(JsonObject body) throws ResponseException { + Response response = client.post("/v2/booking/hotel-orders", body); + return (HotelOrder) Resource.fromObject(response, HotelOrder.class); + } + + /** + *

+ * The Hotel Booking API allows you to perform hotel booking. + *

+ * + *
+   * amadeus.booking.hotelOrders.post(body);
+ * + * @param body the parameters to send to the API as a String + * @return an API resource + * @throws ResponseException when an exception occurs + */ + public HotelOrder post(String body) throws ResponseException { + Response response = client.post("/v2/booking/hotel-orders", body); + return (HotelOrder) Resource.fromObject(response, HotelOrder.class); + } + + /** + * Convenience method for calling post without any parameters. + * + * @see HotelBookings#post() + */ + public HotelOrder post() throws ResponseException { + return post((String) null); + } +} diff --git a/src/main/java/com/amadeus/resources/Hotel.java b/src/main/java/com/amadeus/resources/Hotel.java index b46d2a99..b9e0fbe8 100644 --- a/src/main/java/com/amadeus/resources/Hotel.java +++ b/src/main/java/com/amadeus/resources/Hotel.java @@ -1,6 +1,5 @@ package com.amadeus.resources; -import com.google.gson.annotations.SerializedName; import lombok.Getter; import lombok.ToString; diff --git a/src/main/java/com/amadeus/resources/HotelOrder.java b/src/main/java/com/amadeus/resources/HotelOrder.java new file mode 100644 index 00000000..97ed83fc --- /dev/null +++ b/src/main/java/com/amadeus/resources/HotelOrder.java @@ -0,0 +1,91 @@ +package com.amadeus.resources; + +import com.amadeus.resources.HotelOfferSearch.Offer; +import lombok.Getter; +import lombok.ToString; + +/** + * An HotelOrder object as returned by the Hotel Booking v2 API. + * @see com.amadeus.booking.HotelOrders#get() + */ +@ToString +public class HotelOrder extends Resource { + private @Getter String self; + private @Getter String type; + private @Getter String id; + private @Getter HotelBooking[] hotelBookings; + private @Getter AssociatedRecord[] associatedRecords; + private @Getter Guest[] guests; + + protected HotelOrder() {} + + @ToString + public static class HotelBooking { + private @Getter String type; + private @Getter String id; + private @Getter String bookingStatus; + private @Getter RoomAssociation[] roomAssociations; + private @Getter Offer hotelOffer; + private @Getter Hotel hotel; + + protected HotelBooking() {} + } + + @ToString + public static class RoomAssociation { + private @Getter String hotelOfferId; + private GuestReference[] guestReferences; + private @Getter String specialRequest; + + protected RoomAssociation() {} + } + + @ToString + public static class GuestReference { + private @Getter String guestReference; + private @Getter String hotelLoyaltyId; + + protected GuestReference() {} + } + + @ToString + public static class Guest { + private @Getter int tid; + private @Getter int id; + private @Getter FrequentTraveler[] frequentTraveler; + private @Getter String phone; + private @Getter String email; + private @Getter String title; + private @Getter String firstName; + private @Getter String lastName; + private @Getter Integer childAge; + + protected Guest() {} + } + + @ToString + public static class FrequentTraveler { + private @Getter String airlineCode; + private @Getter String frequentTravelerId; + + protected FrequentTraveler() {} + } + + @ToString + public static class AssociatedRecord { + private @Getter String reference; + private @Getter String originSystemCode; + + protected AssociatedRecord() {} + } + + @ToString + public static class Hotel { + private @Getter String hotelId; + private @Getter String chainCode; + private @Getter String name; + private @Getter String self; + + protected Hotel() {} + } +}