Skip to content

Commit 2276e56

Browse files
committed
Merge branch 'master' into seatmaps
2 parents 7fd04d2 + ee7d849 commit 2276e56

File tree

6 files changed

+197
-0
lines changed

6 files changed

+197
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,10 @@ FlightOfferSearch[] flightOffersSearches = amadeus.shopping.flightOffersSearch.g
238238
// body can be a String version of your JSON or a JsonObject
239239
FlightOfferSearch[] flightOffersSearches = amadeus.shopping.flightOffersSearch.post(body);
240240

241+
// Flight Order Management
242+
// The flightOrderID comes from the Flight Create Orders (in test environment it's temporary)
243+
FlightOrder order = amadeus.booking.flightOrder("eJzTd9f3NjIJdzUGAAp%2fAiY=").get();
244+
241245
// Flight Choice Prediction
242246
// Note that the example calls 2 APIs: Flight Low-fare Search & Flight Choice Prediction
243247
FlightOffer[] flightOffers = amadeus.shopping.flightOffers

src/main/java/com/amadeus/Amadeus.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,21 @@ public class Amadeus extends HTTPClient {
6262
*/
6363
public Airport airport;
6464

65+
/**
66+
* <p>
67+
* A namespaced client for the <code>/v1/booking</code> endpoints.
68+
* </p>
69+
*/
70+
public Booking booking;
71+
6572
protected Amadeus(Configuration configuration) {
6673
super(configuration);
6774
this.referenceData = new ReferenceData(this);
6875
this.travel = new Travel(this);
6976
this.shopping = new Shopping(this);
7077
this.ereputation = new EReputation(this);
7178
this.airport = new Airport(this);
79+
this.booking = new Booking(this);
7280
}
7381

7482
/**
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.amadeus;
2+
3+
import com.amadeus.booking.FlightOrder;
4+
5+
public class Booking {
6+
private Amadeus client;
7+
8+
/**
9+
* <p>
10+
* A namespaced client for the
11+
* <code>/v1/booking/flightOrder</code> endpoints.
12+
* </p>
13+
*/
14+
public FlightOrder flightOrder;
15+
16+
public Booking(Amadeus client) {
17+
this.client = client;
18+
}
19+
20+
public FlightOrder flightOrder(String flightOrderId) {
21+
return new FlightOrder(client, flightOrderId);
22+
}
23+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package com.amadeus.booking;
2+
3+
import com.amadeus.Amadeus;
4+
import com.amadeus.Params;
5+
import com.amadeus.Response;
6+
import com.amadeus.exceptions.ResponseException;
7+
import com.amadeus.resources.Resource;
8+
9+
/**
10+
* <p>
11+
* A namespaced client for the
12+
* <code>/v1/booking/flight-orders/:flightOrderId</code> endpoints.
13+
* </p>
14+
*
15+
* <p>
16+
* Access via the Amadeus client object.
17+
* </p>
18+
*
19+
* <pre>
20+
* Amadeus amadeus = Amadeus.builder("clientId", "secret").build();
21+
* amadeus.booking.flightOrder;</pre>
22+
*/
23+
public class FlightOrder {
24+
private Amadeus client;
25+
private String flightOfferId;
26+
27+
/**
28+
* Constructor.
29+
* @hide
30+
*/
31+
public FlightOrder(Amadeus client, String flightOfferId) {
32+
this.client = client;
33+
this.flightOfferId = flightOfferId;
34+
}
35+
36+
/**
37+
* <p>
38+
* Allows you to manipulate a flight order. The flightOfferId
39+
* used is an example for educational purposes. In test enviromnent
40+
* it's temporary.
41+
* </p>
42+
*
43+
* <pre>
44+
* FlightOrder order = amadeus.booking.flightOrder.(
45+
* "eJzTd9f3NjIJdzUGAAp%2fAiY=").get();
46+
* </pre>
47+
* @param params the parameters to send to the API
48+
* @return an API response object
49+
* @throws ResponseException when an exception occurs
50+
*/
51+
52+
public com.amadeus.resources.FlightOrder get(Params params) throws ResponseException {
53+
String path = String.format("/v1/booking/flight-orders/%s", flightOfferId);
54+
Response response = client.get(path, params);
55+
return (com.amadeus.resources.FlightOrder) Resource.fromObject(
56+
response, com.amadeus.resources.FlightOrder.class);
57+
}
58+
59+
/**
60+
* Convenience method for calling <code>get</code> without any parameters.
61+
* @see com.amadeus.booking.FlightOrder#get()
62+
*/
63+
public com.amadeus.resources.FlightOrder get() throws ResponseException {
64+
return get(null);
65+
}
66+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
package com.amadeus.resources;
2+
3+
import java.util.Date;
4+
import lombok.Getter;
5+
import lombok.ToString;
6+
7+
/**
8+
* An Airline object as returned by the Airline Code LookUp API.
9+
* @see com.amadeus.booking.flightOrder#get()
10+
*/
11+
@ToString
12+
public class FlightOrder extends Resource {
13+
protected FlightOrder() {}
14+
15+
private @Getter String type;
16+
private @Getter String id;
17+
private @Getter String queuingOfficeId;
18+
private @Getter AssociatedRecord[] associatedRecords;
19+
private @Getter Traveler[] travelers;
20+
private @Getter FlightOfferSearch[] flightOffers;
21+
22+
@ToString
23+
public class AssociatedRecord {
24+
protected AssociatedRecord() {
25+
}
26+
27+
private @Getter String reference;
28+
private @Getter String creationDateTime;
29+
private @Getter String originSystemCode;
30+
private @Getter String flightOfferId;
31+
}
32+
33+
@ToString
34+
public class Traveler {
35+
protected Traveler() {
36+
}
37+
38+
private @Getter String id;
39+
private @Getter Date dateOfBirth;
40+
private @Getter Name name;
41+
private @Getter Contact contact;
42+
private @Getter Document[] documents;
43+
}
44+
45+
@ToString
46+
public class Name {
47+
protected Name() {
48+
}
49+
50+
private @Getter String firstName;
51+
private @Getter String lastName;
52+
}
53+
54+
@ToString
55+
public class Contact {
56+
protected Contact() {
57+
}
58+
59+
private @Getter Phone[] phones;
60+
}
61+
62+
@ToString
63+
public class Document {
64+
protected Document() {
65+
}
66+
67+
private @Getter String documentType;
68+
private @Getter String number;
69+
private @Getter Date expiryDate;
70+
private @Getter String issuanceCountry;
71+
private @Getter String nationality;
72+
private @Getter boolean holder;
73+
}
74+
75+
@ToString
76+
public class Phone {
77+
78+
protected Phone() {
79+
}
80+
81+
private @Getter String countryCallingCode;
82+
private @Getter String number;
83+
}
84+
85+
}

src/test/java/com/amadeus/NamespaceTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.amadeus;
22

33
import com.amadeus.airport.predictions.AirportOnTime;
4+
import com.amadeus.booking.FlightOrder;
45
import com.amadeus.ereputation.HotelSentiments;
56
import com.amadeus.exceptions.ResponseException;
67
import com.amadeus.referenceData.Airlines;
@@ -61,6 +62,7 @@ public void testAllNamespacesExist() {
6162
TestCase.assertNotNull(client.ereputation.hotelSentiments);
6263
TestCase.assertNotNull(client.shopping.hotelOffer("XXX"));
6364
TestCase.assertNotNull(client.airport.predictions.onTime);
65+
TestCase.assertNotNull(client.booking.flightOrder("XXX"));
6466
}
6567

6668
@Before
@@ -286,6 +288,15 @@ public void testGetMethods() throws ResponseException {
286288
.thenReturn(multiResponse);
287289
SeatMaps seatmap = new SeatMaps(client);
288290
TestCase.assertNotNull(seatmap.get(params));
291+
292+
// Test fetching a specific offer
293+
Mockito.when(client.get("/v1/booking/flight-orders/XXX", null))
294+
.thenReturn(singleResponse);
295+
Mockito.when(client.get("/v1/booking/flight-orders/XXX", params))
296+
.thenReturn(singleResponse);
297+
FlightOrder flightOrder = new FlightOrder(client, "XXX");
298+
TestCase.assertNotNull(flightOrder.get());
299+
TestCase.assertNotNull(flightOrder.get(params));
289300
}
290301

291302
@Test

0 commit comments

Comments
 (0)