From 550db86b3efae88f8a08d1f0e82daa07d8b4d4ee Mon Sep 17 00:00:00 2001 From: Sidd Date: Tue, 28 Jun 2022 15:54:21 -0500 Subject: [PATCH 1/2] feat: implement updated soundtrack playlist api --- .../github/twitch4j/helix/TwitchHelix.java | 29 +++++++++----- .../domain/SoundtrackPlaylistTracks.java | 39 ------------------- .../domain/SoundtrackPlaylistTracksList.java | 25 ++++++++++++ .../SoundtrackPlaylistTracksWrapper.java | 30 -------------- .../helix/domain/SoundtrackTrack.java | 7 ++++ 5 files changed, 51 insertions(+), 79 deletions(-) delete mode 100644 rest-helix/src/main/java/com/github/twitch4j/helix/domain/SoundtrackPlaylistTracks.java create mode 100644 rest-helix/src/main/java/com/github/twitch4j/helix/domain/SoundtrackPlaylistTracksList.java delete mode 100644 rest-helix/src/main/java/com/github/twitch4j/helix/domain/SoundtrackPlaylistTracksWrapper.java diff --git a/rest-helix/src/main/java/com/github/twitch4j/helix/TwitchHelix.java b/rest-helix/src/main/java/com/github/twitch4j/helix/TwitchHelix.java index 335050132..38b9de339 100644 --- a/rest-helix/src/main/java/com/github/twitch4j/helix/TwitchHelix.java +++ b/rest-helix/src/main/java/com/github/twitch4j/helix/TwitchHelix.java @@ -927,31 +927,40 @@ HystrixCommand getSoundtrackCurrentTrack( ); /** - * Gets a Soundtrack playlist, which includes its list of tracks. + * Gets the tracks of a Soundtrack playlist. * - * @param authToken App access token or User access token. - * @param id The ASIN of the Soundtrack playlist to get. - * @return SoundtrackPlaylistTracksWrapper + * @param authToken Required: App access token or User access token. + * @param id Required: The ID of the Soundtrack playlist to get. + * @param limit Optional: The maximum number of tracks to return for this playlist in the response. The minimum number of tracks is 1 and the maximum is 100. The default is 20. + * @param after Optional: The cursor used to get the next page of tracks for this playlist. The Pagination object in the response contains the cursor’s value. + * @return SoundtrackPlaylistTracksList */ @Unofficial // beta - @RequestLine("GET /soundtrack/playlist?id={id}") + @RequestLine("GET /soundtrack/playlist?id={id}&first={first}&after={after}") @Headers("Authorization: Bearer {token}") - HystrixCommand getSoundtrackPlaylist( + HystrixCommand getSoundtrackPlaylist( @Param("token") String authToken, - @Param("id") String id + @Param("id") String id, + @Param("first") Integer limit, + @Param("after") String after ); /** * Gets a list of Soundtrack playlists. + *

+ * The list contains information about the playlists, such as their titles and descriptions. + * To get a playlist’s tracks, call {@link #getSoundtrackPlaylist(String, String, Integer, String)} and specify the playlist’s ID. * - * @param authToken App access token or User access token. + * @param authToken Required: App access token or User access token. + * @param id Optional: The ID of the Soundtrack playlist to get. Specify an ID only if you want to get a single playlist instead of all playlists. * @return SoundtrackPlaylistMetadataList */ @Unofficial // beta - @RequestLine("GET /soundtrack/playlists") + @RequestLine("GET /soundtrack/playlists?id={id}") @Headers("Authorization: Bearer {token}") HystrixCommand getSoundtrackPlaylists( - @Param("token") String authToken + @Param("token") String authToken, + @Param("id") String id ); /** diff --git a/rest-helix/src/main/java/com/github/twitch4j/helix/domain/SoundtrackPlaylistTracks.java b/rest-helix/src/main/java/com/github/twitch4j/helix/domain/SoundtrackPlaylistTracks.java deleted file mode 100644 index 5e656bd9b..000000000 --- a/rest-helix/src/main/java/com/github/twitch4j/helix/domain/SoundtrackPlaylistTracks.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.github.twitch4j.helix.domain; - -import lombok.AccessLevel; -import lombok.Data; -import lombok.Setter; - -import java.util.List; - -@Data -@Setter(AccessLevel.PRIVATE) -public class SoundtrackPlaylistTracks { - - /** - * The playlist’s title. - */ - private String title; - - /** - * The playlist’s ASIN (Amazon Standard Identification Number). - */ - private String id; - - /** - * A URL to the playlist’s image art. - * Is empty if the playlist doesn't include art. - */ - private String imageUrl; - - /** - * A short description about the music that the playlist includes. - */ - private String description; - - /** - * The list of tracks in the playlist. - */ - private List catalogTracks; - -} diff --git a/rest-helix/src/main/java/com/github/twitch4j/helix/domain/SoundtrackPlaylistTracksList.java b/rest-helix/src/main/java/com/github/twitch4j/helix/domain/SoundtrackPlaylistTracksList.java new file mode 100644 index 000000000..512409071 --- /dev/null +++ b/rest-helix/src/main/java/com/github/twitch4j/helix/domain/SoundtrackPlaylistTracksList.java @@ -0,0 +1,25 @@ +package com.github.twitch4j.helix.domain; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AccessLevel; +import lombok.Data; +import lombok.Setter; + +import java.util.List; + +@Data +@Setter(AccessLevel.PRIVATE) +public class SoundtrackPlaylistTracksList { + + /** + * The list of tracks in the playlist. + */ + @JsonProperty("data") + private List tracks; + + /** + * Cursor for forward pagination; used to tell the server where to start fetching the next set of results, in a multi-page response. + */ + private HelixPagination pagination; + +} diff --git a/rest-helix/src/main/java/com/github/twitch4j/helix/domain/SoundtrackPlaylistTracksWrapper.java b/rest-helix/src/main/java/com/github/twitch4j/helix/domain/SoundtrackPlaylistTracksWrapper.java deleted file mode 100644 index 2b29c274f..000000000 --- a/rest-helix/src/main/java/com/github/twitch4j/helix/domain/SoundtrackPlaylistTracksWrapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.github.twitch4j.helix.domain; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AccessLevel; -import lombok.Data; -import lombok.Setter; - -import java.util.List; -import java.util.Optional; - -@Data -@Setter(AccessLevel.PRIVATE) -public class SoundtrackPlaylistTracksWrapper { - - /** - * A list that contains the single playlist you requested. - */ - @JsonProperty("data") - private List playlists; - - /** - * @return the single playlist you requested. - */ - public Optional getPlaylist() { - if (playlists == null || playlists.isEmpty()) - return Optional.empty(); - return Optional.ofNullable(playlists.get(0)); - } - -} diff --git a/rest-helix/src/main/java/com/github/twitch4j/helix/domain/SoundtrackTrack.java b/rest-helix/src/main/java/com/github/twitch4j/helix/domain/SoundtrackTrack.java index ac2e07caf..53195634c 100644 --- a/rest-helix/src/main/java/com/github/twitch4j/helix/domain/SoundtrackTrack.java +++ b/rest-helix/src/main/java/com/github/twitch4j/helix/domain/SoundtrackTrack.java @@ -1,5 +1,6 @@ package com.github.twitch4j.helix.domain; +import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AccessLevel; import lombok.Data; import lombok.Setter; @@ -30,6 +31,12 @@ public class SoundtrackTrack { */ private String id; + /** + * The track’s ISRC (International Standard Recording Code). + */ + @JsonProperty("isrc") + private String code; + /** * The track’s title. */ From 7809b879327a14997a8795e94beaf0e055e1e3b4 Mon Sep 17 00:00:00 2001 From: Sidd Date: Mon, 11 Jul 2022 14:53:56 -0500 Subject: [PATCH 2/2] feat: add undocumented pagination to getSoundtrackPlaylists --- .../java/com/github/twitch4j/helix/TwitchHelix.java | 10 +++++++--- .../helix/domain/SoundtrackPlaylistMetadataList.java | 7 +++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/rest-helix/src/main/java/com/github/twitch4j/helix/TwitchHelix.java b/rest-helix/src/main/java/com/github/twitch4j/helix/TwitchHelix.java index 38b9de339..31ff363f7 100644 --- a/rest-helix/src/main/java/com/github/twitch4j/helix/TwitchHelix.java +++ b/rest-helix/src/main/java/com/github/twitch4j/helix/TwitchHelix.java @@ -931,7 +931,7 @@ HystrixCommand getSoundtrackCurrentTrack( * * @param authToken Required: App access token or User access token. * @param id Required: The ID of the Soundtrack playlist to get. - * @param limit Optional: The maximum number of tracks to return for this playlist in the response. The minimum number of tracks is 1 and the maximum is 100. The default is 20. + * @param limit Optional: The maximum number of tracks to return for this playlist in the response. The minimum number of tracks is 1 and the maximum is 50. The default is 20. * @param after Optional: The cursor used to get the next page of tracks for this playlist. The Pagination object in the response contains the cursor’s value. * @return SoundtrackPlaylistTracksList */ @@ -953,14 +953,18 @@ HystrixCommand getSoundtrackPlaylist( * * @param authToken Required: App access token or User access token. * @param id Optional: The ID of the Soundtrack playlist to get. Specify an ID only if you want to get a single playlist instead of all playlists. + * @param limit Optional: The maximum number of playlists to return in the response. The minimum number of playlists is 1 and the maximum is 50. The default is 20. + * @param after Optional: The cursor used to get the next page of playlists. The Pagination object in the response contains the cursor’s value. * @return SoundtrackPlaylistMetadataList */ @Unofficial // beta - @RequestLine("GET /soundtrack/playlists?id={id}") + @RequestLine("GET /soundtrack/playlists?id={id}&first={first}&after={after}") @Headers("Authorization: Bearer {token}") HystrixCommand getSoundtrackPlaylists( @Param("token") String authToken, - @Param("id") String id + @Param("id") String id, + @Param("first") Integer limit, + @Param("after") String after ); /** diff --git a/rest-helix/src/main/java/com/github/twitch4j/helix/domain/SoundtrackPlaylistMetadataList.java b/rest-helix/src/main/java/com/github/twitch4j/helix/domain/SoundtrackPlaylistMetadataList.java index fe1825a66..b475c975a 100644 --- a/rest-helix/src/main/java/com/github/twitch4j/helix/domain/SoundtrackPlaylistMetadataList.java +++ b/rest-helix/src/main/java/com/github/twitch4j/helix/domain/SoundtrackPlaylistMetadataList.java @@ -1,6 +1,7 @@ package com.github.twitch4j.helix.domain; import com.fasterxml.jackson.annotation.JsonProperty; +import com.github.twitch4j.common.annotation.Unofficial; import lombok.AccessLevel; import lombok.Data; import lombok.Setter; @@ -17,4 +18,10 @@ public class SoundtrackPlaylistMetadataList { @JsonProperty("data") private List playlists; + /** + * Cursor for forward pagination: tells the server where to start fetching the next set of results, in a multi-page response. + */ + @Unofficial + private HelixPagination pagination; + }