@@ -7,10 +7,14 @@ import com.adamratzman.spotify.SpotifyRestAction
77import com.adamratzman.spotify.SpotifyScope
88import com.adamratzman.spotify.http.SpotifyEndpoint
99import com.adamratzman.spotify.models.AlbumUri
10+ import com.adamratzman.spotify.models.EpisodeUri
1011import com.adamratzman.spotify.models.PagingObject
1112import com.adamratzman.spotify.models.PlayableUri
1213import com.adamratzman.spotify.models.SavedAlbum
14+ import com.adamratzman.spotify.models.SavedEpisode
15+ import com.adamratzman.spotify.models.SavedShow
1316import com.adamratzman.spotify.models.SavedTrack
17+ import com.adamratzman.spotify.models.ShowUri
1418import com.adamratzman.spotify.models.serialization.toList
1519import com.adamratzman.spotify.models.serialization.toNonNullablePagingObject
1620import com.adamratzman.spotify.utils.Market
@@ -118,6 +122,105 @@ public class ClientLibraryApi(api: GenericSpotifyApi) : SpotifyEndpoint(api) {
118122 market : Market ? = null
119123 ): SpotifyRestAction <PagingObject <SavedAlbum >> = SpotifyRestAction { getSavedAlbums(limit, offset, market) }
120124
125+ /* *
126+ * Get a list of shows saved in the current Spotify user’s library.
127+ * Optional parameters can be used to limit the number of shows returned.
128+ *
129+ * **Requires** the [SpotifyScope.USER_LIBRARY_READ] scope
130+ *
131+ * **[Api Reference](https://developer.spotify.com/documentation/web-api/reference/library/get-users-saved-albums/)**
132+ *
133+ * @param limit The number of objects to return. Default: 50 (or api limit). Minimum: 1. Maximum: 50.
134+ * @param offset The index of the first item to return. Default: 0. Use with limit to get the next set of items
135+ *
136+ * @return Paging Object of [SavedShow] ordered by position in library
137+ */
138+ public suspend fun getSavedShows (
139+ limit : Int? = api.spotifyApiOptions.defaultLimit,
140+ offset : Int? = null
141+ ): PagingObject <SavedShow > {
142+ requireScopes(SpotifyScope .USER_LIBRARY_READ )
143+
144+ return get(
145+ endpointBuilder(" /me/shows" ).with (" limit" , limit).with (" offset" , offset).toString()
146+ ).toNonNullablePagingObject(SavedShow .serializer(), api = api, json = json)
147+ }
148+
149+ /* *
150+ * Get a list of shows saved in the current Spotify user’s library.
151+ * Optional parameters can be used to limit the number of shows returned.
152+ *
153+ * **Requires** the [SpotifyScope.USER_LIBRARY_READ] scope
154+ *
155+ * **[Api Reference](https://developer.spotify.com/documentation/web-api/reference/library/get-users-saved-albums/)**
156+ *
157+ * @param limit The number of objects to return. Default: 50 (or api limit). Minimum: 1. Maximum: 50.
158+ * @param offset The index of the first item to return. Default: 0. Use with limit to get the next set of items
159+ *
160+ * @return Paging Object of [SavedShow] ordered by position in library
161+ */
162+ public fun getSavedShowsRestAction (
163+ limit : Int? = api.spotifyApiOptions.defaultLimit,
164+ offset : Int? = null
165+ ): SpotifyRestAction <PagingObject <SavedShow >> {
166+ return SpotifyRestAction {
167+ getSavedShows(limit, offset)
168+ }
169+ }
170+
171+ /* *
172+ * Get a list of the episodes saved in the current Spotify user’s library.
173+ * This API endpoint is in beta and could change without warning.
174+ *
175+ * **Requires** the [SpotifyScope.USER_LIBRARY_READ] scope
176+ *
177+ * **[Api Reference](https://developer.spotify.com/documentation/web-api/reference/library/get-users-saved-albums/)**
178+ *
179+ * @param limit The number of objects to return. Default: 50 (or api limit). Minimum: 1. Maximum: 50.
180+ * @param offset The index of the first item to return. Default: 0. Use with limit to get the next set of items
181+ * @param market Provide this parameter if you want the list of returned items to be relevant to a particular country.
182+ * If omitted, the returned items will be relevant to all countries.
183+ *
184+ * @return Paging Object of [SavedEpisode] ordered by position in library
185+ */
186+ public suspend fun getSavedEpisodes (
187+ limit : Int? = api.spotifyApiOptions.defaultLimit,
188+ offset : Int? = null,
189+ market : Market ? = null
190+ ): PagingObject <SavedEpisode > {
191+ requireScopes(SpotifyScope .USER_LIBRARY_READ )
192+
193+ return get(
194+ endpointBuilder(" /me/episodes" ).with (" limit" , limit).with (" offset" , offset).with (" market" , market)
195+ .toString()
196+ ).toNonNullablePagingObject(SavedEpisode .serializer(), api = api, json = json)
197+ }
198+
199+ /* *
200+ * Get a list of the episodes saved in the current Spotify user’s library.
201+ * This API endpoint is in beta and could change without warning.
202+ *
203+ * **Requires** the [SpotifyScope.USER_LIBRARY_READ] scope
204+ *
205+ * **[Api Reference](https://developer.spotify.com/documentation/web-api/reference/library/get-users-saved-albums/)**
206+ *
207+ * @param limit The number of objects to return. Default: 50 (or api limit). Minimum: 1. Maximum: 50.
208+ * @param offset The index of the first item to return. Default: 0. Use with limit to get the next set of items
209+ * @param market Provide this parameter if you want the list of returned items to be relevant to a particular country.
210+ * If omitted, the returned items will be relevant to all countries.
211+ *
212+ * @return Paging Object of [SavedEpisode] ordered by position in library
213+ */
214+ public suspend fun getSavedEpisodesRestAction (
215+ limit : Int? = api.spotifyApiOptions.defaultLimit,
216+ offset : Int? = null,
217+ market : Market ? = null
218+ ): SpotifyRestAction <PagingObject <SavedEpisode >> {
219+ return SpotifyRestAction {
220+ getSavedEpisodes(limit, offset, market)
221+ }
222+ }
223+
121224 /* *
122225 * Check if the [LibraryType] with id [id] is already saved in the current Spotify user’s ‘Your Music’ library.
123226 *
@@ -144,7 +247,8 @@ public class ClientLibraryApi(api: GenericSpotifyApi) : SpotifyEndpoint(api) {
144247 *
145248 * @throws BadRequestException if [id] is not found
146249 */
147- public fun containsRestAction (type : LibraryType , id : String ): SpotifyRestAction <Boolean > = SpotifyRestAction { contains(type, ids = arrayOf(id))[0 ] }
250+ public fun containsRestAction (type : LibraryType , id : String ): SpotifyRestAction <Boolean > =
251+ SpotifyRestAction { contains(type, ids = arrayOf(id))[0 ] }
148252
149253 /* *
150254 * Check if one or more of [LibraryType] is already saved in the current Spotify user’s ‘Your Music’ library.
@@ -215,7 +319,8 @@ public class ClientLibraryApi(api: GenericSpotifyApi) : SpotifyEndpoint(api) {
215319 *
216320 * @throws BadRequestException if the id is invalid
217321 */
218- public fun addRestAction (type : LibraryType , id : String ): SpotifyRestAction <Unit > = SpotifyRestAction { add(type, id) }
322+ public fun addRestAction (type : LibraryType , id : String ): SpotifyRestAction <Unit > =
323+ SpotifyRestAction { add(type, id) }
219324
220325 /* *
221326 * Save one or more of [LibraryType] to the current user’s ‘Your Music’ library.
@@ -253,7 +358,8 @@ public class ClientLibraryApi(api: GenericSpotifyApi) : SpotifyEndpoint(api) {
253358 *
254359 * @throws BadRequestException if any of the provided ids is invalid
255360 */
256- public fun addRestAction (type : LibraryType , vararg ids : String ): SpotifyRestAction <Unit > = SpotifyRestAction { add(type, * ids) }
361+ public fun addRestAction (type : LibraryType , vararg ids : String ): SpotifyRestAction <Unit > =
362+ SpotifyRestAction { add(type, * ids) }
257363
258364 /* *
259365 * Remove one of [LibraryType] (track or album) from the current user’s ‘Your Music’ library.
@@ -285,7 +391,8 @@ public class ClientLibraryApi(api: GenericSpotifyApi) : SpotifyEndpoint(api) {
285391 *
286392 * @throws BadRequestException if any of the provided ids is invalid
287393 */
288- public fun removeRestAction (type : LibraryType , id : String ): SpotifyRestAction <Unit > = SpotifyRestAction { remove(type, ids = arrayOf(id)) }
394+ public fun removeRestAction (type : LibraryType , id : String ): SpotifyRestAction <Unit > =
395+ SpotifyRestAction { remove(type, ids = arrayOf(id)) }
289396
290397 /* *
291398 * Remove one or more of the [LibraryType] (tracks or albums) from the current user’s ‘Your Music’ library.
@@ -344,7 +451,9 @@ public class ClientLibraryApi(api: GenericSpotifyApi) : SpotifyEndpoint(api) {
344451 */
345452public enum class LibraryType (private val value : String , internal val id : (String ) -> String ) {
346453 TRACK (" tracks" , { PlayableUri (it).id }),
347- ALBUM (" albums" , { AlbumUri (it).id });
454+ ALBUM (" albums" , { AlbumUri (it).id }),
455+ EPISODE (" episodes" , { EpisodeUri (it).id }),
456+ SHOW (" shows" , { ShowUri (it).id });
348457
349458 override fun toString (): String = value
350459}
0 commit comments