@@ -16,17 +16,17 @@ fun spotifyApi(block: SpotifyApiBuilderDsl.() -> Unit) = SpotifyApiBuilderDsl().
16
16
* Spotify traditional Java style API builder
17
17
*/
18
18
class SpotifyApiBuilder (
19
- val clientId : String ,
20
- val clientSecret : String ,
21
- var redirectUri : String? = null ,
22
- var authorizationCode : String? = null ,
23
- var tokenString : String? = null ,
24
- var token : Token ? = null ,
25
- var useCache : Boolean = true ,
26
- var cacheLimit : Int? = 1000 ,
27
- var automaticRefresh : Boolean = true ,
28
- var retryWhenRateLimited : Boolean = false ,
29
- var enableLogger : Boolean = false
19
+ val clientId : String ,
20
+ val clientSecret : String ,
21
+ var redirectUri : String? = null ,
22
+ var authorizationCode : String? = null ,
23
+ var tokenString : String? = null ,
24
+ var token : Token ? = null ,
25
+ var useCache : Boolean = true ,
26
+ var cacheLimit : Int? = 1000 ,
27
+ var automaticRefresh : Boolean = true ,
28
+ var retryWhenRateLimited : Boolean = false ,
29
+ var enableLogger : Boolean = false
30
30
) {
31
31
/* *
32
32
* Instantiate the builder with the application [clientId] and [clientSecret]
@@ -194,9 +194,9 @@ data class SpotifyCredentials(val clientId: String?, val clientSecret: String?,
194
194
* limited time constraint on these before the API automatically refreshes them
195
195
*/
196
196
class SpotifyUserAuthorizationBuilder (
197
- var authorizationCode : String? = null ,
198
- var tokenString : String? = null ,
199
- var token : Token ? = null
197
+ var authorizationCode : String? = null ,
198
+ var tokenString : String? = null ,
199
+ var token : Token ? = null
200
200
)
201
201
202
202
/* *
@@ -269,7 +269,7 @@ class SpotifyApiBuilderDsl {
269
269
return when {
270
270
authentication.token != null -> {
271
271
SpotifyAppAPI (clientId ? : " not-set" , clientSecret
272
- ? : " not-set" , authentication.token!! , useCache, false , retryWhenRateLimited, enableLogger)
272
+ ? : " not-set" , authentication.token!! , useCache, cacheLimit, false , retryWhenRateLimited, enableLogger)
273
273
}
274
274
authentication.tokenString != null -> {
275
275
SpotifyAppAPI (
@@ -280,6 +280,7 @@ class SpotifyApiBuilderDsl {
280
280
60000 , null , null
281
281
),
282
282
useCache,
283
+ cacheLimit,
283
284
automaticRefresh,
284
285
retryWhenRateLimited,
285
286
enableLogger
@@ -288,7 +289,7 @@ class SpotifyApiBuilderDsl {
288
289
else -> try {
289
290
if (clientId == null || clientSecret == null ) throw IllegalArgumentException (" Illegal credentials provided" )
290
291
val token = getCredentialedToken(clientId, clientSecret, null )
291
- SpotifyAppAPI (clientId, clientSecret, token, useCache, automaticRefresh, retryWhenRateLimited, enableLogger)
292
+ SpotifyAppAPI (clientId, clientSecret, token, useCache, cacheLimit, automaticRefresh, retryWhenRateLimited, enableLogger)
292
293
} catch (e: Exception ) {
293
294
throw SpotifyException (" Invalid credentials provided in the login process" , e)
294
295
}
@@ -325,9 +326,9 @@ class SpotifyApiBuilderDsl {
325
326
* [authorizationCode] or [token] is provided
326
327
*/
327
328
private fun buildClient (
328
- authorizationCode : String? = null,
329
- tokenString : String? = null,
330
- token : Token ? = null
329
+ authorizationCode : String? = null,
330
+ tokenString : String? = null,
331
+ token : Token ? = null
331
332
): SpotifyClientAPI {
332
333
val clientId = credentials.clientId
333
334
val clientSecret = credentials.clientSecret
@@ -357,6 +358,7 @@ class SpotifyApiBuilderDsl {
357
358
automaticRefresh,
358
359
redirectUri ? : throw IllegalArgumentException (),
359
360
useCache,
361
+ cacheLimit,
360
362
retryWhenRateLimited,
361
363
enableLogger
362
364
)
@@ -370,6 +372,7 @@ class SpotifyApiBuilderDsl {
370
372
automaticRefresh,
371
373
redirectUri ? : " not-set" ,
372
374
useCache,
375
+ cacheLimit,
373
376
retryWhenRateLimited,
374
377
enableLogger
375
378
)
@@ -386,6 +389,7 @@ class SpotifyApiBuilderDsl {
386
389
false ,
387
390
redirectUri ? : " not-set" ,
388
391
useCache,
392
+ cacheLimit,
389
393
retryWhenRateLimited,
390
394
enableLogger
391
395
)
0 commit comments