@@ -33,7 +33,6 @@ fun getSpotifyAuthorizationUrl(vararg scopes: SpotifyScope, clientId: String, re
33
33
return SpotifyApi .getAuthUrlFull(* scopes, clientId = clientId, redirectUri = redirectUri, isImplicitGrantFlow = isImplicitGrantFlow, shouldShowDialog = shouldShowDialog)
34
34
}
35
35
36
-
37
36
// ==============================================
38
37
39
38
// Implicit grant builder
@@ -77,7 +76,6 @@ fun spotifyImplicitGrantApi(clientId: String, redirectUri: String, token: Token,
77
76
options.json
78
77
)
79
78
80
-
81
79
// App Api builders
82
80
83
81
/*
@@ -131,7 +129,6 @@ fun spotifyAppApi(clientId: String, clientSecret: String, block: SpotifyAppApiBu
131
129
*/
132
130
fun spotifyAppApi (block : SpotifyAppApiBuilder .() -> Unit ) = SpotifyAppApiBuilder ().apply (block)
133
131
134
-
135
132
// Client Api Builders
136
133
/*
137
134
____________________________
@@ -160,10 +157,10 @@ fun spotifyAppApi(block: SpotifyAppApiBuilder.() -> Unit) = SpotifyAppApiBuilder
160
157
* @return Configurable [SpotifyClientApiBuilder] that, when built, creates a new [SpotifyClientApi]
161
158
*/
162
159
fun spotifyClientApi (
163
- clientId : String ,
164
- clientSecret : String ,
165
- redirectUri : String ,
166
- block : SpotifyClientApiBuilder .() -> Unit
160
+ clientId : String ,
161
+ clientSecret : String ,
162
+ redirectUri : String ,
163
+ block : SpotifyClientApiBuilder .() -> Unit
167
164
) = SpotifyClientApiBuilder ().apply (block).apply {
168
165
credentials {
169
166
this .clientId = clientId
@@ -189,12 +186,12 @@ fun spotifyClientApi(
189
186
* @return Configurable [SpotifyClientApiBuilder] that, when built, creates a new [SpotifyClientApi]
190
187
*/
191
188
fun spotifyClientApi (
192
- clientId : String ,
193
- clientSecret : String ,
194
- redirectUri : String ,
195
- authorization : SpotifyUserAuthorization ,
196
- options : SpotifyApiOptions ? = null,
197
- block : SpotifyClientApiBuilder .() -> Unit = {}
189
+ clientId : String ,
190
+ clientSecret : String ,
191
+ redirectUri : String ,
192
+ authorization : SpotifyUserAuthorization ,
193
+ options : SpotifyApiOptions ? = null,
194
+ block : SpotifyClientApiBuilder .() -> Unit = {}
198
195
) = SpotifyClientApiBuilder ().apply (block).apply {
199
196
credentials {
200
197
this .clientId = clientId
@@ -217,14 +214,13 @@ fun spotifyClientApi(
217
214
*/
218
215
fun spotifyClientApi (block : SpotifyClientApiBuilder .() -> Unit ) = SpotifyClientApiBuilder ().apply (block)
219
216
220
-
221
217
/* *
222
218
* Spotify API builder
223
219
*/
224
220
class SpotifyApiBuilder (
225
- private var clientId : String? ,
226
- private var clientSecret : String? ,
227
- private var redirectUri : String?
221
+ private var clientId : String? ,
222
+ private var clientSecret : String? ,
223
+ private var redirectUri : String?
228
224
) {
229
225
/* *
230
226
* Allows you to authenticate a [SpotifyClientApi] with an authorization code
@@ -501,9 +497,9 @@ interface ISpotifyClientApiBuilder : ISpotifyApiBuilder<SpotifyClientApi, Spotif
501
497
* [SpotifyClientApi] builder for api creation using client authorization
502
498
*/
503
499
class SpotifyClientApiBuilder (
504
- override var credentials : SpotifyCredentials = SpotifyCredentialsBuilder ().build(),
505
- override var authorization : SpotifyUserAuthorization = SpotifyUserAuthorizationBuilder ().build(),
506
- override var options : SpotifyApiOptions = SpotifyApiOptionsBuilder ().build()
500
+ override var credentials : SpotifyCredentials = SpotifyCredentialsBuilder ().build(),
501
+ override var authorization : SpotifyUserAuthorization = SpotifyUserAuthorizationBuilder ().build(),
502
+ override var options : SpotifyApiOptions = SpotifyApiOptionsBuilder ().build()
507
503
) : ISpotifyClientApiBuilder {
508
504
override fun getAuthorizationUrl (vararg scopes : SpotifyScope ): String {
509
505
require(credentials.redirectUri != null && credentials.clientId != null ) { " You didn't specify a redirect uri or client id in the credentials block!" }
@@ -613,9 +609,9 @@ interface ISpotifyAppApiBuilder : ISpotifyApiBuilder<SpotifyAppApi, SpotifyAppAp
613
609
* [SpotifyAppApi] builder for api creation using client authorization
614
610
*/
615
611
class SpotifyAppApiBuilder (
616
- override var credentials : SpotifyCredentials = SpotifyCredentialsBuilder ().build(),
617
- override var authorization : SpotifyUserAuthorization = SpotifyUserAuthorizationBuilder ().build(),
618
- override var options : SpotifyApiOptions = SpotifyApiOptionsBuilder ().build()
612
+ override var credentials : SpotifyCredentials = SpotifyCredentialsBuilder ().build(),
613
+ override var authorization : SpotifyUserAuthorization = SpotifyUserAuthorizationBuilder ().build(),
614
+ override var options : SpotifyApiOptions = SpotifyApiOptionsBuilder ().build()
619
615
) : ISpotifyAppApiBuilder {
620
616
/* *
621
617
* Build a public [SpotifyAppApi] using the provided credentials
@@ -734,10 +730,10 @@ data class SpotifyCredentials(val clientId: String?, val clientSecret: String?,
734
730
* limited time constraint on these before the API automatically refreshes them
735
731
*/
736
732
class SpotifyUserAuthorizationBuilder (
737
- var authorizationCode : String? = null ,
738
- var tokenString : String? = null ,
739
- var token : Token ? = null ,
740
- var refreshTokenString : String? = null
733
+ var authorizationCode : String? = null ,
734
+ var tokenString : String? = null ,
735
+ var token : Token ? = null ,
736
+ var refreshTokenString : String? = null
741
737
) {
742
738
fun build () = SpotifyUserAuthorization (authorizationCode, tokenString, token, refreshTokenString)
743
739
}
@@ -754,10 +750,10 @@ class SpotifyUserAuthorizationBuilder(
754
750
* @property refreshTokenString Refresh token, given as a string, to be exchanged to Spotify for a new token
755
751
*/
756
752
data class SpotifyUserAuthorization (
757
- var authorizationCode : String? = null ,
758
- var tokenString : String? = null ,
759
- var token : Token ? = null ,
760
- var refreshTokenString : String? = null
753
+ var authorizationCode : String? = null ,
754
+ var tokenString : String? = null ,
755
+ var token : Token ? = null ,
756
+ var refreshTokenString : String? = null
761
757
)
762
758
763
759
/* *
@@ -777,17 +773,17 @@ data class SpotifyUserAuthorization(
777
773
*
778
774
*/
779
775
class SpotifyApiOptionsBuilder (
780
- var useCache : Boolean = true ,
781
- var cacheLimit : Int? = 200 ,
782
- var automaticRefresh : Boolean = true ,
783
- var retryWhenRateLimited : Boolean = true ,
784
- var enableLogger : Boolean = true ,
785
- var testTokenValidity : Boolean = false ,
786
- var enableAllOptions : Boolean = false ,
787
- var defaultLimit : Int = 50 ,
788
- var allowBulkRequests : Boolean = true ,
789
- var requestTimeoutMillis : Long? = null ,
790
- var json : Json = nonstrictJson
776
+ var useCache : Boolean = true ,
777
+ var cacheLimit : Int? = 200 ,
778
+ var automaticRefresh : Boolean = true ,
779
+ var retryWhenRateLimited : Boolean = true ,
780
+ var enableLogger : Boolean = true ,
781
+ var testTokenValidity : Boolean = false ,
782
+ var enableAllOptions : Boolean = false ,
783
+ var defaultLimit : Int = 50 ,
784
+ var allowBulkRequests : Boolean = true ,
785
+ var requestTimeoutMillis : Long? = null ,
786
+ var json : Json = nonstrictJson
791
787
) {
792
788
fun build () =
793
789
if (enableAllOptions)
@@ -835,16 +831,16 @@ class SpotifyApiOptionsBuilder(
835
831
*/
836
832
837
833
data class SpotifyApiOptions (
838
- var useCache : Boolean ,
839
- var cacheLimit : Int? ,
840
- var automaticRefresh : Boolean ,
841
- var retryWhenRateLimited : Boolean ,
842
- var enableLogger : Boolean ,
843
- var testTokenValidity : Boolean ,
844
- var defaultLimit : Int ,
845
- var allowBulkRequests : Boolean ,
846
- var requestTimeoutMillis : Long? ,
847
- var json : Json
834
+ var useCache : Boolean ,
835
+ var cacheLimit : Int? ,
836
+ var automaticRefresh : Boolean ,
837
+ var retryWhenRateLimited : Boolean ,
838
+ var enableLogger : Boolean ,
839
+ var testTokenValidity : Boolean ,
840
+ var defaultLimit : Int ,
841
+ var allowBulkRequests : Boolean ,
842
+ var requestTimeoutMillis : Long? ,
843
+ var json : Json
848
844
)
849
845
850
846
@Deprecated(" Name has been replaced by `options`" , ReplaceWith (" SpotifyApiOptions" ))
0 commit comments