@@ -16,6 +16,8 @@ import com.adamratzman.spotify.utils.UserURI
1616import com.adamratzman.spotify.utils.encode
1717import com.adamratzman.spotify.utils.toCursorBasedPagingObject
1818import com.adamratzman.spotify.utils.toObject
19+ import kotlinx.serialization.internal.ArrayListSerializer
20+ import kotlinx.serialization.internal.BooleanSerializer
1921import java.util.function.Supplier
2022
2123/* *
@@ -46,7 +48,13 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
4648 * @throws [BadRequestException] if the playlist is not found
4749 */
4850 fun isFollowingPlaylist (playlistOwner : String , playlistId : String ): SpotifyRestAction <Boolean > {
49- return toAction(Supplier { isFollowingPlaylist(playlistOwner, playlistId, (api as SpotifyClientAPI ).userId).complete() })
51+ return toAction(Supplier {
52+ isFollowingPlaylist(
53+ playlistOwner,
54+ playlistId,
55+ (api as SpotifyClientAPI ).userId
56+ ).complete()
57+ })
5058 }
5159
5260 /* *
@@ -58,8 +66,10 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
5866 */
5967 fun isFollowingUsers (vararg users : String ): SpotifyRestAction <List <Boolean >> {
6068 return toAction(Supplier {
61- get(EndpointBuilder (" /me/following/contains" ).with (" type" , " user" )
62- .with (" ids" , users.joinToString(" ," ) { UserURI (it).id.encode() }).toString()).toObject(api, mutableListOf<Boolean >().javaClass).toList()
69+ get(
70+ EndpointBuilder (" /me/following/contains" ).with (" type" , " user" )
71+ .with (" ids" , users.joinToString(" ," ) { UserURI (it).id.encode() }).toString()
72+ ).toObject<List <Boolean >>(api, ArrayListSerializer (BooleanSerializer )).toList()
6373 })
6474 }
6575
@@ -85,8 +95,10 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
8595 */
8696 fun isFollowingArtists (vararg artists : String ): SpotifyRestAction <List <Boolean >> {
8797 return toAction(Supplier {
88- get(EndpointBuilder (" /me/following/contains" ).with (" type" , " artist" )
89- .with (" ids" , artists.joinToString(" ," ) { ArtistURI (it).id.encode() }).toString()).toObject(api, mutableListOf<Boolean >().javaClass).toList()
98+ get(
99+ EndpointBuilder (" /me/following/contains" ).with (" type" , " artist" )
100+ .with (" ids" , artists.joinToString(" ," ) { ArtistURI (it).id.encode() }).toString()
101+ ).toObject<List <Boolean >>(api, ArrayListSerializer (BooleanSerializer )).toList()
90102 })
91103 }
92104
@@ -96,14 +108,23 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
96108 * @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)
97109 * with full [Artist] objects
98110 */
99- fun getFollowedArtists (limit : Int? = null, after : String? = null): SpotifyRestPagingAction <Artist , CursorBasedPagingObject <Artist >> {
111+ fun getFollowedArtists (
112+ limit : Int? = null,
113+ after : String? = null
114+ ): SpotifyRestPagingAction <Artist , CursorBasedPagingObject <Artist >> {
100115 return toPagingObjectAction(Supplier {
101- get(EndpointBuilder (" /me/following" ).with (" type" , " artist" ).with (" limit" , limit).with (" after" , after).toString())
102- .toCursorBasedPagingObject(" artists" , this , Artist ::class .java)
116+ get(
117+ EndpointBuilder (" /me/following" ).with (" type" , " artist" ).with (" limit" , limit).with (
118+ " after" ,
119+ after
120+ ).toString()
121+ )
122+ .toCursorBasedPagingObject(" artists" , this , Artist ::class .java)
103123 })
104124 }
105125
106- fun getFollowedUsers (): SpotifyRestAction <List <SpotifyPublicUser >> = throw NotImplementedError (" Though Spotify will implement this in the future, it is not currently supported." )
126+ fun getFollowedUsers (): SpotifyRestAction <List <SpotifyPublicUser >> =
127+ throw NotImplementedError (" Though Spotify will implement this in the future, it is not currently supported." )
107128
108129 /* *
109130 * Add the current user as a follower of another user
@@ -123,8 +144,10 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
123144 */
124145 fun followUsers (vararg users : String ): SpotifyRestAction <Unit > {
125146 return toAction(Supplier {
126- put(EndpointBuilder (" /me/following" ).with (" type" , " user" )
127- .with (" ids" , users.joinToString(" ," ) { UserURI (it).id.encode() }).toString())
147+ put(
148+ EndpointBuilder (" /me/following" ).with (" type" , " user" )
149+ .with (" ids" , users.joinToString(" ," ) { UserURI (it).id.encode() }).toString()
150+ )
128151 Unit
129152 })
130153 }
@@ -147,8 +170,10 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
147170 */
148171 fun followArtists (vararg artists : String ): SpotifyRestAction <Unit > {
149172 return toAction(Supplier {
150- put(EndpointBuilder (" /me/following" ).with (" type" , " artist" )
151- .with (" ids" , artists.joinToString(" ," ) { ArtistURI (it).id.encode() }).toString())
173+ put(
174+ EndpointBuilder (" /me/following" ).with (" type" , " artist" )
175+ .with (" ids" , artists.joinToString(" ," ) { ArtistURI (it).id.encode() }).toString()
176+ )
152177 Unit
153178 })
154179 }
@@ -165,7 +190,10 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
165190 */
166191 fun followPlaylist (playlist : String , followPublicly : Boolean = true): SpotifyRestAction <Unit > {
167192 return toAction(Supplier {
168- put(EndpointBuilder (" /playlists/${PlaylistURI (playlist).id} /followers" ).toString(), " {\" public\" : $followPublicly }" )
193+ put(
194+ EndpointBuilder (" /playlists/${PlaylistURI (playlist).id} /followers" ).toString(),
195+ " {\" public\" : $followPublicly }"
196+ )
169197 Unit
170198 })
171199 }
@@ -192,8 +220,10 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
192220 */
193221 fun unfollowUsers (vararg users : String ): SpotifyRestAction <Unit > {
194222 return toAction(Supplier {
195- delete(EndpointBuilder (" /me/following" ).with (" type" , " user" )
196- .with (" ids" , users.joinToString(" ," ) { UserURI (it).id.encode() }).toString())
223+ delete(
224+ EndpointBuilder (" /me/following" ).with (" type" , " user" )
225+ .with (" ids" , users.joinToString(" ," ) { UserURI (it).id.encode() }).toString()
226+ )
197227 Unit
198228 })
199229 }
@@ -220,8 +250,10 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
220250 */
221251 fun unfollowArtists (vararg artists : String ): SpotifyRestAction <Unit > {
222252 return toAction(Supplier {
223- delete(EndpointBuilder (" /me/following" ).with (" type" , " artist" )
224- .with (" ids" , artists.joinToString(" ," ) { ArtistURI (it).id.encode() }).toString())
253+ delete(
254+ EndpointBuilder (" /me/following" ).with (" type" , " artist" )
255+ .with (" ids" , artists.joinToString(" ," ) { ArtistURI (it).id.encode() }).toString()
256+ )
225257 Unit
226258 })
227259 }
0 commit comments