@@ -214,7 +214,7 @@ data class SpotifyUserAuthorization(
214
214
* @property testTokenValidity After API creation, test whether the token is valid by performing a lightweight request
215
215
* @property enableAllUtilities Whether to enable all provided utilities
216
216
*/
217
- class SpotifyUtilitiesBuilder (
217
+ class SpotifyApiOptionsBuilder (
218
218
var useCache : Boolean = true ,
219
219
var cacheLimit : Int? = 200 ,
220
220
var automaticRefresh : Boolean = true ,
@@ -225,7 +225,7 @@ class SpotifyUtilitiesBuilder(
225
225
) {
226
226
fun build () =
227
227
if (enableAllUtilities)
228
- SpotifyUtilities (
228
+ SpotifyApiOptions (
229
229
true ,
230
230
200 ,
231
231
automaticRefresh = true ,
@@ -234,7 +234,7 @@ class SpotifyUtilitiesBuilder(
234
234
testTokenValidity = true
235
235
)
236
236
else
237
- SpotifyUtilities (
237
+ SpotifyApiOptions (
238
238
useCache,
239
239
cacheLimit,
240
240
automaticRefresh,
@@ -244,7 +244,7 @@ class SpotifyUtilitiesBuilder(
244
244
)
245
245
}
246
246
247
- data class SpotifyUtilities (
247
+ data class SpotifyApiOptions (
248
248
val useCache : Boolean ,
249
249
val cacheLimit : Int? ,
250
250
val automaticRefresh : Boolean ,
@@ -253,6 +253,9 @@ data class SpotifyUtilities(
253
253
val testTokenValidity : Boolean
254
254
)
255
255
256
+ typealias SpotifyUtilities = SpotifyApiOptions
257
+ typealias SpotifyUtilitiesBuilder = SpotifyApiOptionsBuilder
258
+
256
259
/* *
257
260
* Spotify API mutable parameters
258
261
*
@@ -264,7 +267,7 @@ data class SpotifyUtilities(
264
267
class SpotifyApiBuilderDsl {
265
268
private var credentials: SpotifyCredentials = SpotifyCredentialsBuilder ().build()
266
269
private var authentication: SpotifyUserAuthorization = SpotifyUserAuthorizationBuilder ().build()
267
- private var utilities: SpotifyUtilities = SpotifyUtilitiesBuilder ().build()
270
+ private var utilities: SpotifyApiOptions = SpotifyApiOptionsBuilder ().build()
268
271
269
272
/* *
270
273
* A block in which Spotify application credentials (accessible via the Spotify [dashboard](https://developer.spotify.com/dashboard/applications))
@@ -285,22 +288,22 @@ class SpotifyApiBuilderDsl {
285
288
/* *
286
289
* Allows you to override default values for caching, token refresh, and logging
287
290
*/
288
- fun utilities (block : SpotifyUtilitiesBuilder .() -> Unit ) {
289
- utilities = SpotifyUtilitiesBuilder ().apply (block).build()
291
+ fun utilities (block : SpotifyApiOptionsBuilder .() -> Unit ) {
292
+ utilities = SpotifyApiOptionsBuilder ().apply (block).build()
290
293
}
291
294
292
295
/* *
293
296
* Allows you to override default values for caching, token refresh, and logging
294
297
*/
295
- fun config (block : SpotifyUtilitiesBuilder .() -> Unit ) {
296
- utilities = SpotifyUtilitiesBuilder ().apply (block).build()
298
+ fun config (block : SpotifyApiOptionsBuilder .() -> Unit ) {
299
+ utilities = SpotifyApiOptionsBuilder ().apply (block).build()
297
300
}
298
301
299
302
/* *
300
303
* Allows you to override default values for caching, token refresh, and logging
301
304
*/
302
- fun options (block : SpotifyUtilitiesBuilder .() -> Unit ) {
303
- utilities = SpotifyUtilitiesBuilder ().apply (block).build()
305
+ fun options (block : SpotifyApiOptionsBuilder .() -> Unit ) {
306
+ utilities = SpotifyApiOptionsBuilder ().apply (block).build()
304
307
}
305
308
306
309
/* *
@@ -443,49 +446,49 @@ class SpotifyApiBuilderDsl {
443
446
), clientId, clientSecret)
444
447
445
448
SpotifyClientAPI (
446
- clientId,
447
- clientSecret,
448
- response.body.toObject(null ),
449
- utilities.automaticRefresh,
450
- redirectUri,
451
- utilities.useCache,
452
- utilities.cacheLimit,
453
- utilities.retryWhenRateLimited,
454
- utilities.enableLogger,
455
- utilities.testTokenValidity
456
- )
457
- } catch (e: Exception ) {
458
- throw SpotifyException (" Invalid credentials provided in the login process" , e)
459
- }
460
- token != null -> SpotifyClientAPI (
461
- clientId ? : " not-set" ,
462
- clientSecret ? : " not-set" ,
463
- token,
464
- utilities.automaticRefresh,
465
- redirectUri ? : " not-set" ,
449
+ clientId,
450
+ clientSecret,
451
+ redirectUri,
452
+ response.body.toObject(null ),
466
453
utilities.useCache,
467
454
utilities.cacheLimit,
455
+ utilities.automaticRefresh,
468
456
utilities.retryWhenRateLimited,
469
457
utilities.enableLogger,
470
458
utilities.testTokenValidity
459
+ )
460
+ } catch (e: Exception ) {
461
+ throw SpotifyException (" Invalid credentials provided in the login process" , e)
462
+ }
463
+ token != null -> SpotifyClientAPI (
464
+ clientId ? : " not-set" ,
465
+ clientSecret ? : " not-set" ,
466
+ redirectUri ? : " not-set" ,
467
+ token,
468
+ utilities.useCache,
469
+ utilities.cacheLimit,
470
+ utilities.automaticRefresh,
471
+ utilities.retryWhenRateLimited,
472
+ utilities.enableLogger,
473
+ utilities.testTokenValidity
471
474
)
472
475
tokenString != null -> SpotifyClientAPI (
473
- clientId ? : " not-set" ,
474
- clientSecret ? : " not-set" ,
475
- Token (
476
- tokenString,
477
- " client_credentials " ,
478
- 1000 ,
479
- null ,
480
- null
481
- ),
482
- false ,
483
- redirectUri ? : " not-set " ,
484
- utilities.useCache ,
485
- utilities.cacheLimit ,
486
- utilities.retryWhenRateLimited,
487
- utilities.enableLogger,
488
- utilities.testTokenValidity
476
+ clientId ? : " not-set" ,
477
+ clientSecret ? : " not-set" ,
478
+ redirectUri ? : " not-set " ,
479
+ Token (
480
+ tokenString ,
481
+ " client_credentials " ,
482
+ 1000 ,
483
+ null ,
484
+ null
485
+ ) ,
486
+ utilities.useCache ,
487
+ utilities.cacheLimit ,
488
+ false ,
489
+ utilities.retryWhenRateLimited,
490
+ utilities.enableLogger,
491
+ utilities.testTokenValidity
489
492
)
490
493
else -> throw IllegalArgumentException (
491
494
" At least one of: authorizationCode, tokenString, or token must be provided " +
0 commit comments