Skip to content

Commit 3620493

Browse files
committed
support docs and tests
1 parent f09aab4 commit 3620493

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
@@ -318,6 +318,7 @@ OnTime AirportOnTime = amadeus.airport.predictions.onTime.get(Params
318318
.with("airportCode", "NCE")
319319
.and("date", "2020-09-01"));
320320

321+
// What's the likelihood of a given flight to be delayed?
321322
Delay[] flightDelay = amadeus.travel.predictions.flightDelay.get(Params
322323
.with("originLocationCode", "NCE")
323324
.and("destinationLocationCode", "IST")
@@ -329,6 +330,14 @@ Delay[] flightDelay = amadeus.travel.predictions.flightDelay.get(Params
329330
.and("carrierCode", "TK")
330331
.and("flightNumber", "1816")
331332
.and("duration", "PT31H10M"));
333+
334+
// What is the the seat map of a given flight?
335+
SeatMap[] seatmap = amadeus.shopping.seatMaps.get(Params
336+
.with("flight-orderId", "eJzTd9f3NjIJdzUGAAp%2fAiY="));
337+
338+
// What is the the seat map of a given flight?
339+
// The body can be a String version of your JSON or a JsonObject
340+
SeatMap[] seatmap = amadeus.shopping.seatMaps..post(body);
332341
```
333342

334343
## 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
@@ -9,7 +9,6 @@
99
import com.amadeus.referenceData.locations.Airports;
1010
import com.amadeus.referenceData.locations.PointsOfInterest;
1111
import com.amadeus.referenceData.urls.CheckinLinks;
12-
import com.amadeus.resources.Delay;
1312
import com.amadeus.shopping.FlightDates;
1413
import com.amadeus.shopping.FlightDestinations;
1514
import com.amadeus.shopping.FlightOffers;
@@ -18,6 +17,7 @@
1817
import com.amadeus.shopping.HotelOffers;
1918
import com.amadeus.shopping.HotelOffersByHotel;
2019
import com.amadeus.shopping.flightOffers.Prediction;
20+
import com.amadeus.shopping.SeatMaps;
2121
import com.amadeus.travel.analytics.airTraffic.Booked;
2222
import com.amadeus.travel.analytics.airTraffic.BusiestPeriod;
2323
import com.amadeus.travel.analytics.airTraffic.Traveled;
@@ -57,6 +57,7 @@ public void testAllNamespacesExist() {
5757
TestCase.assertNotNull(client.shopping.flightOffers.prediction);
5858
TestCase.assertNotNull(client.shopping.hotelOffers);
5959
TestCase.assertNotNull(client.shopping.hotelOffersByHotel);
60+
TestCase.assertNotNull(client.shopping.seatMaps);
6061
TestCase.assertNotNull(client.ereputation.hotelSentiments);
6162
TestCase.assertNotNull(client.shopping.hotelOffer("XXX"));
6263
TestCase.assertNotNull(client.airport.predictions.onTime);
@@ -277,6 +278,14 @@ public void testGetMethods() throws ResponseException {
277278
FlightDelay flightDelay = new FlightDelay(client);
278279
TestCase.assertNotNull(flightDelay.get());
279280
TestCase.assertNotNull(flightDelay.get(params));
281+
282+
// Test SeatMaps get
283+
Mockito.when(client.get("/v1/shopping/seatmaps", null))
284+
.thenReturn(multiResponse);
285+
Mockito.when(client.get("/v1/shopping/seatmaps", params))
286+
.thenReturn(multiResponse);
287+
SeatMaps seatmap = new SeatMaps(client);
288+
TestCase.assertNotNull(seatmap.get(params));
280289
}
281290

282291
@Test
@@ -302,5 +311,16 @@ public void testPostMethods() throws ResponseException {
302311
TestCase.assertNotNull(flightOfferSearch.post());
303312
TestCase.assertNotNull(flightOfferSearch.post(body));
304313
TestCase.assertEquals(flightOfferSearch.post().length, 2);
314+
315+
// Test SeatMaps post
316+
Mockito.when(client.post("/v1/shopping/seatmaps", (String) null))
317+
.thenReturn(multiResponse);
318+
Mockito.when(client.post("/v1/shopping/seatmaps", body))
319+
.thenReturn(multiResponse);
320+
Mockito.when(client.post("/v1/shopping/seatmaps", jsonObject))
321+
.thenReturn(multiResponse);
322+
SeatMaps seatmap = new SeatMaps(client);
323+
TestCase.assertNotNull(seatmap.post());
324+
TestCase.assertNotNull(seatmap.post(body));
305325
}
306326
}

0 commit comments

Comments
 (0)