From d6542d0676a5a53f755b1360cbfeb235968b18f5 Mon Sep 17 00:00:00 2001 From: Aviem Zur Date: Mon, 15 Jan 2018 07:27:27 +0200 Subject: [PATCH] Get movie recommendations method --- .../themoviedbapi/enumeration/MovieMethod.java | 1 + .../themoviedbapi/methods/TmdbMovies.java | 18 ++++++++++++++++++ .../themoviedbapi/model/movie/MovieInfo.java | 7 +++++++ .../themoviedbapi/tools/MethodSub.java | 1 + .../themoviedbapi/methods/TmdbMoviesTest.java | 18 ++++++++++++++++++ 5 files changed, 45 insertions(+) diff --git a/src/main/java/com/omertron/themoviedbapi/enumeration/MovieMethod.java b/src/main/java/com/omertron/themoviedbapi/enumeration/MovieMethod.java index 8dfc69378..ffe03def3 100644 --- a/src/main/java/com/omertron/themoviedbapi/enumeration/MovieMethod.java +++ b/src/main/java/com/omertron/themoviedbapi/enumeration/MovieMethod.java @@ -35,6 +35,7 @@ public enum MovieMethod implements AppendToResponseMethod { IMAGES, KEYWORDS, LISTS, + RECOMMENDATIONS, RELEASES, REVIEWS, SIMILAR, diff --git a/src/main/java/com/omertron/themoviedbapi/methods/TmdbMovies.java b/src/main/java/com/omertron/themoviedbapi/methods/TmdbMovies.java index bf2b67eff..1ef5cd42d 100644 --- a/src/main/java/com/omertron/themoviedbapi/methods/TmdbMovies.java +++ b/src/main/java/com/omertron/themoviedbapi/methods/TmdbMovies.java @@ -262,6 +262,24 @@ public class TmdbMovies extends AbstractMethod { } } + /** + * The recommendations method will let you retrieve the movie recommendations for a particular movie. + * + * @param movieId + * @param language + * @return + * @throws MovieDbException + */ + public ResultList getRecommendations(int movieId, String language) throws MovieDbException { + TmdbParameters parameters = new TmdbParameters(); + parameters.add(Param.ID, movieId); + parameters.add(Param.LANGUAGE, language); + + URL url = new ApiUrl(apiKey, MethodBase.MOVIE).subMethod(MethodSub.RECOMMENDATIONS).buildUrl(parameters); + WrapperGenericList wrapper = processWrapper(getTypeReference(MovieInfo.class), url, "recommendations"); + return wrapper.getResultsList(); + } + /** * This method is used to retrieve all of the release and certification data we have for a specific movie. * diff --git a/src/main/java/com/omertron/themoviedbapi/model/movie/MovieInfo.java b/src/main/java/com/omertron/themoviedbapi/model/movie/MovieInfo.java index 273954898..3f9700101 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/movie/MovieInfo.java +++ b/src/main/java/com/omertron/themoviedbapi/model/movie/MovieInfo.java @@ -94,6 +94,7 @@ public class MovieInfo extends MovieBasic implements Serializable, Identificatio private List