File tree Expand file tree Collapse file tree 2 files changed +10
-15
lines changed
src/commonTest/kotlin/com.adamratzman/spotify Expand file tree Collapse file tree 2 files changed +10
-15
lines changed Original file line number Diff line number Diff line change @@ -6,36 +6,29 @@ val _clientSecret = getEnvironmentVariable("SPOTIFY_CLIENT_SECRET")
6
6
val _redirectUri = getEnvironmentVariable(" SPOTIFY_REDIRECT_URI" )
7
7
val _tokenString = getEnvironmentVariable(" SPOTIFY_TOKEN_STRING" )
8
8
9
- val api = {
10
- println (_redirectUri )
11
- println (_clientId )
12
- println (_redirectUri .isNullOrBlank())
13
- println (_clientId .isNullOrBlank())
14
-
15
- }.let { when {
16
- _redirectUri ?.isNotBlank() != true -> {
17
- spotifyAppApi {
9
+ val api = when {
10
+ _redirectUri ?.isNotBlank() == true -> {
11
+ spotifyClientApi {
18
12
credentials {
19
13
clientId = _clientId
20
14
clientSecret = _clientSecret
15
+ redirectUri = _redirectUri
16
+ }
17
+ authorization {
18
+ tokenString = _tokenString
21
19
}
22
20
}.build()
23
21
}
24
22
_clientId ?.isNotBlank() == true -> {
25
- spotifyClientApi {
23
+ spotifyAppApi {
26
24
credentials {
27
25
clientId = _clientId
28
26
clientSecret = _clientSecret
29
- redirectUri = _redirectUri
30
- }
31
- authorization {
32
- tokenString = _tokenString
33
27
}
34
28
}.build()
35
29
}
36
30
else -> null
37
31
}
38
- }
39
32
40
33
expect fun getEnvironmentVariable (name : String ): String?
41
34
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ class UtilityTests : Spek({
59
59
}
60
60
61
61
it("Refresh on invalid token") {
62
+ if (api == null) return @it
62
63
val api = spotifyAppApi {
63
64
credentials {
64
65
clientId = getEnvironmentVariable("SPOTIFY_CLIENT_ID ")
@@ -68,6 +69,7 @@ class UtilityTests : Spek({
68
69
}
69
70
70
71
it("Automatic refresh") {
72
+ if (api == null) return @it
71
73
val api = spotifyAppApi {
72
74
credentials {
73
75
clientId = getEnvironmentVariable("SPOTIFY_CLIENT_ID ")
You can’t perform that action at this time.
0 commit comments