Skip to content

Commit 3edec80

Browse files
committed
update documentation
Signed-off-by: Adam Ratzman <adam@adamratzman.com>
1 parent 3ef3ba4 commit 3edec80

File tree

3 files changed

+31
-12
lines changed

3 files changed

+31
-12
lines changed

src/main/kotlin/com/adamratzman/spotify/endpoints/client/ClientFollowingAPI.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
2525
/**
2626
* Check to see if the current user is following another Spotify users.
2727
*
28-
* @param userId Spotify ID to check.
28+
* @param user Spotify ID to check.
2929
*
3030
* @throws BadRequestException if [userId] is a non-existing id
3131
*/
@@ -52,7 +52,7 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
5252
/**
5353
* Check to see if the current user is following one or more other Spotify users.
5454
*
55-
* @param userIds List of the user Spotify IDs to check. Max 50
55+
* @param users List of the user Spotify IDs to check. Max 50
5656
*
5757
* @throws BadRequestException if [userIds] contains a non-existing id
5858
*/
@@ -173,7 +173,7 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
173173
/**
174174
* Remove the current user as a follower of another user
175175
*
176-
* @param userId The user to be unfollowed from
176+
* @param user The user to be unfollowed from
177177
*
178178
* @throws BadRequestException if [userId] is not found
179179
*/
@@ -186,7 +186,7 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
186186
/**
187187
* Remove the current user as a follower of other users
188188
*
189-
* @param userIds The users to be unfollowed from
189+
* @param users The users to be unfollowed from
190190
*
191191
* @throws BadRequestException if an invalid id is provided
192192
*/

src/main/kotlin/com/adamratzman/spotify/endpoints/client/ClientPlaylistAPI.kt

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import com.adamratzman.spotify.utils.UserURI
1818
import com.adamratzman.spotify.utils.encode
1919
import com.adamratzman.spotify.utils.toObject
2020
import com.adamratzman.spotify.utils.toPagingObject
21+
import org.json.JSONArray
2122
import org.json.JSONObject
2223
import java.awt.image.BufferedImage
2324
import java.io.ByteArrayOutputStream
@@ -71,7 +72,6 @@ class ClientPlaylistAPI(api: SpotifyAPI) : PlaylistsAPI(api) {
7172
/**
7273
* Add one or more tracks to a user’s playlist.
7374
*
74-
* @param user The user’s Spotify user ID.
7575
* @param playlist The Spotify ID for the playlist.
7676
* @param tracks Spotify track ids. A maximum of 100 tracks can be added in one request.
7777
* @param position The position to insert the tracks, a zero-based index. For example, to insert the tracks in the
@@ -92,7 +92,6 @@ class ClientPlaylistAPI(api: SpotifyAPI) : PlaylistsAPI(api) {
9292
/**
9393
* Change a playlist’s name and public/private state. (The user must, of course, own the playlist.)
9494
*
95-
* @param user The user’s Spotify user ID.
9695
* @param playlist The Spotify ID for the playlist.
9796
* @param name Optional. The name to change the playlist to.
9897
* @param public Optional. Whether to make the playlist public or not.
@@ -173,7 +172,6 @@ class ClientPlaylistAPI(api: SpotifyAPI) : PlaylistsAPI(api) {
173172
* untouched. In addition, the users following the playlists won’t be notified about changes in the playlists
174173
* when the tracks are reordered.
175174
*
176-
* @param user The user’s Spotify user ID.
177175
* @param playlist The Spotify ID for the playlist.
178176
* @param reorderRangeStart The position of the first track to be reordered.
179177
* @param reorderRangeLength The amount of tracks to be reordered. Defaults to 1 if not set.
@@ -206,7 +204,6 @@ class ClientPlaylistAPI(api: SpotifyAPI) : PlaylistsAPI(api) {
206204
* Replace all the tracks in a playlist, overwriting its existing tracks. This powerful request can be useful
207205
* for replacing tracks, re-ordering existing tracks, or clearing the playlist.
208206
*
209-
* @param user The user’s Spotify user ID.
210207
* @param playlist The Spotify ID for the playlist.
211208
* @param tracks The Spotify track ids.
212209
*
@@ -223,7 +220,6 @@ class ClientPlaylistAPI(api: SpotifyAPI) : PlaylistsAPI(api) {
223220

224221
/**
225222
* Remove all the tracks in a playlist
226-
* @param user The user’s Spotify user ID.
227223
* @param playlist The Spotify ID for the playlist.
228224
*/
229225
fun removeAllPlaylistTracks(playlist: String): SpotifyRestAction<Unit> {
@@ -235,7 +231,6 @@ class ClientPlaylistAPI(api: SpotifyAPI) : PlaylistsAPI(api) {
235231
*
236232
* Must specify a JPEG image path or image data, maximum payload size is 256 KB
237233
*
238-
* @param user The user’s Spotify user ID.
239234
* @param playlist The Spotify ID for the playlist.
240235
* @param imagePath Optionally specify the full local path to the image
241236
* @param imageUrl Optionally specify a URL to the image
@@ -270,6 +265,30 @@ class ClientPlaylistAPI(api: SpotifyAPI) : PlaylistsAPI(api) {
270265
})
271266
}
272267

268+
/*
269+
private fun removePlaylistTracks(
270+
playlist: String,
271+
tracks: List<Pair<TrackURI, SpotifyTrackPositions?>>,
272+
snapshotId: String?
273+
): SpotifyRestAction<String> {
274+
return toAction(Supplier {
275+
if (tracks.isEmpty()) throw IllegalArgumentException("You need to provide at least one track to remove")
276+
277+
val json = JSONObject().also { if (snapshotId != null) it.put("snapshot_id", snapshotId) }
278+
279+
tracks.map { (track, positions) ->
280+
JSONObject().put("uri", track.uri)
281+
.also { if (positions?.positions?.isNotEmpty() == true) it.put("positions", positions.positions) }
282+
}.let { json.put("tracks", JSONArray(it)) }
283+
284+
delete(
285+
EndpointBuilder("/playlists/${PlaylistURI(playlist).id}/tracks").toString(), data = listOf(
286+
"tracks" to json.toString()
287+
)
288+
)
289+
})
290+
}*/
291+
273292
/*
274293
fun removeAllOccurances(user: String, playlist: String, vararg tracks: String): SpotifyRestAction<Unit> {
275294
if (tracks.isEmpty()) throw IllegalArgumentException("Tracks to remove must not be empty")
@@ -293,3 +312,5 @@ class ClientPlaylistAPI(api: SpotifyAPI) : PlaylistsAPI(api) {
293312

294313
data class Snapshot(val snapshot_id: String)
295314
}
315+
316+
class SpotifyTrackPositions(vararg val positions: Int)

src/main/kotlin/com/adamratzman/spotify/endpoints/public/PlaylistsAPI.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ open class PlaylistsAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
4949
/**
5050
* Get a playlist owned by a Spotify user.
5151
*
52-
* @param user The user’s Spotify user ID.
5352
* @param playlist The Spotify ID for the playlist.
5453
* @param market Provide this parameter if you want to apply [Track Relinking](https://github.com/adamint/spotify-web-api-kotlin/blob/master/README.md#track-relinking)
5554
*
@@ -83,7 +82,6 @@ open class PlaylistsAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
8382

8483
/**
8584
* Get the current image associated with a specific playlist.
86-
* @param user The user’s Spotify user ID.
8785
* @param playlist The Spotify ID for the playlist.
8886
*
8987
* @throws BadRequestException if the playlist cannot be found

0 commit comments

Comments
 (0)