@@ -64,11 +64,11 @@ class ClientPlaylistApi(api: SpotifyApi<*, *>) : PlaylistApi(api) {
64
64
* @return The created [Playlist] object with no tracks
65
65
*/
66
66
fun createClientPlaylist (
67
- name : String ,
68
- description : String? = null,
69
- public : Boolean? = null,
70
- collaborative : Boolean? = null,
71
- user : String = (api as SpotifyClientApi ).userId
67
+ name : String ,
68
+ description : String? = null,
69
+ public : Boolean? = null,
70
+ collaborative : Boolean? = null,
71
+ user : String = (api as SpotifyClientApi ).userId
72
72
): SpotifyRestAction <Playlist > {
73
73
if (name.isEmpty()) throw BadRequestException (ErrorObject (400 , " Name cannot be empty" ))
74
74
return toAction {
@@ -120,7 +120,7 @@ class ClientPlaylistApi(api: SpotifyApi<*, *>) : PlaylistApi(api) {
120
120
*
121
121
* @throws BadRequestException if any invalid track ids is provided or the playlist is not found
122
122
*/
123
- fun addTracksToClientPlaylist (playlist : String , vararg tracks : String , position : Int? = null): SpotifyRestAction <Unit > {
123
+ fun addTracksToClientPlaylist (playlist : String , vararg tracks : String , position : Int? = null): SpotifyRestAction <Unit > {
124
124
checkBulkRequesting(100 , tracks.size)
125
125
return toAction {
126
126
bulkRequest(100 , tracks.toList()) { chunk ->
@@ -135,7 +135,6 @@ class ClientPlaylistApi(api: SpotifyApi<*, *>) : PlaylistApi(api) {
135
135
136
136
Unit
137
137
}
138
-
139
138
}
140
139
141
140
/* *
@@ -155,11 +154,11 @@ class ClientPlaylistApi(api: SpotifyApi<*, *>) : PlaylistApi(api) {
155
154
* @throws BadRequestException if the playlist is not found or parameters exceed the max length
156
155
*/
157
156
fun changeClientPlaylistDetails (
158
- playlist : String ,
159
- name : String? = null,
160
- public : Boolean? = null,
161
- collaborative : Boolean? = null,
162
- description : String? = null
157
+ playlist : String ,
158
+ name : String? = null,
159
+ public : Boolean? = null,
160
+ collaborative : Boolean? = null,
161
+ description : String? = null
163
162
): SpotifyRestAction <Unit > {
164
163
val body = jsonMap()
165
164
if (name != null ) body + = json { " name" to name }
@@ -190,8 +189,8 @@ class ClientPlaylistApi(api: SpotifyApi<*, *>) : PlaylistApi(api) {
190
189
* @throws BadRequestException if the filters provided are illegal
191
190
*/
192
191
fun getClientPlaylists (
193
- limit : Int? = api.defaultLimit,
194
- offset : Int? = null
192
+ limit : Int? = api.defaultLimit,
193
+ offset : Int? = null
195
194
): SpotifyRestActionPaging <SimplePlaylist , PagingObject <SimplePlaylist >> {
196
195
require(! (limit != null && limit !in 1 .. 50 )) { " Limit must be between 1 and 50. Provided $limit " }
197
196
require(! (offset != null && offset !in 0 .. 100000 )) { " Offset must be between 0 and 100,000. Provided $limit " }
@@ -257,11 +256,11 @@ class ClientPlaylistApi(api: SpotifyApi<*, *>) : PlaylistApi(api) {
257
256
* @throws BadRequestException if the playlist is not found or illegal filters are applied
258
257
*/
259
258
fun reorderClientPlaylistTracks (
260
- playlist : String ,
261
- reorderRangeStart : Int ,
262
- reorderRangeLength : Int? = null,
263
- insertionPoint : Int ,
264
- snapshotId : String? = null
259
+ playlist : String ,
260
+ reorderRangeStart : Int ,
261
+ reorderRangeLength : Int? = null,
262
+ insertionPoint : Int ,
263
+ snapshotId : String? = null
265
264
): SpotifyRestAction <PlaylistSnapshot > {
266
265
return toAction {
267
266
val body = jsonMap()
@@ -352,12 +351,12 @@ class ClientPlaylistApi(api: SpotifyApi<*, *>) : PlaylistApi(api) {
352
351
* @throws BadRequestException if invalid data is provided
353
352
*/
354
353
fun uploadClientPlaylistCover (
355
- playlist : String ,
356
- imagePath : String? = null,
357
- imageFile : File ? = null,
358
- image : BufferedImage ? = null,
359
- imageData : String? = null,
360
- imageUrl : String? = null
354
+ playlist : String ,
355
+ imagePath : String? = null,
356
+ imageFile : File ? = null,
357
+ image : BufferedImage ? = null,
358
+ imageData : String? = null,
359
+ imageUrl : String? = null
361
360
): SpotifyRestAction <Unit > {
362
361
return toAction {
363
362
val data = imageData ? : when {
@@ -389,10 +388,10 @@ class ClientPlaylistApi(api: SpotifyApi<*, *>) : PlaylistApi(api) {
389
388
* @param snapshotId The playlist snapshot against which to apply this action. **recommended to have**
390
389
*/
391
390
fun removeTrackFromClientPlaylist (
392
- playlist : String ,
393
- track : String ,
394
- positions : SpotifyTrackPositions ,
395
- snapshotId : String? = null
391
+ playlist : String ,
392
+ track : String ,
393
+ positions : SpotifyTrackPositions ,
394
+ snapshotId : String? = null
396
395
) = removeTracksFromClientPlaylist(playlist, track to positions, snapshotId = snapshotId)
397
396
398
397
/* *
@@ -408,9 +407,9 @@ class ClientPlaylistApi(api: SpotifyApi<*, *>) : PlaylistApi(api) {
408
407
* @param snapshotId The playlist snapshot against which to apply this action. **recommended to have**
409
408
*/
410
409
fun removeTrackFromClientPlaylist (
411
- playlist : String ,
412
- track : String ,
413
- snapshotId : String? = null
410
+ playlist : String ,
411
+ track : String ,
412
+ snapshotId : String? = null
414
413
) = removeTracksFromClientPlaylist(playlist, track, snapshotId = snapshotId)
415
414
416
415
/* *
@@ -426,9 +425,9 @@ class ClientPlaylistApi(api: SpotifyApi<*, *>) : PlaylistApi(api) {
426
425
* @param snapshotId The playlist snapshot against which to apply this action. **recommended to have**
427
426
*/
428
427
fun removeTracksFromClientPlaylist (
429
- playlist : String ,
430
- vararg tracks : String ,
431
- snapshotId : String? = null
428
+ playlist : String ,
429
+ vararg tracks : String ,
430
+ snapshotId : String? = null
432
431
) = removePlaylistTracksImpl(playlist, tracks.map { it to null }.toTypedArray(), snapshotId)
433
432
434
433
/* *
@@ -444,17 +443,17 @@ class ClientPlaylistApi(api: SpotifyApi<*, *>) : PlaylistApi(api) {
444
443
* @param snapshotId The playlist snapshot against which to apply this action. **recommended to have**
445
444
*/
446
445
fun removeTracksFromClientPlaylist (
447
- playlist : String ,
448
- vararg tracks : Pair <String , SpotifyTrackPositions >,
449
- snapshotId : String? = null
446
+ playlist : String ,
447
+ vararg tracks : Pair <String , SpotifyTrackPositions >,
448
+ snapshotId : String? = null
450
449
) = removePlaylistTracksImpl(playlist, tracks.toList().toTypedArray(), snapshotId)
451
450
452
451
private fun removePlaylistTracksImpl (
453
- playlist : String ,
454
- tracks : Array <Pair <String , SpotifyTrackPositions ?>>,
455
- snapshotId : String?
452
+ playlist : String ,
453
+ tracks : Array <Pair <String , SpotifyTrackPositions ?>>,
454
+ snapshotId : String?
456
455
): SpotifyRestAction <PlaylistSnapshot > {
457
- checkBulkRequesting(100 ,tracks.size)
456
+ checkBulkRequesting(100 , tracks.size)
458
457
if (snapshotId != null && tracks.size > 100 ) throw BadRequestException (" You cannot provide both the snapshot id and attempt bulk requesting" )
459
458
460
459
return toAction {
0 commit comments