Skip to content

Commit 7ba3b36

Browse files
committed
fix client following api tests
Signed-off-by: Adam Ratzman <[email protected]>
1 parent a3017c3 commit 7ba3b36

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/commonMain/kotlin/com.adamratzman.spotify/SpotifyApi.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -542,18 +542,18 @@ public open class SpotifyClientApi(
542542
*/
543543
public val player: ClientPlayerApi = ClientPlayerApi(this)
544544

545-
private lateinit var userIdBacking: String
545+
private var userIdBacking: String? = null
546546

547547
private suspend fun initiatizeUserIdBacking(): String {
548548
userIdBacking = users.getClientProfile().id
549-
return userIdBacking
549+
return userIdBacking!!
550550
}
551551

552552
/**
553553
* The Spotify user id to which the api instance is connected
554554
*/
555555
public suspend fun getUserId(): String =
556-
if (::userIdBacking.isInitialized) userIdBacking else initiatizeUserIdBacking()
556+
if (userIdBacking != null) userIdBacking!! else initiatizeUserIdBacking()
557557

558558
/**
559559
* The Spotify user id to which the api instance is connected

src/commonMain/kotlin/com.adamratzman.spotify/endpoints/client/ClientFollowingApi.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ public class ClientFollowingApi(api: GenericSpotifyApi) : FollowingApi(api) {
209209
* with full [Artist] objects
210210
*/
211211
public suspend fun getFollowedArtists(
212-
limit: Int?,
213-
after: String?
212+
limit: Int? = api.spotifyApiOptions.defaultLimit,
213+
after: String? = null
214214
): CursorBasedPagingObject<Artist> = get(
215215
endpointBuilder("/me/following").with("type", "artist").with("limit", limit).with(
216216
"after",
@@ -232,8 +232,8 @@ public class ClientFollowingApi(api: GenericSpotifyApi) : FollowingApi(api) {
232232
* with full [Artist] objects
233233
*/
234234
public fun getFollowedArtistsRestAction(
235-
limit: Int?,
236-
after: String?
235+
limit: Int? = api.spotifyApiOptions.defaultLimit,
236+
after: String? = null
237237
): SpotifyRestAction<CursorBasedPagingObject<Artist>> = SpotifyRestAction { getFollowedArtists(limit, after) }
238238

239239
/**
@@ -313,7 +313,7 @@ public class ClientFollowingApi(api: GenericSpotifyApi) : FollowingApi(api) {
313313
*
314314
* @throws BadRequestException if an invalid id is provided
315315
*/
316-
public fun followArtistRestAction(artistId: String) = SpotifyRestAction { followArtist(artistId) }
316+
public fun followArtistRestAction(artistId: String): SpotifyRestAction<Unit> = SpotifyRestAction { followArtist(artistId) }
317317

318318
/**
319319
* Add the current user as a follower of other artists
@@ -369,7 +369,7 @@ public class ClientFollowingApi(api: GenericSpotifyApi) : FollowingApi(api) {
369369
*
370370
* @throws BadRequestException if the playlist is not found
371371
*/
372-
public suspend fun followPlaylist(playlist: String, followPublicly: Boolean): String = put(
372+
public suspend fun followPlaylist(playlist: String, followPublicly: Boolean = true): String = put(
373373
endpointBuilder("/playlists/${PlaylistUri(playlist).id}/followers").toString(),
374374
"{\"public\": $followPublicly}"
375375
)

0 commit comments

Comments
 (0)