1
1
/* Spotify Web API - Kotlin Wrapper; MIT License, 2019; Original author: Adam Ratzman */
2
2
package com.adamratzman.spotify.endpoints.client
3
3
4
- import com.adamratzman.spotify.endpoints.public.FollowingAPI
5
- import com.adamratzman.spotify.http.EndpointBuilder
6
- import com.adamratzman.spotify.http.encode
7
4
import com.adamratzman.spotify.SpotifyAPI
8
5
import com.adamratzman.spotify.SpotifyClientAPI
9
6
import com.adamratzman.spotify.SpotifyRestAction
10
7
import com.adamratzman.spotify.SpotifyRestActionPaging
8
+ import com.adamratzman.spotify.SpotifyScope
9
+ import com.adamratzman.spotify.endpoints.public.FollowingAPI
10
+ import com.adamratzman.spotify.http.EndpointBuilder
11
+ import com.adamratzman.spotify.http.encode
11
12
import com.adamratzman.spotify.models.Artist
12
13
import com.adamratzman.spotify.models.ArtistURI
13
14
import com.adamratzman.spotify.models.CursorBasedPagingObject
@@ -22,11 +23,14 @@ import java.util.function.Supplier
22
23
*/
23
24
class ClientFollowingAPI (api : SpotifyAPI ) : FollowingAPI(api) {
24
25
/* *
25
- * Check to see if the current user is following another Spotify users.
26
+ * Check to see if the current user is following another Spotify user.
27
+ *
28
+ * **Requires** the [SpotifyScope.USER_FOLLOW_READ] scope
26
29
*
27
- * @param user user id or uri to check.
30
+ * @param user The user id or uri to check.
28
31
*
29
32
* @throws BadRequestException if [user] is a non-existing id
33
+ * @return Whether the current user is following [user]
30
34
*/
31
35
fun isFollowingUser (user : String ): SpotifyRestAction <Boolean > {
32
36
return toAction(Supplier {
@@ -35,14 +39,18 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
35
39
}
36
40
37
41
/* *
38
- * Check to see if the logged-in Spotify user is following the specified playlist.
42
+ * Check to see if the current Spotify user is following the specified playlist.
43
+ *
44
+ * Checking if the user is privately following a playlist is only possible for the current user when
45
+ * that user has granted access to the [SpotifyScope.PLAYLIST_READ_PRIVATE] scope.
39
46
*
40
47
* @param playlistOwner id or uri of the creator of the playlist
41
48
* @param playlistId playlist id or uri
42
49
*
43
- * @return booleans representing whether the user follows the playlist. User IDs **not** found will return false
50
+ * @return Boolean representing whether the user follows the playlist
44
51
*
45
52
* @throws [BadRequestException] if the playlist is not found
53
+ * @return Whether the current user is following [playlistId]
46
54
*/
47
55
fun isFollowingPlaylist (playlistOwner : String , playlistId : String ): SpotifyRestAction <Boolean > {
48
56
return toAction(Supplier {
@@ -57,9 +65,12 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
57
65
/* *
58
66
* Check to see if the current user is following one or more other Spotify users.
59
67
*
68
+ * **Requires** the [SpotifyScope.USER_FOLLOW_READ] scope
69
+ *
60
70
* @param users List of the user Spotify IDs to check. Max 50
61
71
*
62
72
* @throws BadRequestException if [users] contains a non-existing id
73
+ * @return A list of booleans corresponding to [users] of whether the current user is following that user
63
74
*/
64
75
fun isFollowingUsers (vararg users : String ): SpotifyRestAction <List <Boolean >> {
65
76
return toAction(Supplier {
@@ -73,9 +84,12 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
73
84
/* *
74
85
* Check to see if the current user is following a Spotify artist.
75
86
*
76
- * @param artist artist id to check.
87
+ * **Requires** the [SpotifyScope.USER_FOLLOW_READ] scope
88
+ *
89
+ * @param artist The artist id to check.
77
90
*
78
91
* @throws BadRequestException if [artist] is a non-existing id
92
+ * @return Whether the current user is following [artist]
79
93
*/
80
94
fun isFollowingArtist (artist : String ): SpotifyRestAction <Boolean > {
81
95
return toAction(Supplier {
@@ -86,9 +100,12 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
86
100
/* *
87
101
* Check to see if the current user is following one or more artists.
88
102
*
103
+ * **Requires** the [SpotifyScope.USER_FOLLOW_READ] scope
104
+ *
89
105
* @param artists List of the artist ids or uris to check. Max 50
90
106
*
91
107
* @throws BadRequestException if [artists] contains a non-existing id
108
+ * @return A list of booleans corresponding to [artists] of whether the current user is following that artist
92
109
*/
93
110
fun isFollowingArtists (vararg artists : String ): SpotifyRestAction <List <Boolean >> {
94
111
return toAction(Supplier {
@@ -102,6 +119,11 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
102
119
/* *
103
120
* Get the current user’s followed artists.
104
121
*
122
+ * **Requires** the [SpotifyScope.USER_FOLLOW_READ] scope
123
+ *
124
+ * @param limit The maximum number of items to return. Default: 20. Minimum: 1. Maximum: 50.
125
+ * @param after The last artist ID retrieved from the previous request.
126
+ *
105
127
* @return [CursorBasedPagingObject] ([Information about them](https://github.com/adamint/spotify-web-api-kotlin/blob/master/README.md#the-benefits-of-linkedresults-pagingobjects-and-cursor-based-paging-objects)
106
128
* with full [Artist] objects
107
129
*/
@@ -122,6 +144,8 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
122
144
/* *
123
145
* Add the current user as a follower of another user
124
146
*
147
+ * **Requires** the [SpotifyScope.USER_FOLLOW_MODIFY] scope
148
+ *
125
149
* @throws BadRequestException if an invalid id is provided
126
150
*/
127
151
fun followUser (user : String ): SpotifyRestAction <Unit > {
@@ -133,6 +157,8 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
133
157
/* *
134
158
* Add the current user as a follower of other users
135
159
*
160
+ * **Requires** the [SpotifyScope.USER_FOLLOW_MODIFY] scope
161
+ *
136
162
* @throws BadRequestException if an invalid id is provided
137
163
*/
138
164
fun followUsers (vararg users : String ): SpotifyRestAction <Unit > {
@@ -148,6 +174,8 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
148
174
/* *
149
175
* Add the current user as a follower of an artist
150
176
*
177
+ * **Requires** the [SpotifyScope.USER_FOLLOW_MODIFY] scope
178
+ *
151
179
* @throws BadRequestException if an invalid id is provided
152
180
*/
153
181
fun followArtist (artistId : String ): SpotifyRestAction <Unit > {
@@ -159,6 +187,8 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
159
187
/* *
160
188
* Add the current user as a follower of other artists
161
189
*
190
+ * **Requires** the [SpotifyScope.USER_FOLLOW_MODIFY] scope
191
+ *
162
192
* @throws BadRequestException if an invalid id is provided
163
193
*/
164
194
fun followArtists (vararg artists : String ): SpotifyRestAction <Unit > {
@@ -174,6 +204,13 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
174
204
/* *
175
205
* Add the current user as a follower of a playlist.
176
206
*
207
+ * Following a playlist publicly requires authorization of the [SpotifyScope.PLAYLIST_MODIFY_PUBLIC] scope;
208
+ * following it privately requires the [SpotifyScope.PLAYLIST_MODIFY_PRIVATE] scope.
209
+ *
210
+ * Note that the scopes you provide determine only whether the current user can themselves follow the playlist
211
+ * publicly or privately (i.e. show others what they are following), not whether the playlist itself is
212
+ * public or private.
213
+ *
177
214
* @param playlist the spotify id or uri of the playlist. Any playlist can be followed, regardless of its
178
215
* public/private status, as long as you know its playlist ID.
179
216
* @param followPublicly Defaults to true. If true the playlist will be included in user’s public playlists,
@@ -194,6 +231,8 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
194
231
/* *
195
232
* Remove the current user as a follower of another user
196
233
*
234
+ * **Requires** the [SpotifyScope.USER_FOLLOW_MODIFY] scope
235
+ *
197
236
* @param user The user to be unfollowed from
198
237
*
199
238
* @throws BadRequestException if [user] is not found
@@ -207,6 +246,8 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
207
246
/* *
208
247
* Remove the current user as a follower of other users
209
248
*
249
+ * **Requires** the [SpotifyScope.USER_FOLLOW_MODIFY] scope
250
+ *
210
251
* @param users The users to be unfollowed from
211
252
*
212
253
* @throws BadRequestException if an invalid id is provided
@@ -224,6 +265,8 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
224
265
/* *
225
266
* Remove the current user as a follower of an artist
226
267
*
268
+ * **Requires** the [SpotifyScope.USER_FOLLOW_MODIFY] scope
269
+ *
227
270
* @param artist The artist to be unfollowed from
228
271
*
229
272
* @throws BadRequestException if an invalid id is provided
@@ -237,6 +280,8 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
237
280
/* *
238
281
* Remove the current user as a follower of artists
239
282
*
283
+ * **Requires** the [SpotifyScope.USER_FOLLOW_MODIFY] scope
284
+ *
240
285
* @param artists The artists to be unfollowed from
241
286
*
242
287
* @throws BadRequestException if an invalid id is provided
@@ -254,7 +299,13 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
254
299
/* *
255
300
* Remove the current user as a follower of a playlist.
256
301
*
257
- * @param playlist the spotify id or uri of the playlist that is to be no longer followed.
302
+ * Unfollowing a publicly followed playlist for a user requires authorization of the [SpotifyScope.PLAYLIST_MODIFY_PUBLIC] scope;
303
+ * unfollowing a privately followed playlist requires the [SpotifyScope.PLAYLIST_MODIFY_PRIVATE] scope.
304
+ *
305
+ * Note that the scopes you provide relate only to whether the current user is following the playlist publicly or
306
+ * privately (i.e. showing others what they are following), not whether the playlist itself is public or private.
307
+ *
308
+ * @param playlist The spotify id or uri of the playlist that is to be no longer followed.
258
309
*
259
310
* @throws BadRequestException if the playlist is not found
260
311
*/
0 commit comments