Skip to content

Commit 7db313d

Browse files
committed
Merge branch 'master' into models-flight-apis
2 parents addb918 + c0a6dfd commit 7db313d

File tree

15 files changed

+385
-4
lines changed

15 files changed

+385
-4
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,10 @@ FlightOfferSearch[] flightOffersSearches = amadeus.shopping.flightOffersSearch.p
239239

240240
// Flight Order Management
241241
// The flightOrderID comes from the Flight Create Orders (in test environment it's temporary)
242+
// Retrieve a flight order
242243
FlightOrder order = amadeus.booking.flightOrder("eJzTd9f3NjIJdzUGAAp%2fAiY=").get();
244+
// Cancel a flight order
245+
FlightOrder order = amadeus.booking.flightOrder("eJzTd9f3NjIJdzUGAAp%2fAiY=").delete();
243246

244247
// Flight Offers price
245248
FlightPrice[] flightPricing = amadeus.shopping.flightOffersSearch.pricing.post(
@@ -306,6 +309,11 @@ HotelOffer[] offers = amadeus.shopping.hotelOffers.get(Params
306309
HotelOffer hotelOffer = amadeus.shopping.hotelOffersByHotel.get(Params.with("hotelId", "BGLONBGB"));
307310
// Confirm the availability of a specific offer
308311
HotelOffer offer = amadeus.shopping.hotelOffer("4BA070CE929E135B3268A9F2D0C51E9D4A6CF318BA10485322FA2C7E78C7852E").get();
312+
313+
// Hotel Booking
314+
// The body can be a String version of your JSON or a JsonObject
315+
HotelBooking[] hotel = amadeus.booking.hotelBookings.post(body);
316+
309317
// Hotel Ratings / Sentiments
310318
HotelSentiment[] hotelSentiments = amadeus.ereputation.hotelSentiments.get(Params.with("hotelIds", "ELONMFS,ADNYCCTB"));
311319

@@ -322,6 +330,9 @@ PointOfInterest[] pointsOfInterest = amadeus.referenceData.locations.pointsOfInt
322330
.and("south", "41.394582")
323331
.and("east", "2.177181"));
324332

333+
// Returns a single Point of Interest from a given id
334+
PointOfInterest pointOfInterest = amadeus.referenceData.locations.pointOfInterest("9CB40CB5D0").get();
335+
325336
// What's the likelihood flights from this airport will leave on time?
326337
Prediction AirportOnTime = amadeus.airport.predictions.onTime.get(Params
327338
.with("airportCode", "NCE")

src/main/java/examples/flight/createorders/FlightCreateOrders.java renamed to src/examples/flight/createorders/FlightCreateOrders.java

File renamed without changes.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package examples.hotel.booking;
2+
3+
import com.amadeus.Amadeus;
4+
import com.amadeus.exceptions.ResponseException;
5+
import com.amadeus.resources.HotelBooking;
6+
7+
public class HotelBookings {
8+
/**
9+
* <p>
10+
* An example to call hotel Booking API
11+
* <code>/v1/booking/hotel-bookings</code> endpoints.
12+
* </p>
13+
*
14+
* <p>
15+
* Access via the Amadeus client object.
16+
* </p>
17+
*
18+
* <pre>
19+
* Amadeus amadeus = Amadeus.builder("clientId", "secret").build();
20+
* amadeus.booking.hotelBookings;</pre>
21+
*/
22+
public static void main(String[] args) throws ResponseException {
23+
24+
Amadeus amadeus = Amadeus
25+
.builder("REPLACE_BY_YOUR_API_KEY","REPLACE_BY_YOUR_API_SECRET")
26+
.build();
27+
String body = "{\"data\""
28+
+ ":{\"offerId\":\"2F5B1C3B215FA11FD5A44BE210315B18FF91BDA2FEDDD879907A3798F41D1C28\""
29+
+ ",\"guests\":[{\"id\":1,\"name\":{\"title\":\"MR\",\"firstName\":\"BOB\","
30+
+ "\"lastName\" :\"SMITH\"},\"contact\":{\"phone\":\"+33679278416\",\""
31+
+ "email\":\"[email protected]\"}}],\""
32+
+ "payments\":[{\"id\":1,\"method\":\"creditCard\",\""
33+
+ "card\":{\"vendorCode\":\"VI\",\"cardNumber\""
34+
+ ":\"4151289722471370\",\"expiryDate\":\"2021-08\"}}]}}";
35+
HotelBooking[] hotel = amadeus.booking.hotelBookings.post(body);
36+
System.out.println(hotel[0].getId());
37+
}
38+
}
File renamed without changes.

src/main/java/com/amadeus/Booking.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.amadeus.booking.FlightOrder;
44
import com.amadeus.booking.FlightOrders;
5+
import com.amadeus.booking.HotelBookings;
56

67
public class Booking {
78
private Amadeus client;
@@ -22,9 +23,22 @@ public class Booking {
2223
*/
2324
public FlightOrders flightOrders;
2425

26+
/**
27+
* <p>
28+
* A namespaced client for the
29+
* <code>/v1/booking/hotelBookings</code> endpoints.
30+
* </p>
31+
*/
32+
public HotelBookings hotelBookings;
33+
34+
/**
35+
* Constructor.
36+
* @hide
37+
*/
2538
public Booking(Amadeus client) {
2639
this.client = client;
2740
this.flightOrders = new FlightOrders(client);
41+
this.hotelBookings = new HotelBookings(client);
2842
}
2943

3044
public FlightOrder flightOrder(String flightOrderId) {

src/main/java/com/amadeus/Constants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public final class Constants {
1212
public static final String GET = "GET";
1313
public static final String POST = "POST";
1414
public static final String PUT = "PUT";
15+
public static final String DELETE = "DELETE";
1516

1617

1718
public static final String HTTPS = "https";

src/main/java/com/amadeus/HTTPClient.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,43 @@ public Response get(String path, Params params) throws ResponseException {
6767
return request(Constants.GET, path, params, null);
6868
}
6969

70+
/**
71+
* <p>
72+
* A helper module for making generic DELETE requests calls. It is used by
73+
* every namespaced API DELETE method.
74+
* </p>
75+
*
76+
* <pre>
77+
* amadeus.booking.flightOrder("eJzTd9f3NjIJdzUGAAp%2fAiY=").delete();
78+
* </pre>
79+
*
80+
* <p>
81+
* It can be used to make any generic API call that is automatically
82+
* authenticated using your API credentials:
83+
* </p>
84+
*
85+
* <pre>
86+
* amadeus.delete("/v1/foo/bar", Params.with("airline", "1X"));
87+
* </pre>
88+
*
89+
* @param path The full path for the API call
90+
* @param params The optional DELETE params to pass to the API
91+
* @return a Response object containing the status code, body, and parsed data.
92+
*/
93+
public Response delete(String path, Params params) throws ResponseException {
94+
return request(Constants.DELETE, path, params, null);
95+
}
96+
97+
/**
98+
* A helper module for making generic DELETE requests calls. It is used by
99+
* every namespaced API DELETE method.
100+
*
101+
* @see Amadeus#delete(String, Params)
102+
*/
103+
public Response delete(String path) throws ResponseException {
104+
return request(Constants.DELETE, path, null,null);
105+
}
106+
70107
/**
71108
* A helper module for making generic POST requests calls. It is used by
72109
* every namespaced API POST method.

src/main/java/com/amadeus/booking/FlightOrder.java

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,43 @@ public com.amadeus.resources.FlightOrder get(Params params) throws ResponseExcep
5555
return (com.amadeus.resources.FlightOrder) Resource.fromObject(
5656
response, com.amadeus.resources.FlightOrder.class);
5757
}
58-
58+
5959
/**
6060
* Convenience method for calling <code>get</code> without any parameters.
6161
* @see com.amadeus.booking.FlightOrder#get()
6262
*/
6363
public com.amadeus.resources.FlightOrder get() throws ResponseException {
6464
return get(null);
6565
}
66+
67+
/**
68+
* <p>
69+
* Allows you to cancel a flight order. The flightOfferId
70+
* used is an example for educational purposes. In test enviromnent
71+
* it's temporary.
72+
* </p>
73+
*
74+
* <pre>
75+
* FlightOrder order = amadeus.booking.flightOrder.(
76+
* "eJzTd9f3NjIJdzUGAAp%2fAiY=").delete();
77+
* </pre>
78+
* @param params the parameters to send to the API
79+
* @return an API response object
80+
* @throws ResponseException when an exception occurs
81+
*/
82+
83+
public com.amadeus.resources.FlightOrder delete(Params params) throws ResponseException {
84+
String path = String.format("/v1/booking/flight-orders/%s", flightOfferId);
85+
Response response = client.delete(path, params);
86+
return (com.amadeus.resources.FlightOrder) Resource.fromObject(
87+
response, com.amadeus.resources.FlightOrder.class);
88+
}
89+
90+
/**
91+
* Convenience method for calling <code>delete</code> without any parameters.
92+
* @see com.amadeus.booking.FlightOrder#delete()
93+
*/
94+
public com.amadeus.resources.FlightOrder delete() throws ResponseException {
95+
return delete(null);
96+
}
6697
}
Lines changed: 78 additions & 0 deletions
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.HotelBooking;
7+
import com.amadeus.resources.Resource;
8+
import com.google.gson.JsonObject;
9+
10+
/**
11+
* <p>
12+
* A namespaced client for the
13+
* <code>/v1/booking/hotel-bookings</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.hotelBookings;</pre>
23+
*/
24+
public class HotelBookings {
25+
private Amadeus client;
26+
27+
/**
28+
* Constructor.
29+
*
30+
* @hide
31+
*/
32+
public HotelBookings(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.hotelBookings.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 HotelBooking[] post(JsonObject body) throws ResponseException {
49+
Response response = client.post("/v1/booking/hotel-bookings", body);
50+
return (HotelBooking[]) Resource.fromArray(response, HotelBooking[].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.hotelBookings.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 HotelBooking[] post(String body) throws ResponseException {
66+
Response response = client.post("/v1/booking/hotel-bookings", body);
67+
return (HotelBooking[]) Resource.fromArray(response, HotelBooking[].class);
68+
}
69+
70+
/**
71+
* Convenience method for calling <code>post</code> without any parameters.
72+
*
73+
* @see HotelBookings#post()
74+
*/
75+
public HotelBooking[] post() throws ResponseException {
76+
return post((String) null);
77+
}
78+
}

src/main/java/com/amadeus/referenceData/Locations.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
import com.amadeus.Response;
66
import com.amadeus.exceptions.ResponseException;
77
import com.amadeus.referenceData.locations.Airports;
8+
import com.amadeus.referenceData.locations.PointOfInterest;
89
import com.amadeus.referenceData.locations.PointsOfInterest;
910
import com.amadeus.resources.Location;
1011
import com.amadeus.resources.Resource;
11-
import com.google.gson.Gson;
1212

1313
/**
1414
* <p>
@@ -49,6 +49,13 @@ public class Locations {
4949
*/
5050
public PointsOfInterest pointsOfInterest;
5151

52+
/**
53+
* <p>
54+
* A namespaced client for the
55+
* <code>/v2/reference-data/locations/pois</code> endpoints.
56+
* </p>
57+
*/
58+
public PointOfInterest pointOfInterest;
5259

5360
/**
5461
* Constructor.
@@ -86,4 +93,8 @@ public Location[] get(Params params) throws ResponseException {
8693
public Location[] get() throws ResponseException {
8794
return get(null);
8895
}
96+
97+
public PointOfInterest pointOfInterest(String id) {
98+
return new PointOfInterest(client, id);
99+
}
89100
}

0 commit comments

Comments
 (0)