diff --git a/src/main/java/info/movito/themoviedbapi/TmdbTrending.java b/src/main/java/info/movito/themoviedbapi/TmdbTrending.java index 7e3b142..758bc89 100644 --- a/src/main/java/info/movito/themoviedbapi/TmdbTrending.java +++ b/src/main/java/info/movito/themoviedbapi/TmdbTrending.java @@ -15,8 +15,6 @@ public class TmdbTrending extends AbstractTmdbApi { protected static final String TMDB_METHOD_TRENDING = "trending"; - private static final String TMDB_PARAM_TIME_WINDOW = "time_window"; - /** * Create a new TmdbTrending instance to call the rending TMDb API methods. */ @@ -34,8 +32,7 @@ public class TmdbTrending extends AbstractTmdbApi { * @throws TmdbException If there was an error making the request or mapping the response. */ public MultiResultsPage getAll(TimeWindow timeWindow, String language) throws TmdbException { - ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TRENDING, "all"); - apiUrl.addPathParam(TMDB_PARAM_TIME_WINDOW, timeWindow.getValue()); + ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TRENDING, "all", timeWindow.getValue()); apiUrl.addLanguage(language); return mapJsonResult(apiUrl, MultiResultsPage.class); } @@ -50,8 +47,7 @@ public MultiResultsPage getAll(TimeWindow timeWindow, String language) throws Tm * @throws TmdbException If there was an error making the request or mapping the response. */ public MovieResultsPage getMovies(TimeWindow timeWindow, String language) throws TmdbException { - ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TRENDING, "movie"); - apiUrl.addPathParam(TMDB_PARAM_TIME_WINDOW, timeWindow.getValue()); + ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TRENDING, "movie", timeWindow.getValue()); apiUrl.addLanguage(language); return mapJsonResult(apiUrl, MovieResultsPage.class); } @@ -66,8 +62,7 @@ public MovieResultsPage getMovies(TimeWindow timeWindow, String language) throws * @throws TmdbException If there was an error making the request or mapping the response. */ public PopularPersonResultsPage getPeople(TimeWindow timeWindow, String language) throws TmdbException { - ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TRENDING, "person"); - apiUrl.addPathParam(TMDB_PARAM_TIME_WINDOW, timeWindow.getValue()); + ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TRENDING, "person", timeWindow.getValue()); apiUrl.addLanguage(language); return mapJsonResult(apiUrl, PopularPersonResultsPage.class); } @@ -82,8 +77,7 @@ public PopularPersonResultsPage getPeople(TimeWindow timeWindow, String language * @throws TmdbException If there was an error making the request or mapping the response. */ public TvSeriesResultsPage getTv(TimeWindow timeWindow, String language) throws TmdbException { - ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TRENDING, "tv"); - apiUrl.addPathParam(TMDB_PARAM_TIME_WINDOW, timeWindow.getValue()); + ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TRENDING, "tv", timeWindow.getValue()); apiUrl.addLanguage(language); return mapJsonResult(apiUrl, TvSeriesResultsPage.class); } diff --git a/src/test/java/info/movito/themoviedbapi/TmdbTrendingTest.java b/src/test/java/info/movito/themoviedbapi/TmdbTrendingTest.java index 3b94580..e1f69c8 100644 --- a/src/test/java/info/movito/themoviedbapi/TmdbTrendingTest.java +++ b/src/test/java/info/movito/themoviedbapi/TmdbTrendingTest.java @@ -34,7 +34,7 @@ public TmdbTrending createApiToTest() { @Test public void testGetAll() throws IOException, TmdbException { String body = TestUtils.readTestFile("api_responses/trending/all.json"); - URL url = new URL(TMDB_API_BASE_URL + TMDB_METHOD_TRENDING + "/all?time_window=week&language=en-US"); + URL url = new URL(TMDB_API_BASE_URL + TMDB_METHOD_TRENDING + "/all/week?language=en-US"); when(getTmdbUrlReader().readUrl(url, null, RequestType.GET)).thenReturn(body); MultiResultsPage allResults = getApiToTest().getAll(TimeWindow.WEEK, "en-US"); @@ -48,7 +48,7 @@ public void testGetAll() throws IOException, TmdbException { @Test public void testGetMovies() throws IOException, TmdbException { String body = TestUtils.readTestFile("api_responses/trending/movies.json"); - URL url = new URL(TMDB_API_BASE_URL + TMDB_METHOD_TRENDING + "/movie?time_window=week&language=en-US"); + URL url = new URL(TMDB_API_BASE_URL + TMDB_METHOD_TRENDING + "/movie/week?language=en-US"); when(getTmdbUrlReader().readUrl(url, null, RequestType.GET)).thenReturn(body); MovieResultsPage movieResults = getApiToTest().getMovies(TimeWindow.WEEK, "en-US"); @@ -62,7 +62,7 @@ public void testGetMovies() throws IOException, TmdbException { @Test public void testGetPeople() throws IOException, TmdbException { String body = TestUtils.readTestFile("api_responses/trending/people.json"); - URL url = new URL(TMDB_API_BASE_URL + TMDB_METHOD_TRENDING + "/person?time_window=week&language=en-US"); + URL url = new URL(TMDB_API_BASE_URL + TMDB_METHOD_TRENDING + "/person/week?language=en-US"); when(getTmdbUrlReader().readUrl(url, null, RequestType.GET)).thenReturn(body); PopularPersonResultsPage peopleResults = getApiToTest().getPeople(TimeWindow.WEEK, "en-US"); @@ -76,7 +76,7 @@ public void testGetPeople() throws IOException, TmdbException { @Test public void testGetTv() throws IOException, TmdbException { String body = TestUtils.readTestFile("api_responses/trending/tv.json"); - URL url = new URL(TMDB_API_BASE_URL + TMDB_METHOD_TRENDING + "/tv?time_window=week&language=en-US"); + URL url = new URL(TMDB_API_BASE_URL + TMDB_METHOD_TRENDING + "/tv/week?language=en-US"); when(getTmdbUrlReader().readUrl(url, null, RequestType.GET)).thenReturn(body); TvSeriesResultsPage tvResults = getApiToTest().getTv(TimeWindow.WEEK, "en-US");