Skip to content

Commit bc0a60e

Browse files
authored
Merge pull request #83 from amadeus4dev/travel-recommendations
Add support for Travel Recommendations API
2 parents 3d3ef78 + 0d29f94 commit bc0a60e

File tree

4 files changed

+89
-0
lines changed

4 files changed

+89
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,11 @@ Prediction tripPurpose = amadeus.travel.predictions.tripPurpose.get(Params
351351
.and("destinationLocationCode", "MAD")
352352
.and("departureDate", "2020-08-01")
353353
.and("returnDate", "2020-08-12"));
354+
355+
// Travel Recommendations
356+
Location destinations = amadeus.referenceData.recommendedLocations.get(Params
357+
.with("cityCodes", "PAR")
358+
.and("travelerCountryCode", "FR"));
354359
```
355360

356361
## Development & Contributing

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.amadeus.referenceData.Airlines;
44
import com.amadeus.referenceData.Location;
55
import com.amadeus.referenceData.Locations;
6+
import com.amadeus.referenceData.RecommendedLocations;
67
import com.amadeus.referenceData.Urls;
78

89
/**
@@ -48,6 +49,14 @@ public class ReferenceData {
4849
*/
4950
public Airlines airlines;
5051

52+
/**
53+
* <p>
54+
* A namespaced client for the
55+
* <code>/v1/reference-data/recommended-locations</code> endpoints.
56+
* </p>
57+
*/
58+
public RecommendedLocations recommendedLocations;
59+
5160

5261
/**
5362
* Constructor.
@@ -58,6 +67,7 @@ public ReferenceData(Amadeus client) {
5867
this.urls = new Urls(client);
5968
this.locations = new Locations(client);
6069
this.airlines = new Airlines(client);
70+
this.recommendedLocations = new RecommendedLocations(client);
6171
}
6272

6373
/**
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package com.amadeus.referenceData;
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.Location;
8+
import com.amadeus.resources.Resource;
9+
import com.google.gson.Gson;
10+
11+
/**
12+
* <p>
13+
* A namespaced client for the
14+
* <code>/v1/reference-data/recommended-locations</code> endpoints.
15+
* </p>
16+
*
17+
* <p>
18+
* Access via the Amadeus client object.
19+
* </p>
20+
*
21+
* <pre>
22+
* Amadeus amadeus = Amadeus.builder("clientId", "secret").build();
23+
* amadeus.referenceData.recommendedLocations;</pre>
24+
*/
25+
public class RecommendedLocations {
26+
private Amadeus client;
27+
28+
/**
29+
* Constructor.
30+
* @hide
31+
*/
32+
public RecommendedLocations(Amadeus client) {
33+
this.client = client;
34+
}
35+
36+
/**
37+
* <p>
38+
* Returns a list of destination recommendations.
39+
* </p>
40+
*
41+
* <pre>
42+
* amadeus.referenceData.recommendedLocations.get(Params
43+
* .with("cityCodes", "PAR")
44+
* .and("travelerCountryCode", "FR"));</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 Location[] get(Params params) throws ResponseException {
51+
Response response = client.get("/v1/reference-data/recommended-locations", params);
52+
return (Location[]) Resource.fromArray(response, Location[].class);
53+
}
54+
55+
/**
56+
* Convenience method for calling <code>get</code> without any parameters.
57+
* @see Location#get()
58+
*/
59+
public Location[] get() throws ResponseException {
60+
return get(null);
61+
}
62+
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.amadeus.referenceData.Airlines;
1111
import com.amadeus.referenceData.Location;
1212
import com.amadeus.referenceData.Locations;
13+
import com.amadeus.referenceData.RecommendedLocations;
1314
import com.amadeus.referenceData.locations.Airports;
1415
import com.amadeus.referenceData.locations.PointsOfInterest;
1516
import com.amadeus.referenceData.urls.CheckinLinks;
@@ -54,6 +55,7 @@ public void testAllNamespacesExist() {
5455
TestCase.assertNotNull(client.referenceData.locations.pointsOfInterest.bySquare);
5556
TestCase.assertNotNull(client.referenceData.locations.pointOfInterest("XXX"));
5657
TestCase.assertNotNull(client.referenceData.location("123"));
58+
TestCase.assertNotNull(client.referenceData.recommendedLocations);
5759
TestCase.assertNotNull(client.referenceData.airlines);
5860
TestCase.assertNotNull(client.travel.analytics.airTraffic.traveled);
5961
TestCase.assertNotNull(client.travel.analytics.airTraffic.booked);
@@ -164,6 +166,16 @@ public void testGetMethods() throws ResponseException {
164166
TestCase.assertNotNull(poi.get(params));
165167
TestCase.assertEquals(poi.get().length, 2);
166168

169+
// Testing travel recommendations
170+
Mockito.when(client.get("/v1/reference-data/recommended-locations", null))
171+
.thenReturn(multiResponse);
172+
Mockito.when(client.get("/v1/reference-data/recommended-locations", params))
173+
.thenReturn(multiResponse);
174+
RecommendedLocations destinations = new RecommendedLocations(client);
175+
TestCase.assertNotNull(destinations.get());
176+
TestCase.assertNotNull(destinations.get(params));
177+
TestCase.assertEquals(destinations.get().length, 2);
178+
167179
// Testing safe place by coordinates
168180
Mockito.when(client.get("/v1/safety/safety-rated-locations", null))
169181
.thenReturn(multiResponse);

0 commit comments

Comments
 (0)