Skip to content

Commit b220f7e

Browse files
committed
allow adding data to requests
1 parent 8fc04c0 commit b220f7e

File tree

16 files changed

+112
-88
lines changed

16 files changed

+112
-88
lines changed

.idea/modules/SpotifyKotlinWrapper.iml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules/SpotifyKotlinWrapper_main.iml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules/SpotifyKotlinWrapper_test.iml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,6 @@ links provided for each API below
204204
1. `createPlaylist` creates the playlist and returns its full Playlist representation
205205
2. `addTrackToPlaylist` adds the entered tracks to the playlist. Returns nothing
206206
3. `changePlaylistDescription` changes the description of the playlist. Returns nothing
207-
4. `getUserPlaylists` returns a `PagingObject` of SimplePlaylists the user has created
207+
4. `getClientPlaylists` returns a `PagingObject` of SimplePlaylists the user has created
208208
5. `reorderTracks` reorders the tracks in the playlist and returns the current Snapshot
209209
6. `replaceTracks` replaces tracks in the playlist and returns the current Snapshot

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group 'com.adamratzman'
2-
version '3.1.1'
2+
version '3.1.2'
33

44
buildscript {
55
ext.kotlin_version = '1.2.31'

src/main/kotlin/com/adamratzman/spotify/endpoints/priv/follow/UserFollowAPI.kt renamed to src/main/kotlin/com/adamratzman/spotify/endpoints/priv/follow/ClientFollowAPI.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import java.util.function.Supplier
77
/**
88
* These endpoints allow you manage the artists, users and playlists that a Spotify user follows.
99
*/
10-
class UserFollowAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
10+
class ClientFollowAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
1111
/**
1212
* Check to see if the current user is following another Spotify users.
1313
*

src/main/kotlin/com/adamratzman/spotify/endpoints/priv/library/UserLibraryAPI.kt renamed to src/main/kotlin/com/adamratzman/spotify/endpoints/priv/library/ClientLibraryAPI.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import java.util.function.Supplier
88
/**
99
* Endpoints for retrieving information about, and managing, tracks that the current user has saved in their “Your Music” library.
1010
*/
11-
class UserLibraryAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
11+
class ClientLibraryAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
1212
/**
1313
* Get a list of the songs saved in the current Spotify user’s ‘Your Music’ library.
1414
*

src/main/kotlin/com/adamratzman/spotify/endpoints/priv/playlists/UserPlaylistAPI.kt renamed to src/main/kotlin/com/adamratzman/spotify/endpoints/priv/playlists/ClientPlaylistAPI.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import javax.xml.bind.DatatypeConverter
1616
/**
1717
* Endpoints for retrieving information about a user’s playlists and for managing a user’s playlists.
1818
*/
19-
class UserPlaylistAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
19+
class ClientPlaylistAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
2020
/**
2121
* Create a playlist for a Spotify user. (The playlist will be empty until you add tracks.)
2222
*
@@ -187,7 +187,19 @@ class UserPlaylistAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
187187
Unit
188188
})
189189
}
190-
190+
/*
191+
fun removeAllOccurances(userId: String, playlistId: String, vararg trackIds: String): SpotifyRestAction<Unit> {
192+
if (trackIds.isEmpty()) throw IllegalArgumentException("Tracks to remove must not be empty")
193+
return toAction(Supplier {
194+
val json = JSONObject()
195+
json.put("tracks", trackIds.map { JSONObject().put("uri", "spotify:track:$it") })
196+
println(json.toString())
197+
delete("https://api.spotify.com/v1/users/$userId/playlists/$playlistId/tracks",
198+
body = json.toString(), contentType = "application/json")
199+
Unit
200+
})
201+
}
202+
*/
191203
private fun encode(image: BufferedImage): String {
192204
val bos = ByteArrayOutputStream()
193205
ImageIO.write(image, "jpg", bos)

src/main/kotlin/com/adamratzman/spotify/endpoints/priv/users/UserAPI.kt renamed to src/main/kotlin/com/adamratzman/spotify/endpoints/priv/users/ClientProfileAPI.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import java.util.function.Supplier
1010
/**
1111
* Endpoints for retrieving information about a user’s profile.
1212
*/
13-
class UserAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
13+
class ClientProfileAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
1414
/**
1515
* Get detailed profile information about the current user (including the current user’s username).
1616
*

src/main/kotlin/com/adamratzman/spotify/main/SpotifyAPI.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package com.adamratzman.spotify.main
22

3-
import com.adamratzman.spotify.endpoints.priv.follow.UserFollowAPI
4-
import com.adamratzman.spotify.endpoints.priv.library.UserLibraryAPI
3+
import com.adamratzman.spotify.endpoints.priv.follow.ClientFollowAPI
4+
import com.adamratzman.spotify.endpoints.priv.library.ClientLibraryAPI
55
import com.adamratzman.spotify.endpoints.priv.personalization.PersonalizationAPI
66
import com.adamratzman.spotify.endpoints.priv.player.PlayerAPI
7-
import com.adamratzman.spotify.endpoints.priv.playlists.UserPlaylistAPI
8-
import com.adamratzman.spotify.endpoints.priv.users.UserAPI
7+
import com.adamratzman.spotify.endpoints.priv.playlists.ClientPlaylistAPI
8+
import com.adamratzman.spotify.endpoints.priv.users.ClientProfileAPI
99
import com.adamratzman.spotify.endpoints.pub.album.AlbumAPI
1010
import com.adamratzman.spotify.endpoints.pub.artists.ArtistsAPI
1111
import com.adamratzman.spotify.endpoints.pub.browse.BrowseAPI
@@ -70,11 +70,11 @@ open class SpotifyAPI internal constructor(val clientId: String?, val clientSecr
7070

7171
class SpotifyClientAPI private constructor(clientId: String, clientSecret: String, token: Token, automaticRefresh: Boolean = false) : SpotifyAPI(clientId, clientSecret, token) {
7272
val personalization = PersonalizationAPI(this)
73-
val userProfile = UserAPI(this)
74-
val userLibrary = UserLibraryAPI(this)
75-
val userFollowing = UserFollowAPI(this)
73+
val clientProfile = ClientProfileAPI(this)
74+
val clientLibrary = ClientLibraryAPI(this)
75+
val clientFollowing = ClientFollowAPI(this)
7676
val player = PlayerAPI(this)
77-
val userPlaylists = UserPlaylistAPI(this)
77+
val clientPlaylists = ClientPlaylistAPI(this)
7878

7979
init {
8080
if (automaticRefresh) {

0 commit comments

Comments
 (0)