@@ -7,10 +7,14 @@ import com.adamratzman.spotify.SpotifyRestAction
7
7
import com.adamratzman.spotify.SpotifyScope
8
8
import com.adamratzman.spotify.http.SpotifyEndpoint
9
9
import com.adamratzman.spotify.models.AlbumUri
10
+ import com.adamratzman.spotify.models.EpisodeUri
10
11
import com.adamratzman.spotify.models.PagingObject
11
12
import com.adamratzman.spotify.models.PlayableUri
12
13
import com.adamratzman.spotify.models.SavedAlbum
14
+ import com.adamratzman.spotify.models.SavedEpisode
15
+ import com.adamratzman.spotify.models.SavedShow
13
16
import com.adamratzman.spotify.models.SavedTrack
17
+ import com.adamratzman.spotify.models.ShowUri
14
18
import com.adamratzman.spotify.models.serialization.toList
15
19
import com.adamratzman.spotify.models.serialization.toNonNullablePagingObject
16
20
import com.adamratzman.spotify.utils.Market
@@ -118,6 +122,105 @@ public class ClientLibraryApi(api: GenericSpotifyApi) : SpotifyEndpoint(api) {
118
122
market : Market ? = null
119
123
): SpotifyRestAction <PagingObject <SavedAlbum >> = SpotifyRestAction { getSavedAlbums(limit, offset, market) }
120
124
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
+
121
224
/* *
122
225
* Check if the [LibraryType] with id [id] is already saved in the current Spotify user’s ‘Your Music’ library.
123
226
*
@@ -144,7 +247,8 @@ public class ClientLibraryApi(api: GenericSpotifyApi) : SpotifyEndpoint(api) {
144
247
*
145
248
* @throws BadRequestException if [id] is not found
146
249
*/
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 ] }
148
252
149
253
/* *
150
254
* 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) {
215
319
*
216
320
* @throws BadRequestException if the id is invalid
217
321
*/
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) }
219
324
220
325
/* *
221
326
* 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) {
253
358
*
254
359
* @throws BadRequestException if any of the provided ids is invalid
255
360
*/
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) }
257
363
258
364
/* *
259
365
* 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) {
285
391
*
286
392
* @throws BadRequestException if any of the provided ids is invalid
287
393
*/
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)) }
289
396
290
397
/* *
291
398
* 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) {
344
451
*/
345
452
public enum class LibraryType (private val value : String , internal val id : (String ) -> String ) {
346
453
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 });
348
457
349
458
override fun toString (): String = value
350
459
}
0 commit comments