Merge pull request #44 from aviemzur/get-movie-recommendations

Get movie recommendations method
This commit is contained in:
Stuart Boston
2018-01-25 15:22:22 +00:00
committed by GitHub
5 changed files with 45 additions and 0 deletions
@@ -35,6 +35,7 @@ public enum MovieMethod implements AppendToResponseMethod {
IMAGES,
KEYWORDS,
LISTS,
RECOMMENDATIONS,
RELEASES,
REVIEWS,
SIMILAR,
@@ -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<MovieInfo> 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<MovieInfo> 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.
*
@@ -94,6 +94,7 @@ public class MovieInfo extends MovieBasic implements Serializable, Identificatio
private List<Video> videos = Collections.emptyList();
private List<Translation> translations = Collections.emptyList();
private List<MovieInfo> similarMovies = Collections.emptyList();
private List<MovieInfo> recommendations = Collections.emptyList();
private List<Review> reviews = Collections.emptyList();
private List<UserList> lists = Collections.emptyList();
private List<ChangeKeyItem> changes = Collections.emptyList();
@@ -295,6 +296,12 @@ public class MovieInfo extends MovieBasic implements Serializable, Identificatio
addMethod(MovieMethod.LISTS);
}
@JsonSetter("recommendations")
public void seRecommendations(WrapperGenericList<MovieInfo> recommendations) {
this.recommendations = recommendations.getResults();
addMethod(MovieMethod.RECOMMENDATIONS);
}
@JsonSetter("reviews")
public void setReviews(WrapperGenericList<Review> reviews) {
this.reviews = reviews.getResults();
@@ -62,6 +62,7 @@ public enum MethodSub {
RATED_MOVIES_GUEST("rated_movies"),
RATED_TV("rated/tv"),
RATING("rating"),
RECOMMENDATIONS("recommendations"),
RELEASES("releases"),
REMOVE_ITEM("remove_item"),
REVIEWS("reviews"),
@@ -326,6 +326,24 @@ public class TmdbMoviesTest extends AbstractTests {
}
}
/**
* Test of getRecommendations method, of class TmdbMovies.
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
public void testGetRecommendations() throws MovieDbException {
LOG.info("getRecommendations");
String language = LANGUAGE_DEFAULT;
for (TestID test : FILM_IDS) {
ResultList<MovieInfo> result = instance.getRecommendations(test.getTmdb(), language);
TestSuite.test(result, "Recommendations");
}
}
/**
* Test of getMovieReviews method, of class TmdbMovies.
*