Skip to content

Commit 96d3d82

Browse files
committed
Add flight shopping urls
1 parent b87839e commit 96d3d82

File tree

7 files changed

+274
-2
lines changed

7 files changed

+274
-2
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,19 @@ public class Amadeus extends HTTPClient {
3838
*/
3939
public Travel travel;
4040

41+
/**
42+
* <p>
43+
* A namespaced client for the
44+
* <code>/v1/shopping</code> endpoints.
45+
* </p>
46+
*/
47+
public Shopping shopping;
48+
4149
protected Amadeus(Configuration configuration) {
4250
super(configuration);
4351
this.referenceData = new ReferenceData(this);
4452
this.travel = new Travel(this);
53+
this.shopping = new Shopping(this);
4554
}
4655

4756
/**
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package com.amadeus;
2+
3+
import com.amadeus.shopping.FlightDates;
4+
import com.amadeus.shopping.FlightDestinations;
5+
import com.amadeus.shopping.FlightOffers;
6+
7+
/**
8+
* <p>
9+
* A namespaced client for the
10+
* <code>/v2/travel</code> endpoints.
11+
* </p>
12+
*
13+
* <p>
14+
* Access via the Amadeus client object.
15+
* </p>
16+
*
17+
* <pre>
18+
* Amadeus amadeus = Amadeus.builder("clientId", "secret").build();
19+
* amadeus.travel;</pre>
20+
*
21+
* @hide
22+
*/
23+
public class Shopping {
24+
/**
25+
* <p>
26+
* A namespaced client for the
27+
* <code>/v1/shopping/flight-dates</code> endpoints.
28+
* </p>
29+
*/
30+
public FlightDates flightDates;
31+
32+
/**
33+
* <p>
34+
* A namespaced client for the
35+
* <code>/v1/shopping/flight-destinations</code> endpoints.
36+
* </p>
37+
*/
38+
public FlightDestinations flightDestinations;
39+
40+
/**
41+
* <p>
42+
* A namespaced client for the
43+
* <code>/v1/shopping/flight-offers</code> endpoints.
44+
* </p>
45+
*/
46+
public FlightOffers flightOffers;
47+
48+
/**
49+
* Constructor.
50+
* @hide
51+
*/
52+
public Shopping(Amadeus client) {
53+
this.flightDates = new FlightDates(client);
54+
this.flightDestinations = new FlightDestinations(client);
55+
this.flightOffers = new FlightOffers(client);
56+
}
57+
}

src/main/java/com/amadeus/Travel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
*
1515
* <pre>
1616
* Amadeus amadeus = Amadeus.builder("clientId", "secret").build();
17-
* amadeus.referenceData;</pre>
17+
* amadeus.travel;</pre>
1818
*
1919
* @hide
2020
*/
2121
public class Travel {
2222
/**
2323
* <p>
2424
* A namespaced client for the
25-
* <code>v2/travel/analytics</code> endpoints.
25+
* <code>/v2/travel/analytics</code> endpoints.
2626
* </p>
2727
*/
2828
public Analytics analytics;
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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+
8+
/**
9+
* <p>
10+
* A namespaced client for the
11+
* <code>/v1/shopping/flight-dates</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.shopping.flightDates;</pre>
21+
*/
22+
public class FlightDates {
23+
private Amadeus client;
24+
25+
/**
26+
* Constructor.
27+
* @hide
28+
*/
29+
public FlightDates(Amadeus client) {
30+
this.client = client;
31+
}
32+
33+
/**
34+
* <p>
35+
* Find the cheapest flight dates from an
36+
* origin to a destination.
37+
* </p>
38+
*
39+
* <pre>
40+
* amadeus.shopping.flightDates.get(Params
41+
* .with("origin", "LHR")
42+
* .and("destination", "PAR"));</pre>
43+
*
44+
* @param params the parameters to send to the API
45+
* @return an API response object
46+
* @throws ResponseException when an exception occurs
47+
*/
48+
public Response get(Params params) throws ResponseException {
49+
return client.get("/v1/shopping/flight-dates", params);
50+
}
51+
52+
/**
53+
* Convenience method for calling <code>get</code> without any parameters.
54+
* @see FlightDates#get()
55+
*/
56+
public Response get() throws ResponseException {
57+
return get(null);
58+
}
59+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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+
8+
/**
9+
* <p>
10+
* A namespaced client for the
11+
* <code>/v1/shopping/flight-destinations</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.shopping.flightDestinations;</pre>
21+
*/
22+
public class FlightDestinations {
23+
private Amadeus client;
24+
25+
/**
26+
* Constructor.
27+
* @hide
28+
*/
29+
public FlightDestinations(Amadeus client) {
30+
this.client = client;
31+
}
32+
33+
/**
34+
* <p>
35+
* Find the cheapest destinations where
36+
* you can fly to.
37+
* </p>
38+
*
39+
* <pre>
40+
* amadeus.shopping.flightDestinations.get(Params
41+
* .with("origin", "LHR"));</pre>
42+
*
43+
* @param params the parameters to send to the API
44+
* @return an API response object
45+
* @throws ResponseException when an exception occurs
46+
*/
47+
public Response get(Params params) throws ResponseException {
48+
return client.get("/v1/shopping/flight-destinations", params);
49+
}
50+
51+
/**
52+
* Convenience method for calling <code>get</code> without any parameters.
53+
* @see FlightDestinations#get()
54+
*/
55+
public Response get() throws ResponseException {
56+
return get(null);
57+
}
58+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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+
8+
/**
9+
* <p>
10+
* A namespaced client for the
11+
* <code>/v1/shopping/flight-offers</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.shopping.flightOffers;</pre>
21+
*/
22+
public class FlightOffers {
23+
private Amadeus client;
24+
25+
/**
26+
* Constructor.
27+
* @hide
28+
*/
29+
public FlightOffers(Amadeus client) {
30+
this.client = client;
31+
}
32+
33+
/**
34+
* <p>
35+
* Find the cheapest bookable flights.
36+
* </p>
37+
*
38+
* <pre>
39+
* amadeus.shopping.flightOffers.get(Params
40+
* .with("origin", "LHR")
41+
* .and("destination", "LAX")
42+
* .and("departureDate", "2017-12-24"));</pre>
43+
*
44+
* @param params the parameters to send to the API
45+
* @return an API response object
46+
* @throws ResponseException when an exception occurs
47+
*/
48+
public Response get(Params params) throws ResponseException {
49+
return client.get("/v1/shopping/flight-offers", params);
50+
}
51+
52+
/**
53+
* Convenience method for calling <code>get</code> without any parameters.
54+
* @see FlightOffers#get()
55+
*/
56+
public Response get() throws ResponseException {
57+
return get(null);
58+
}
59+
}

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
import com.amadeus.exceptions.ResponseException;
99
import com.amadeus.referenceData.urls.CheckinLinks;
10+
import com.amadeus.shopping.FlightDates;
11+
import com.amadeus.shopping.FlightDestinations;
12+
import com.amadeus.shopping.FlightOffers;
1013
import com.amadeus.travel.analytics.FareSearches;
1114
import com.amadeus.travel.analytics.airTraffic.Traveled;
1215
import org.junit.Test;
@@ -17,6 +20,9 @@ public class NamespaceTest {
1720
assertNotNull(client.referenceData.urls.checkinLinks);
1821
assertNotNull(client.travel.analytics.airTraffic.traveled);
1922
assertNotNull(client.travel.analytics.fareSearches);
23+
assertNotNull(client.shopping.flightDates);
24+
assertNotNull(client.shopping.flightDestinations);
25+
assertNotNull(client.shopping.flightOffers);
2026
}
2127

2228
@Test public void testGetMethods() throws ResponseException {
@@ -46,5 +52,29 @@ public class NamespaceTest {
4652
FareSearches fareSearches = new FareSearches(client);
4753
assertTrue(fareSearches.get() instanceof Response);
4854
assertTrue(fareSearches.get(params) instanceof Response);
55+
56+
when(client.get("/v1/shopping/flight-dates", null))
57+
.thenReturn(mock(Response.class));
58+
when(client.get("/v1/shopping/flight-dates", params))
59+
.thenReturn(mock(Response.class));
60+
FlightDates flightDates = new FlightDates(client);
61+
assertTrue(flightDates.get() instanceof Response);
62+
assertTrue(flightDates.get(params) instanceof Response);
63+
64+
when(client.get("/v1/shopping/flight-destinations", null))
65+
.thenReturn(mock(Response.class));
66+
when(client.get("/v1/shopping/flight-destinations", params))
67+
.thenReturn(mock(Response.class));
68+
FlightDestinations flightDestinations = new FlightDestinations(client);
69+
assertTrue(flightDestinations.get() instanceof Response);
70+
assertTrue(flightDestinations.get(params) instanceof Response);
71+
72+
when(client.get("/v1/shopping/flight-offers", null))
73+
.thenReturn(mock(Response.class));
74+
when(client.get("/v1/shopping/flight-offers", params))
75+
.thenReturn(mock(Response.class));
76+
FlightOffers flightOffers = new FlightOffers(client);
77+
assertTrue(flightOffers.get() instanceof Response);
78+
assertTrue(flightOffers.get(params) instanceof Response);
4979
}
5080
}

0 commit comments

Comments
 (0)