Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comments: add Cache-Control arguments #141

Merged
merged 1 commit into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading