Skip to content

Commit b87839e

Browse files
committed
Add travel APIs
1 parent ed0c658 commit b87839e

File tree

9 files changed

+281
-4
lines changed

9 files changed

+281
-4
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,26 @@ public class Amadeus extends HTTPClient {
2222
*/
2323
public static final String VERSION = "1.0.0";
2424

25+
/**
26+
* <p>
27+
* A namespaced client for the
28+
* <code>/v2/reference-data</code> endpoints.
29+
* </p>
30+
*/
2531
public ReferenceData referenceData;
2632

33+
/**
34+
* <p>
35+
* A namespaced client for the
36+
* <code>/v1/travel</code> endpoints.
37+
* </p>
38+
*/
39+
public Travel travel;
40+
2741
protected Amadeus(Configuration configuration) {
2842
super(configuration);
2943
this.referenceData = new ReferenceData(this);
44+
this.travel = new Travel(this);
3045
}
3146

3247
/**

src/main/java/com/amadeus/ReferenceData.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* <pre>
1616
* Amadeus amadeus = Amadeus.builder("clientId", "secret").build();
1717
* amadeus.referenceData;</pre>
18+
*
19+
* @hide
1820
*/
1921
public class ReferenceData {
2022
/**
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.amadeus;
2+
3+
import com.amadeus.travel.analytics.Analytics;
4+
5+
/**
6+
* <p>
7+
* A namespaced client for the
8+
* <code>/v2/travel</code> endpoints.
9+
* </p>
10+
*
11+
* <p>
12+
* Access via the Amadeus client object.
13+
* </p>
14+
*
15+
* <pre>
16+
* Amadeus amadeus = Amadeus.builder("clientId", "secret").build();
17+
* amadeus.referenceData;</pre>
18+
*
19+
* @hide
20+
*/
21+
public class Travel {
22+
/**
23+
* <p>
24+
* A namespaced client for the
25+
* <code>v2/travel/analytics</code> endpoints.
26+
* </p>
27+
*/
28+
public Analytics analytics;
29+
30+
/**
31+
* Constructor.
32+
* @hide
33+
*/
34+
public Travel(Amadeus client) {
35+
this.analytics = new Analytics(client);
36+
}
37+
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
* <pre>
1717
* Amadeus amadeus = Amadeus.builder("clientId", "secret").build();
1818
* amadeus.referenceData.urls;</pre>
19+
*
20+
* @hide
1921
*/
2022
public class Urls {
2123
/**
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.amadeus.travel.analytics;
2+
3+
import com.amadeus.Amadeus;
4+
5+
/**
6+
* <p>
7+
* A namespaced client for the
8+
* <code>/v1/travel/analytics</code> endpoints.
9+
* </p>
10+
*
11+
* <p>
12+
* Access via the Amadeus client object.
13+
* </p>
14+
*
15+
* <pre>
16+
* Amadeus amadeus = Amadeus.builder("clientId", "secret").build();
17+
* amadeus.travel.analytics;</pre>
18+
*
19+
* @hide
20+
*/
21+
public class Analytics {
22+
/**
23+
* <p>
24+
* A namespaced client for the
25+
* <code>/v1/travel/analytics/air-traffics</code> endpoints.
26+
* </p>
27+
*/
28+
public AirTraffic airTraffic;
29+
30+
/**
31+
* <p>
32+
* A namespaced client for the
33+
* <code>/v1/travel/analytics/fare-searches</code> endpoints.
34+
* </p>
35+
*/
36+
public FareSearches fareSearches;
37+
38+
/**
39+
* Constructor.
40+
* @hide
41+
*/
42+
public Analytics(Amadeus client) {
43+
this.airTraffic = new AirTraffic(client);
44+
this.fareSearches = new FareSearches(client);
45+
}
46+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.amadeus.travel.analytics;
2+
3+
import com.amadeus.Amadeus;
4+
import com.amadeus.travel.analytics.airTraffic.Traveled;
5+
6+
/**
7+
* <p>
8+
* A namespaced client for the
9+
* <code>/v1/travel/analytics/air-traffic</code> endpoints.
10+
* </p>
11+
*
12+
* <p>
13+
* Access via the Amadeus client object.
14+
* </p>
15+
*
16+
* <pre>
17+
* Amadeus amadeus = Amadeus.builder("clientId", "secret").build();
18+
* amadeus.travel.analytics.airTraffic;</pre>
19+
*
20+
* @hide
21+
*/
22+
public class AirTraffic {
23+
/**
24+
* <p>
25+
* A namespaced client for the
26+
* <code>/v1/travel/analytics/air-traffic/traveled</code> endpoints.
27+
* </p>
28+
*/
29+
public Traveled traveled;
30+
31+
/**
32+
* Constructor.
33+
* @hide
34+
*/
35+
public AirTraffic(Amadeus client) {
36+
this.traveled = new Traveled(client);
37+
}
38+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package com.amadeus.travel.analytics;
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/travel/analytics/fare-searches</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.travel.analytics.fareSearches;</pre>
21+
*/
22+
public class FareSearches {
23+
private Amadeus client;
24+
25+
/**
26+
* Constructor.
27+
* @hide
28+
*/
29+
public FareSearches(Amadeus client) {
30+
this.client = client;
31+
}
32+
33+
/**
34+
* <p>
35+
* The Fare Search History API allows to find the number of
36+
* estimated searches from an origin, optionally a destination,
37+
* within a time period when travelers are performing the searches.
38+
* </p>
39+
*
40+
* <pre>
41+
* amadeus.travel.analytics.fareSearches.get(Params
42+
* .with("origin", "LHR")
43+
* .with("sourceCountry", "FR")
44+
* .with("period", 2011);</pre>
45+
*
46+
* @param params the parameters to send to the API
47+
* @return an API response object
48+
* @throws ResponseException when an exception occurs
49+
*/
50+
public Response get(Params params) throws ResponseException {
51+
return client.get("/v1/travel/analytics/air-traffic/traveled", params);
52+
}
53+
54+
/**
55+
* Convenience method for calling <code>get</code> without any parameters.
56+
* @see FareSearches#get()
57+
*/
58+
public Response get() throws ResponseException {
59+
return get(null);
60+
}
61+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package com.amadeus.travel.analytics.airTraffic;
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/travel/analytics/air-traffic/traveled</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.travel.analytics.airTraffis.traveled;</pre>
21+
*/
22+
public class Traveled {
23+
private Amadeus client;
24+
25+
/**
26+
* Constructor.
27+
* @hide
28+
*/
29+
public Traveled(Amadeus client) {
30+
this.client = client;
31+
}
32+
33+
/**
34+
* <p>
35+
* Returns a list of air traffic reports.
36+
* </p>
37+
*
38+
* <pre>
39+
* amadeus.travel.analytics.airTraffic.traveled.get(Params
40+
* .with("origin", "LHR")
41+
* .with("period", "2017-03");</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/travel/analytics/air-traffic/traveled", params);
49+
}
50+
51+
/**
52+
* Convenience method for calling <code>get</code> without any parameters.
53+
* @see Traveled#get()
54+
*/
55+
public Response get() throws ResponseException {
56+
return get(null);
57+
}
58+
}

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

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,44 @@
77

88
import com.amadeus.exceptions.ResponseException;
99
import com.amadeus.referenceData.urls.CheckinLinks;
10+
import com.amadeus.travel.analytics.FareSearches;
11+
import com.amadeus.travel.analytics.airTraffic.Traveled;
1012
import org.junit.Test;
1113

1214
public class NamespaceTest {
1315
@Test public void testAllNamespacesExist() {
1416
Amadeus client = Amadeus.builder("id", "secret").build();
1517
assertNotNull(client.referenceData.urls.checkinLinks);
18+
assertNotNull(client.travel.analytics.airTraffic.traveled);
19+
assertNotNull(client.travel.analytics.fareSearches);
1620
}
1721

1822
@Test public void testGetMethods() throws ResponseException {
1923
Amadeus client = mock(Amadeus.class);
24+
Params params = Params.with("airline", "1X");
2025

2126
when(client.get("/v2/reference-data/urls/checkin-links", null))
2227
.thenReturn(mock(Response.class));
28+
when(client.get("/v2/reference-data/urls/checkin-links", params))
29+
.thenReturn(mock(Response.class));
2330
CheckinLinks checkinLinks = new CheckinLinks(client);
2431
assertTrue(checkinLinks.get() instanceof Response);
32+
assertTrue(checkinLinks.get(params) instanceof Response);
2533

26-
Params params = Params.with("airline", "1X");
27-
when(client.get("/v2/reference-data/urls/checkin-links", params))
34+
when(client.get("/v1/travel/analytics/air-traffic/traveled", null))
2835
.thenReturn(mock(Response.class));
29-
checkinLinks = new CheckinLinks(client);
30-
assertTrue(checkinLinks.get(params) instanceof Response);
36+
when(client.get("/v1/travel/analytics/air-traffic/traveled", params))
37+
.thenReturn(mock(Response.class));
38+
Traveled traveled = new Traveled(client);
39+
assertTrue(traveled.get() instanceof Response);
40+
assertTrue(traveled.get(params) instanceof Response);
41+
42+
when(client.get("/v1/travel/analytics/fare-searches", null))
43+
.thenReturn(mock(Response.class));
44+
when(client.get("/v1/travel/analytics/fare-searches", params))
45+
.thenReturn(mock(Response.class));
46+
FareSearches fareSearches = new FareSearches(client);
47+
assertTrue(fareSearches.get() instanceof Response);
48+
assertTrue(fareSearches.get(params) instanceof Response);
3149
}
3250
}

0 commit comments

Comments
 (0)