diff --git a/README.md b/README.md index 0b3ca689..12f9cbb7 100644 --- a/README.md +++ b/README.md @@ -351,6 +351,11 @@ Prediction tripPurpose = amadeus.travel.predictions.tripPurpose.get(Params .and("destinationLocationCode", "MAD") .and("departureDate", "2020-08-01") .and("returnDate", "2020-08-12")); + +// Travel Recommendations +Location destinations = amadeus.referenceData.recommendedLocations.get(Params + .with("cityCodes", "PAR") + .and("travelerCountryCode", "FR")); ``` ## Development & Contributing diff --git a/src/main/java/com/amadeus/ReferenceData.java b/src/main/java/com/amadeus/ReferenceData.java index 34f2700f..3b96d843 100644 --- a/src/main/java/com/amadeus/ReferenceData.java +++ b/src/main/java/com/amadeus/ReferenceData.java @@ -3,6 +3,7 @@ import com.amadeus.referenceData.Airlines; import com.amadeus.referenceData.Location; import com.amadeus.referenceData.Locations; +import com.amadeus.referenceData.RecommendedLocations; import com.amadeus.referenceData.Urls; /** @@ -48,6 +49,14 @@ public class ReferenceData { */ public Airlines airlines; + /** + *
+ * A namespaced client for the
+ * /v1/reference-data/recommended-locations
endpoints.
+ *
+ * A namespaced client for the
+ * /v1/reference-data/recommended-locations
endpoints.
+ *
+ * Access via the Amadeus client object. + *
+ * + *+ * Amadeus amadeus = Amadeus.builder("clientId", "secret").build(); + * amadeus.referenceData.recommendedLocations;+ */ +public class RecommendedLocations { + private Amadeus client; + + /** + * Constructor. + * @hide + */ + public RecommendedLocations(Amadeus client) { + this.client = client; + } + + /** + *
+ * Returns a list of destination recommendations. + *
+ * + *+ * amadeus.referenceData.recommendedLocations.get(Params + * .with("cityCodes", "PAR") + * .and("travelerCountryCode", "FR"));+ * + * @param params the parameters to send to the API + * @return an API response object + * @throws ResponseException when an exception occurs + */ + public Location[] get(Params params) throws ResponseException { + Response response = client.get("/v1/reference-data/recommended-locations", params); + return (Location[]) Resource.fromArray(response, Location[].class); + } + + /** + * Convenience method for calling
get
without any parameters.
+ * @see Location#get()
+ */
+ public Location[] get() throws ResponseException {
+ return get(null);
+ }
+}
diff --git a/src/test/java/com/amadeus/NamespaceTest.java b/src/test/java/com/amadeus/NamespaceTest.java
index 773a5433..10eb9aeb 100644
--- a/src/test/java/com/amadeus/NamespaceTest.java
+++ b/src/test/java/com/amadeus/NamespaceTest.java
@@ -10,6 +10,7 @@
import com.amadeus.referenceData.Airlines;
import com.amadeus.referenceData.Location;
import com.amadeus.referenceData.Locations;
+import com.amadeus.referenceData.RecommendedLocations;
import com.amadeus.referenceData.locations.Airports;
import com.amadeus.referenceData.locations.PointsOfInterest;
import com.amadeus.referenceData.urls.CheckinLinks;
@@ -54,6 +55,7 @@ public void testAllNamespacesExist() {
TestCase.assertNotNull(client.referenceData.locations.pointsOfInterest.bySquare);
TestCase.assertNotNull(client.referenceData.locations.pointOfInterest("XXX"));
TestCase.assertNotNull(client.referenceData.location("123"));
+ TestCase.assertNotNull(client.referenceData.recommendedLocations);
TestCase.assertNotNull(client.referenceData.airlines);
TestCase.assertNotNull(client.travel.analytics.airTraffic.traveled);
TestCase.assertNotNull(client.travel.analytics.airTraffic.booked);
@@ -164,6 +166,16 @@ public void testGetMethods() throws ResponseException {
TestCase.assertNotNull(poi.get(params));
TestCase.assertEquals(poi.get().length, 2);
+ // Testing travel recommendations
+ Mockito.when(client.get("/v1/reference-data/recommended-locations", null))
+ .thenReturn(multiResponse);
+ Mockito.when(client.get("/v1/reference-data/recommended-locations", params))
+ .thenReturn(multiResponse);
+ RecommendedLocations destinations = new RecommendedLocations(client);
+ TestCase.assertNotNull(destinations.get());
+ TestCase.assertNotNull(destinations.get(params));
+ TestCase.assertEquals(destinations.get().length, 2);
+
// Testing safe place by coordinates
Mockito.when(client.get("/v1/safety/safety-rated-locations", null))
.thenReturn(multiResponse);