Skip to content

Commit 6a21a7d

Browse files
committed
use cache limit
1 parent 0ba3040 commit 6a21a7d

File tree

3 files changed

+25
-21
lines changed

3 files changed

+25
-21
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ dependencies {
5151
<dependency>
5252
<groupId>com.adamratzman</groupId>
5353
<artifactId>spotify-api-kotlin</artifactId>
54-
<version>2.2.0</version>
54+
<version>2.2.1</version>
5555
</dependency>
5656
5757
<repository>

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ apply plugin: 'kotlin'
2222
apply plugin: 'org.jetbrains.dokka'
2323

2424
group 'com.adamratzman'
25-
version '2.2.0'
25+
version '2.2.1'
2626

2727
archivesBaseName = 'spotify-api-kotlin'
2828

src/main/kotlin/com/adamratzman/spotify/Builder.kt

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ fun spotifyApi(block: SpotifyApiBuilderDsl.() -> Unit) = SpotifyApiBuilderDsl().
1616
* Spotify traditional Java style API builder
1717
*/
1818
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
3030
) {
3131
/**
3232
* Instantiate the builder with the application [clientId] and [clientSecret]
@@ -194,9 +194,9 @@ data class SpotifyCredentials(val clientId: String?, val clientSecret: String?,
194194
* limited time constraint on these before the API automatically refreshes them
195195
*/
196196
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
200200
)
201201

202202
/**
@@ -269,7 +269,7 @@ class SpotifyApiBuilderDsl {
269269
return when {
270270
authentication.token != null -> {
271271
SpotifyAppAPI(clientId ?: "not-set", clientSecret
272-
?: "not-set", authentication.token!!, useCache, false, retryWhenRateLimited, enableLogger)
272+
?: "not-set", authentication.token!!, useCache, cacheLimit, false, retryWhenRateLimited, enableLogger)
273273
}
274274
authentication.tokenString != null -> {
275275
SpotifyAppAPI(
@@ -280,6 +280,7 @@ class SpotifyApiBuilderDsl {
280280
60000, null, null
281281
),
282282
useCache,
283+
cacheLimit,
283284
automaticRefresh,
284285
retryWhenRateLimited,
285286
enableLogger
@@ -288,7 +289,7 @@ class SpotifyApiBuilderDsl {
288289
else -> try {
289290
if (clientId == null || clientSecret == null) throw IllegalArgumentException("Illegal credentials provided")
290291
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)
292293
} catch (e: Exception) {
293294
throw SpotifyException("Invalid credentials provided in the login process", e)
294295
}
@@ -325,9 +326,9 @@ class SpotifyApiBuilderDsl {
325326
* [authorizationCode] or [token] is provided
326327
*/
327328
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
331332
): SpotifyClientAPI {
332333
val clientId = credentials.clientId
333334
val clientSecret = credentials.clientSecret
@@ -357,6 +358,7 @@ class SpotifyApiBuilderDsl {
357358
automaticRefresh,
358359
redirectUri ?: throw IllegalArgumentException(),
359360
useCache,
361+
cacheLimit,
360362
retryWhenRateLimited,
361363
enableLogger
362364
)
@@ -370,6 +372,7 @@ class SpotifyApiBuilderDsl {
370372
automaticRefresh,
371373
redirectUri ?: "not-set",
372374
useCache,
375+
cacheLimit,
373376
retryWhenRateLimited,
374377
enableLogger
375378
)
@@ -386,6 +389,7 @@ class SpotifyApiBuilderDsl {
386389
false,
387390
redirectUri ?: "not-set",
388391
useCache,
392+
cacheLimit,
389393
retryWhenRateLimited,
390394
enableLogger
391395
)

0 commit comments

Comments
 (0)