Skip to content

Commit cdc8fc9

Browse files
authored
Merge pull request #53 from amadeus4dev/seatmaps
Add support for SeatMap
2 parents ee7d849 + 2276e56 commit cdc8fc9

File tree

5 files changed

+223
-1
lines changed

5 files changed

+223
-1
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ OnTime AirportOnTime = amadeus.airport.predictions.onTime.get(Params
322322
.with("airportCode", "NCE")
323323
.and("date", "2020-09-01"));
324324

325+
// What's the likelihood of a given flight to be delayed?
325326
Delay[] flightDelay = amadeus.travel.predictions.flightDelay.get(Params
326327
.with("originLocationCode", "NCE")
327328
.and("destinationLocationCode", "IST")
@@ -333,6 +334,14 @@ Delay[] flightDelay = amadeus.travel.predictions.flightDelay.get(Params
333334
.and("carrierCode", "TK")
334335
.and("flightNumber", "1816")
335336
.and("duration", "PT31H10M"));
337+
338+
// What is the the seat map of a given flight?
339+
SeatMap[] seatmap = amadeus.shopping.seatMaps.get(Params
340+
.with("flight-orderId", "eJzTd9f3NjIJdzUGAAp%2fAiY="));
341+
342+
// What is the the seat map of a given flight?
343+
// The body can be a String version of your JSON or a JsonObject
344+
SeatMap[] seatmap = amadeus.shopping.seatMaps.post(body);
336345
```
337346

338347
## Development & Contributing

src/main/java/com/amadeus/Shopping.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.amadeus.shopping.HotelOffer;
88
import com.amadeus.shopping.HotelOffers;
99
import com.amadeus.shopping.HotelOffersByHotel;
10+
import com.amadeus.shopping.SeatMaps;
1011

1112
/**
1213
* <p>
@@ -75,6 +76,14 @@ public class Shopping {
7576
*/
7677
public HotelOffersByHotel hotelOffersByHotel;
7778

79+
/**
80+
* <p>
81+
* A namespaced client for the
82+
* <code>/v1/shopping/seatmaps</code> endpoints.
83+
* </p>
84+
*/
85+
public SeatMaps seatMaps;
86+
7887
/**
7988
* Constructor.
8089
* @hide
@@ -87,6 +96,7 @@ public Shopping(Amadeus client) {
8796
this.hotelOffers = new HotelOffers(client);
8897
this.hotelOffersByHotel = new HotelOffersByHotel(client);
8998
this.flightOffersSearch = new FlightOffersSearch(client);
99+
this.seatMaps = new SeatMaps(client);
90100
}
91101

92102
/**
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package com.amadeus.resources;
2+
3+
import lombok.Getter;
4+
import lombok.ToString;
5+
6+
/**
7+
* An SeatMap object as returned by the SeatMap API.
8+
* @see com.amadeus.booking.SeatMaps#get()
9+
* @see com.amadeus.booking.SeatMaps#post() */
10+
@ToString
11+
public class SeatMap extends Resource {
12+
protected SeatMap() {}
13+
14+
private @Getter String type;
15+
private @Getter String flightOfferid;
16+
private @Getter String segmentid;
17+
private @Getter String carrierCode;
18+
private @Getter String number;
19+
private @Getter Aircraft aircraft;
20+
private @Getter Departure departure;
21+
private @Getter Deck[] decks;
22+
23+
@ToString
24+
public class Aircraft {
25+
protected Aircraft() {
26+
}
27+
28+
private @Getter String code;
29+
}
30+
31+
@ToString
32+
public class Departure {
33+
protected Departure() {
34+
}
35+
36+
private @Getter String iataCode;
37+
private @Getter String at;
38+
}
39+
40+
@ToString
41+
public class Arrival {
42+
protected Arrival() {
43+
}
44+
45+
private @Getter String iataCode;
46+
}
47+
48+
@ToString
49+
public class Deck {
50+
protected Deck() {
51+
}
52+
53+
private @Getter String deckType;
54+
private @Getter DeckConfiguration deckConfiguration;
55+
56+
}
57+
58+
@ToString
59+
public class DeckConfiguration {
60+
protected DeckConfiguration() {
61+
}
62+
63+
private @Getter int width;
64+
private @Getter int length;
65+
private @Getter int startseatRow;
66+
private @Getter int endSeatRow;
67+
private @Getter int startWingsRow;
68+
private @Getter int endWingsRow;
69+
private @Getter int startWingsX;
70+
private @Getter int endWingsX;
71+
72+
}
73+
74+
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
package com.amadeus.shopping;
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+
import com.amadeus.resources.SeatMap;
9+
import com.google.gson.JsonObject;
10+
11+
/**
12+
* <p>
13+
* A namespaced client for the
14+
* <code>/v1/shopping/seatmaps</code> endpoints.
15+
* </p>
16+
*
17+
* <p>
18+
* Access via the Amadeus client object.
19+
* </p>
20+
*
21+
* <pre>
22+
* Amadeus amadeus = Amadeus.builder(API_KEY, API_SECRET).build();
23+
* amadeus.shopping.seatMaps;</pre>
24+
*/
25+
public class SeatMaps {
26+
private Amadeus client;
27+
28+
/**
29+
* Constructor.
30+
*
31+
* @hide
32+
*/
33+
public SeatMaps(Amadeus client) {
34+
this.client = client;
35+
}
36+
37+
/**
38+
* <p>
39+
* The SeatMap API allows you to retrieve the seat map of one or several
40+
* flights based on the flight-orderId returned by the Flight Create Orders API.
41+
* </p>
42+
*
43+
* <pre>
44+
* amadeus.shopping.seatMaps.get(params);</pre>
45+
*
46+
* @param params the parameters to send to the API
47+
* @return an API resource
48+
* @throws ResponseException when an exception occurs
49+
*/
50+
public SeatMap[] get(Params params) throws ResponseException {
51+
Response response = client.get("/v1/shopping/seatmaps", params);
52+
return (SeatMap[]) Resource.fromArray(response, SeatMap[].class);
53+
}
54+
55+
/**
56+
* Convenience method for calling <code>get</code> without any parameters.
57+
* @see SeatMaps#get()
58+
*/
59+
public SeatMap[] get() throws ResponseException {
60+
return get(null);
61+
}
62+
63+
/**
64+
* <p>
65+
* The SeatMap API allows you to retrieve the seat map of one or several
66+
* Take the body of a flight offer search or flight offer price and pass
67+
* it in to this method to get a seatmap.
68+
* </p>
69+
*
70+
* <pre>
71+
* amadeus.shopping.seatMaps.post(body);</pre>
72+
*
73+
* @param body the parameters to send to the API as a JSonObject
74+
* @return an API resource
75+
* @throws ResponseException when an exception occurs
76+
*/
77+
public SeatMap[] post(JsonObject body) throws ResponseException {
78+
Response response = client.post("/v1/shopping/seatmaps", body);
79+
return (SeatMap[]) Resource.fromArray(response, SeatMap[].class);
80+
}
81+
82+
/**
83+
* <p>
84+
* The SeatMap API allows you to retrieve the seat map of one or several
85+
* Take the body of a flight offer search or flight offer price and pass
86+
* it in to this method to get a seatmap.
87+
* </p>
88+
*
89+
* <pre>
90+
* amadeus.shopping.seatMaps.post(body);</pre>
91+
*
92+
* @param body the parameters to send to the API as a String
93+
* @return an API resource
94+
* @throws ResponseException when an exception occurs
95+
*/
96+
public SeatMap[] post(String body) throws ResponseException {
97+
Response response = client.post("/v1/shopping/seatmaps", body);
98+
return (SeatMap[]) Resource.fromArray(response, SeatMap[].class);
99+
}
100+
101+
/**
102+
* Convenience method for calling <code>post</code> without any parameters.
103+
*
104+
* @see SeatMaps#post()
105+
*/
106+
public SeatMap[] post() throws ResponseException {
107+
return post((String) null);
108+
}
109+
}

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
import com.amadeus.referenceData.locations.Airports;
1111
import com.amadeus.referenceData.locations.PointsOfInterest;
1212
import com.amadeus.referenceData.urls.CheckinLinks;
13-
import com.amadeus.resources.Delay;
1413
import com.amadeus.shopping.FlightDates;
1514
import com.amadeus.shopping.FlightDestinations;
1615
import com.amadeus.shopping.FlightOffers;
1716
import com.amadeus.shopping.FlightOffersSearch;
1817
import com.amadeus.shopping.HotelOffer;
1918
import com.amadeus.shopping.HotelOffers;
2019
import com.amadeus.shopping.HotelOffersByHotel;
20+
import com.amadeus.shopping.SeatMaps;
2121
import com.amadeus.shopping.flightOffers.Prediction;
2222
import com.amadeus.travel.analytics.airTraffic.Booked;
2323
import com.amadeus.travel.analytics.airTraffic.BusiestPeriod;
@@ -58,6 +58,7 @@ public void testAllNamespacesExist() {
5858
TestCase.assertNotNull(client.shopping.flightOffers.prediction);
5959
TestCase.assertNotNull(client.shopping.hotelOffers);
6060
TestCase.assertNotNull(client.shopping.hotelOffersByHotel);
61+
TestCase.assertNotNull(client.shopping.seatMaps);
6162
TestCase.assertNotNull(client.ereputation.hotelSentiments);
6263
TestCase.assertNotNull(client.shopping.hotelOffer("XXX"));
6364
TestCase.assertNotNull(client.airport.predictions.onTime);
@@ -280,6 +281,14 @@ public void testGetMethods() throws ResponseException {
280281
TestCase.assertNotNull(flightDelay.get());
281282
TestCase.assertNotNull(flightDelay.get(params));
282283

284+
// Test SeatMaps get
285+
Mockito.when(client.get("/v1/shopping/seatmaps", null))
286+
.thenReturn(multiResponse);
287+
Mockito.when(client.get("/v1/shopping/seatmaps", params))
288+
.thenReturn(multiResponse);
289+
SeatMaps seatmap = new SeatMaps(client);
290+
TestCase.assertNotNull(seatmap.get(params));
291+
283292
// Test fetching a specific offer
284293
Mockito.when(client.get("/v1/booking/flight-orders/XXX", null))
285294
.thenReturn(singleResponse);
@@ -313,5 +322,16 @@ public void testPostMethods() throws ResponseException {
313322
TestCase.assertNotNull(flightOfferSearch.post());
314323
TestCase.assertNotNull(flightOfferSearch.post(body));
315324
TestCase.assertEquals(flightOfferSearch.post().length, 2);
325+
326+
// Test SeatMaps post
327+
Mockito.when(client.post("/v1/shopping/seatmaps", (String) null))
328+
.thenReturn(multiResponse);
329+
Mockito.when(client.post("/v1/shopping/seatmaps", body))
330+
.thenReturn(multiResponse);
331+
Mockito.when(client.post("/v1/shopping/seatmaps", jsonObject))
332+
.thenReturn(multiResponse);
333+
SeatMaps seatmap = new SeatMaps(client);
334+
TestCase.assertNotNull(seatmap.post());
335+
TestCase.assertNotNull(seatmap.post(body));
316336
}
317337
}

0 commit comments

Comments
 (0)