Skip to content

Commit 52bdbda

Browse files
committed
Watched: support combining extended parameters
1 parent 4518adf commit 52bdbda

5 files changed

Lines changed: 93 additions & 8 deletions

File tree

src/main/java/com/uwetrottmann/trakt5/enums/ExtendedMoviesWatched.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,22 @@
1616

1717
package com.uwetrottmann.trakt5.enums;
1818

19-
public enum ExtendedMoviesWatched implements TraktEnum {
19+
/**
20+
* Extended info options for the watched movies endpoint.
21+
*/
22+
public class ExtendedMoviesWatched implements TraktEnum {
2023

2124
/**
2225
* Return movie details, like overview and rating.
2326
*
2427
* @deprecated Starting 2026-05-30, this will be the default.
2528
*/
2629
@Deprecated
27-
FULL("full");
30+
public static final ExtendedMoviesWatched FULL = new ExtendedMoviesWatched("full");
2831

2932
private final String value;
3033

31-
ExtendedMoviesWatched(String value) {
34+
private ExtendedMoviesWatched(String value) {
3235
this.value = value;
3336
}
3437

src/main/java/com/uwetrottmann/trakt5/enums/ExtendedShowsWatched.java

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,55 @@
1616

1717
package com.uwetrottmann.trakt5.enums;
1818

19-
public enum ExtendedShowsWatched implements TraktEnum {
19+
import java.util.Arrays;
20+
import java.util.stream.Collectors;
21+
22+
/**
23+
* Extended info options for the watched shows endpoint. Use {@link #of(ExtendedShowsWatched...)}
24+
* to combine multiple values into a comma-separated parameter.
25+
*/
26+
public class ExtendedShowsWatched implements TraktEnum {
2027

2128
/**
2229
* Return show details, like overview and rating.
2330
*
2431
* @deprecated Starting 2026-05-30, this will be the default.
2532
*/
2633
@Deprecated
27-
FULL("full"),
34+
public static final ExtendedShowsWatched FULL = new ExtendedShowsWatched("full");
2835

2936
/**
3037
* Exclude watched info for seasons and episodes.
3138
*
3239
* @deprecated Starting 2026-05-30, this will be the default.
3340
*/
3441
@Deprecated
35-
NOSEASONS("noseasons"),
42+
public static final ExtendedShowsWatched NOSEASONS = new ExtendedShowsWatched("noseasons");
3643

3744
/**
3845
* Include season progress information.
3946
* <p>
4047
* Note: until 2026-05-30 this is the default and won't have any effect.
4148
*/
42-
PROGRESS("progress");
49+
public static final ExtendedShowsWatched PROGRESS = new ExtendedShowsWatched("progress");
50+
51+
/**
52+
* Combine multiple extended values into a single comma-separated parameter.
53+
* <p>
54+
* Example: {@code ExtendedShowsWatched.of(FULL, NOSEASONS)} produces {@code "full,noseasons"}.
55+
*/
56+
public static ExtendedShowsWatched of(ExtendedShowsWatched... values) {
57+
if (values == null || values.length == 0) {
58+
throw new IllegalArgumentException("At least one value is required.");
59+
}
60+
return new ExtendedShowsWatched(
61+
Arrays.stream(values).map(ExtendedShowsWatched::toString).collect(Collectors.joining(","))
62+
);
63+
}
4364

4465
private final String value;
4566

46-
ExtendedShowsWatched(String value) {
67+
private ExtendedShowsWatched(String value) {
4768
this.value = value;
4869
}
4970

src/test/java/com/uwetrottmann/trakt5/BaseTestCase.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,27 @@ protected static void assertSyncShows(List<BaseShow> shows, String type) {
266266
}
267267
}
268268

269+
public static void assertWatchedMoviesFull(List<BaseMovie> movies) {
270+
assertThat(movies)
271+
.isNotEmpty()
272+
.allSatisfy(movie -> {
273+
assertThat(movie.movie).isNotNull();
274+
assertThat(movie.movie.rating).isPositive();
275+
});
276+
}
277+
278+
public static void assertWatchedShowsFullNoSeasons(List<BaseShow> shows) {
279+
assertThat(shows)
280+
.isNotEmpty()
281+
.allSatisfy(show -> {
282+
// Check it returns full show info
283+
assertThat(show.show).isNotNull();
284+
assertThat(show.show.rating).isPositive();
285+
// Check on season info is returned
286+
assertThat(show.seasons).isNull();
287+
});
288+
}
289+
269290
public static void assertWatchlistShows(List<BaseShow> shows) {
270291
assertThat(shows).isNotEmpty();
271292
for (BaseShow show : shows) {

src/test/java/com/uwetrottmann/trakt5/services/SyncTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import com.uwetrottmann.trakt5.entities.WatchlistedEpisode;
4747
import com.uwetrottmann.trakt5.entities.WatchlistedSeason;
4848
import com.uwetrottmann.trakt5.enums.Extended;
49+
import com.uwetrottmann.trakt5.enums.ExtendedMoviesWatched;
4950
import com.uwetrottmann.trakt5.enums.ExtendedShowsWatched;
5051
import com.uwetrottmann.trakt5.enums.HistoryType;
5152
import com.uwetrottmann.trakt5.enums.Rating;
@@ -332,6 +333,15 @@ public void test_watchedMovies() throws IOException {
332333
assertSyncMovies(response.body(), "watched");
333334
}
334335

336+
@Test
337+
public void test_watchedMovies_extended() throws IOException {
338+
// Note: Starting 2026-05-30 this extended value will be the default
339+
List<BaseMovie> movies = executeCall(
340+
getTrakt().sync().watchedMovies(PAGE_ONE, LIMIT_MAX, ExtendedMoviesWatched.FULL));
341+
342+
assertWatchedMoviesFull(movies);
343+
}
344+
335345
@Test
336346
public void test_watchedShows() throws IOException {
337347
Response<List<BaseShow>> response = executeCallWithoutReadingBody(
@@ -342,6 +352,16 @@ public void test_watchedShows() throws IOException {
342352
assertSyncShows(response.body(), "watched");
343353
}
344354

355+
@Test
356+
public void test_watchedShows_extended() throws IOException {
357+
// Note: Starting 2026-05-30 these extended values will be the default
358+
List<BaseShow> shows = executeCall(
359+
getTrakt().sync().watchedShows(PAGE_ONE, LIMIT_MAX,
360+
ExtendedShowsWatched.of(ExtendedShowsWatched.FULL, ExtendedShowsWatched.NOSEASONS)));
361+
362+
assertWatchedShowsFullNoSeasons(shows);
363+
}
364+
345365
@Test
346366
public void test_addItemsToWatchedHistory() throws IOException {
347367
// movie

src/test/java/com/uwetrottmann/trakt5/services/UsersTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import com.uwetrottmann.trakt5.entities.WatchlistedEpisode;
4949
import com.uwetrottmann.trakt5.entities.WatchlistedSeason;
5050
import com.uwetrottmann.trakt5.enums.Extended;
51+
import com.uwetrottmann.trakt5.enums.ExtendedMoviesWatched;
5152
import com.uwetrottmann.trakt5.enums.ExtendedShowsWatched;
5253
import com.uwetrottmann.trakt5.enums.HistoryType;
5354
import com.uwetrottmann.trakt5.enums.ListPrivacy;
@@ -550,6 +551,15 @@ public void test_watchedMovies() throws IOException {
550551
assertSyncMovies(response.body(), "watched");
551552
}
552553

554+
@Test
555+
public void test_watchedMovies_extended() throws IOException {
556+
// Note: Starting 2026-05-30 this extended value will be the default
557+
List<BaseMovie> movies = executeCall(
558+
getTrakt().users().watchedMovies(TestData.USER_SLUG, PAGE_ONE, LIMIT_MAX, ExtendedMoviesWatched.FULL));
559+
560+
assertWatchedMoviesFull(movies);
561+
}
562+
553563
@Test
554564
public void test_watchedShows() throws IOException {
555565
Response<List<BaseShow>> response = executeCallWithoutReadingBody(
@@ -560,4 +570,14 @@ public void test_watchedShows() throws IOException {
560570
assertSyncShows(response.body(), "watched");
561571
}
562572

573+
@Test
574+
public void test_watchedShows_extended() throws IOException {
575+
// Note: Starting 2026-05-30 these extended values will be the default
576+
List<BaseShow> shows = executeCall(
577+
getTrakt().users().watchedShows(TestData.USER_SLUG, PAGE_ONE, LIMIT_MAX,
578+
ExtendedShowsWatched.of(ExtendedShowsWatched.FULL, ExtendedShowsWatched.NOSEASONS)));
579+
580+
assertWatchedShowsFullNoSeasons(shows);
581+
}
582+
563583
}

0 commit comments

Comments
 (0)