@@ -54,11 +54,11 @@ class ClientPlaylistAPI(api: SpotifyAPI) : PlaylistAPI(api) {
54
54
* @return The created [Playlist] object with no tracks
55
55
*/
56
56
fun createPlaylist (
57
- name : String ,
58
- description : String? = null,
59
- public : Boolean? = null,
60
- collaborative : Boolean? = null,
61
- user : String = (api as SpotifyClientAPI ).userId
57
+ name : String ,
58
+ description : String? = null,
59
+ public : Boolean? = null,
60
+ collaborative : Boolean? = null,
61
+ user : String = (api as SpotifyClientAPI ).userId
62
62
): SpotifyRestAction <Playlist > {
63
63
if (name.isEmpty()) throw BadRequestException (ErrorObject (400 , " Name cannot be empty" ))
64
64
return toAction(Supplier {
@@ -133,11 +133,11 @@ class ClientPlaylistAPI(api: SpotifyAPI) : PlaylistAPI(api) {
133
133
* @throws BadRequestException if the playlist is not found or parameters exceed the max length
134
134
*/
135
135
fun changePlaylistDetails (
136
- playlist : String ,
137
- name : String? = null,
138
- public : Boolean? = null,
139
- collaborative : Boolean? = null,
140
- description : String? = null
136
+ playlist : String ,
137
+ name : String? = null,
138
+ public : Boolean? = null,
139
+ collaborative : Boolean? = null,
140
+ description : String? = null
141
141
): SpotifyRestAction <Unit > {
142
142
val json = jsonMap()
143
143
if (name != null ) json[" name" ] = name
@@ -166,8 +166,8 @@ class ClientPlaylistAPI(api: SpotifyAPI) : PlaylistAPI(api) {
166
166
* @throws BadRequestException if the filters provided are illegal
167
167
*/
168
168
fun getPlaylists (
169
- limit : Int? = null,
170
- offset : Int? = null
169
+ limit : Int? = null,
170
+ offset : Int? = null
171
171
): SpotifyRestActionPaging <SimplePlaylist , PagingObject <SimplePlaylist >> {
172
172
if (limit != null && limit !in 1 .. 50 ) throw IllegalArgumentException (" Limit must be between 1 and 50. Provided $limit " )
173
173
if (offset != null && offset !in 0 .. 100000 ) throw IllegalArgumentException (" Offset must be between 0 and 100,000. Provided $limit " )
@@ -229,11 +229,11 @@ class ClientPlaylistAPI(api: SpotifyAPI) : PlaylistAPI(api) {
229
229
* @throws BadRequestException if the playlist is not found or illegal filters are applied
230
230
*/
231
231
fun reorderPlaylistTracks (
232
- playlist : String ,
233
- reorderRangeStart : Int ,
234
- reorderRangeLength : Int? = null,
235
- insertionPoint : Int ,
236
- snapshotId : String? = null
232
+ playlist : String ,
233
+ reorderRangeStart : Int ,
234
+ reorderRangeLength : Int? = null,
235
+ insertionPoint : Int ,
236
+ snapshotId : String? = null
237
237
): SpotifyRestAction <Snapshot > {
238
238
return toAction(Supplier {
239
239
val json = jsonMap()
@@ -316,12 +316,12 @@ class ClientPlaylistAPI(api: SpotifyAPI) : PlaylistAPI(api) {
316
316
* @throws BadRequestException if invalid data is provided
317
317
*/
318
318
fun uploadPlaylistCover (
319
- playlist : String ,
320
- imagePath : String? = null,
321
- imageFile : File ? = null,
322
- image : BufferedImage ? = null,
323
- imageData : String? = null,
324
- imageUrl : String? = null
319
+ playlist : String ,
320
+ imagePath : String? = null,
321
+ imageFile : File ? = null,
322
+ image : BufferedImage ? = null,
323
+ imageData : String? = null,
324
+ imageUrl : String? = null
325
325
): SpotifyRestAction <Unit > {
326
326
return toAction(Supplier {
327
327
val data = imageData ? : when {
@@ -351,10 +351,10 @@ class ClientPlaylistAPI(api: SpotifyAPI) : PlaylistAPI(api) {
351
351
* @param snapshotId The playlist snapshot against which to apply this action. **recommended to have**
352
352
*/
353
353
fun removeTrackFromPlaylist (
354
- playlist : String ,
355
- track : String ,
356
- positions : SpotifyTrackPositions ,
357
- snapshotId : String? = null
354
+ playlist : String ,
355
+ track : String ,
356
+ positions : SpotifyTrackPositions ,
357
+ snapshotId : String? = null
358
358
) = removeTracksFromPlaylist(playlist, track to positions, snapshotId = snapshotId)
359
359
360
360
/* *
@@ -368,9 +368,9 @@ class ClientPlaylistAPI(api: SpotifyAPI) : PlaylistAPI(api) {
368
368
* @param snapshotId The playlist snapshot against which to apply this action. **recommended to have**
369
369
*/
370
370
fun removeTrackFromPlaylist (
371
- playlist : String ,
372
- track : String ,
373
- snapshotId : String? = null
371
+ playlist : String ,
372
+ track : String ,
373
+ snapshotId : String? = null
374
374
) = removeTracksFromPlaylist(playlist, track, snapshotId = snapshotId)
375
375
376
376
/* *
@@ -384,9 +384,9 @@ class ClientPlaylistAPI(api: SpotifyAPI) : PlaylistAPI(api) {
384
384
* @param snapshotId The playlist snapshot against which to apply this action. **recommended to have**
385
385
*/
386
386
fun removeTracksFromPlaylist (
387
- playlist : String ,
388
- vararg tracks : String ,
389
- snapshotId : String? = null
387
+ playlist : String ,
388
+ vararg tracks : String ,
389
+ snapshotId : String? = null
390
390
) = removePlaylistTracksImpl(playlist, tracks.map { it to null }.toTypedArray(), snapshotId)
391
391
392
392
/* *
@@ -400,15 +400,15 @@ class ClientPlaylistAPI(api: SpotifyAPI) : PlaylistAPI(api) {
400
400
* @param snapshotId The playlist snapshot against which to apply this action. **recommended to have**
401
401
*/
402
402
fun removeTracksFromPlaylist (
403
- playlist : String ,
404
- vararg tracks : Pair <String , SpotifyTrackPositions >,
405
- snapshotId : String? = null
403
+ playlist : String ,
404
+ vararg tracks : Pair <String , SpotifyTrackPositions >,
405
+ snapshotId : String? = null
406
406
) = removePlaylistTracksImpl(playlist, tracks.toList().toTypedArray(), snapshotId)
407
407
408
408
private fun removePlaylistTracksImpl (
409
- playlist : String ,
410
- tracks : Array <Pair <String , SpotifyTrackPositions ?>>,
411
- snapshotId : String?
409
+ playlist : String ,
410
+ tracks : Array <Pair <String , SpotifyTrackPositions ?>>,
411
+ snapshotId : String?
412
412
): SpotifyRestAction <Snapshot > {
413
413
return toAction(Supplier {
414
414
if (tracks.isEmpty()) throw IllegalArgumentException (" You need to provide at least one track to remove" )
0 commit comments