Skip to content

Commit

Permalink
add support for hotel booking v2
Browse files Browse the repository at this point in the history
  • Loading branch information
tsolakoua committed Jul 8, 2024
1 parent 2a25b36 commit 0287bb9
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/main/java/com/amadeus/Booking.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -31,6 +32,14 @@ public class Booking {
*/
public HotelBookings hotelBookings;

/**
* <p>
* A namespaced client for the
* <code>/v1/booking/hotelOrders</code> endpoints.
* </p>
*/
public HotelOrders hotelOrders;

/**
* Constructor.
* @hide
Expand All @@ -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) {
Expand Down
78 changes: 78 additions & 0 deletions src/main/java/com/amadeus/booking/HotelOrders.java
Original file line number Diff line number Diff line change
@@ -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;

/**
* <p>
* A namespaced client for the
* <code>/v2/booking/hotel-orders</code> endpoints.
* </p>
*
* <p>
* Access via the Amadeus client object.
* </p>
*
* <pre>
* Amadeus amadeus = Amadeus.builder(API_KEY, API_SECRET).build();
* amadeus.booking.HotelOrders;</pre>
*/
public class HotelOrders {
private Amadeus client;

/**
* Constructor.
*
* @hide
*/
public HotelOrders(Amadeus client) {
this.client = client;
}

/**
* <p>
* The Hotel Booking API allows you to perform hotel booking.
* </p>
*
* <pre>
* amadeus.booking.hotelOrders.post(body);</pre>
*
* @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);
}

/**
* <p>
* The Hotel Booking API allows you to perform hotel booking.
* </p>
*
* <pre>
* amadeus.booking.hotelOrders.post(body);</pre>
*
* @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 <code>post</code> without any parameters.
*
* @see HotelBookings#post()
*/
public HotelOrder post() throws ResponseException {
return post((String) null);
}
}
1 change: 0 additions & 1 deletion src/main/java/com/amadeus/resources/Hotel.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.amadeus.resources;

import com.google.gson.annotations.SerializedName;
import lombok.Getter;
import lombok.ToString;

Expand Down
91 changes: 91 additions & 0 deletions src/main/java/com/amadeus/resources/HotelOrder.java
Original file line number Diff line number Diff line change
@@ -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() {}
}
}

0 comments on commit 0287bb9

Please sign in to comment.