Skip to content

Commit

Permalink
Add variants of comments that accept Cache-Control header
Browse files Browse the repository at this point in the history
  • Loading branch information
UweTrottmann committed May 24, 2024
1 parent a8e44ad commit c8b1b15
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Change Log
## Next version
_in development

* Deprecated TV rage ID, it appears to be no longer used.
* Deprecated TV rage ID, it appears to be no longer used.
* Add variants of the comments methods that accept a `Cache-Control` header.
This can be used to skip the local cache and get the latest comments from the server.
* Update retrofit [2.9.0 -> 2.11.0].
* Update okhttp [4.10.0 -> 4.12.0].
* Update gson [2.9.1 -> 2.11.0].
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/uwetrottmann/trakt5/services/Episodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.uwetrottmann.trakt5.enums.Extended;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Path;
import retrofit2.http.Query;

Expand Down Expand Up @@ -62,6 +63,20 @@ Call<List<Comment>> comments(
@Query(value = "extended", encoded = true) Extended extended
);

/**
* Variant that allows changing the Cache-Control header.
*/
@GET("shows/{id}/seasons/{season}/episodes/{episode}/comments")
Call<List<Comment>> comments(
@Path("id") String showId,
@Path("season") int season,
@Path("episode") int episode,
@Query("page") Integer page,
@Query("limit") Integer limit,
@Query(value = "extended", encoded = true) Extended extended,
@Header("Cache-Control") String cacheControl
);

/**
* Returns rating (between 0 and 10) and distribution for an episode.
*
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/uwetrottmann/trakt5/services/Movies.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.uwetrottmann.trakt5.enums.Extended;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Path;
import retrofit2.http.Query;

Expand Down Expand Up @@ -107,6 +108,18 @@ Call<List<Comment>> comments(
@Query(value = "extended", encoded = true) Extended extended
);

/**
* Variant that allows changing the Cache-Control header.
*/
@GET("movies/{id}/comments")
Call<List<Comment>> comments(
@Path("id") String movieId,
@Query("page") Integer page,
@Query("limit") Integer limit,
@Query(value = "extended", encoded = true) Extended extended,
@Header("Cache-Control") String cacheControl
);

/**
* Returns all actors, directors, writers, and producers for a movie.
*
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/uwetrottmann/trakt5/services/Seasons.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.uwetrottmann.trakt5.enums.Extended;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Path;
import retrofit2.http.Query;

Expand Down Expand Up @@ -67,6 +68,16 @@ Call<List<Comment>> comments(
@Path("season") int season
);

/**
* Variant that allows changing the Cache-Control header.
*/
@GET("shows/{id}/seasons/{season}/comments")
Call<List<Comment>> comments(
@Path("id") String showId,
@Path("season") int season,
@Header("Cache-Control") String cacheControl
);

/**
* Returns rating (between 0 and 10) and distribution for a season.
*
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/uwetrottmann/trakt5/services/Shows.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.uwetrottmann.trakt5.enums.ProgressLastActivity;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Path;
import retrofit2.http.Query;

Expand Down Expand Up @@ -109,6 +110,18 @@ Call<List<Comment>> comments(
@Query(value = "extended", encoded = true) Extended extended
);

/**
* Variant that allows changing the Cache-Control header.
*/
@GET("shows/{id}/comments")
Call<List<Comment>> comments(
@Path("id") String showId,
@Query("page") Integer page,
@Query("limit") Integer limit,
@Query(value = "extended", encoded = true) Extended extended,
@Header("Cache-Control") String cacheControl
);

/**
* <b>OAuth Required</b>
*
Expand Down

0 comments on commit c8b1b15

Please sign in to comment.