1
1
/* Spotify Web API - Kotlin Wrapper; MIT License, 2019; Original author: Adam Ratzman */
2
2
package com.adamratzman.spotify
3
3
4
- import com.adamratzman.spotify.SpotifyBuilder .Companion.spotifyAppApi
5
- import com.adamratzman.spotify.SpotifyBuilder .Companion.spotifyClientApi
4
+ import com.adamratzman.spotify.SpotifyApi .Companion.spotifyAppApi
5
+ import com.adamratzman.spotify.SpotifyApi .Companion.spotifyClientApi
6
6
import com.adamratzman.spotify.http.HttpConnection
7
7
import com.adamratzman.spotify.http.HttpRequestMethod
8
8
import com.adamratzman.spotify.models.Token
@@ -17,104 +17,21 @@ import kotlinx.serialization.json.Json
17
17
18
18
// Kotlin DSL builders
19
19
20
- @Deprecated(" Builder methods are now found in SpotifyBuilder " , ReplaceWith (" SpotifyBuilder .spotifyAppApi" ))
20
+ @Deprecated(" Builder methods are now found in SpotifyApi " , ReplaceWith (" SpotifyApi .spotifyAppApi" ))
21
21
fun spotifyAppApi (clientId : String , clientSecret : String , block : SpotifyAppApiBuilder .() -> Unit = {}) =
22
- SpotifyBuilder .spotifyAppApi(clientId, clientSecret, block)
22
+ SpotifyApi .spotifyAppApi(clientId, clientSecret, block)
23
23
24
- @Deprecated(" Builder methods are now found in SpotifyBuilder " , ReplaceWith (" SpotifyBuilder .spotifyAppApi" ))
24
+ @Deprecated(" Builder methods are now found in SpotifyApi " , ReplaceWith (" SpotifyApi .spotifyAppApi" ))
25
25
fun spotifyAppApi (block : SpotifyAppApiBuilder .() -> Unit ) =
26
- SpotifyBuilder .spotifyAppApi(block)
26
+ SpotifyApi .spotifyAppApi(block)
27
27
28
- @Deprecated(" Builder methods are now found in SpotifyBuilder " , ReplaceWith (" SpotifyBuilder .spotifyClientApi" ))
28
+ @Deprecated(" Builder methods are now found in SpotifyApi " , ReplaceWith (" SpotifyApi .spotifyClientApi" ))
29
29
fun spotifyAppApi (clientId : String , clientSecret : String , redirectUri : String , block : SpotifyClientApiBuilder .() -> Unit = {}) =
30
- SpotifyBuilder .spotifyClientApi(clientId, clientSecret, redirectUri, block)
30
+ SpotifyApi .spotifyClientApi(clientId, clientSecret, redirectUri, block)
31
31
32
- @Deprecated(" Builder methods are now found in SpotifyBuilder " , ReplaceWith (" SpotifyBuilder .spotifyClientApi" ))
32
+ @Deprecated(" Builder methods are now found in SpotifyApi " , ReplaceWith (" SpotifyApi .spotifyClientApi" ))
33
33
fun spotifyAppApi (block : SpotifyClientApiBuilder .() -> Unit ) =
34
- SpotifyBuilder .spotifyClientApi(block)
35
-
36
- /* *
37
- * Contains static methods to instantiate [SpotifyAppApi] and [SpotifyClientApi] instances
38
- */
39
- class SpotifyBuilder {
40
- companion object {
41
- /*
42
- App Api Builders
43
- */
44
-
45
- /* *
46
- * Instantiate a new [SpotifyAppApiBuilder] using a Spotify [clientId] and [clientSecret], with the ability to configure
47
- * the api settings by providing a builder initialization [block]
48
- *
49
- * @param clientId Spotify [client id](https://developer.spotify.com/documentation/general/guides/app-settings/)
50
- * @param clientSecret Spotify [client secret](https://developer.spotify.com/documentation/general/guides/app-settings/)
51
- * @param block Api settings block
52
- *
53
- * @return Configurable [SpotifyAppApiBuilder] that, when built, creates a new [SpotifyAppApi]
54
- */
55
- fun spotifyAppApi (clientId : String , clientSecret : String , block : SpotifyAppApiBuilder .() -> Unit = {}) =
56
- SpotifyAppApiBuilder ().apply (block).apply {
57
- credentials {
58
- this .clientId = clientId
59
- this .clientSecret = clientSecret
60
- }
61
- }
62
-
63
- /* *
64
- * Instantiate a new [SpotifyAppApiBuilder] by providing a builder initialization [block].
65
- *
66
- * **Note**: You **must** provide your app credentials in the [SpotifyAppApiBuilder.credentials] block
67
- *
68
- * @param block Api settings block
69
- *
70
- * @return Configurable [SpotifyAppApiBuilder] that, when built, creates a new [SpotifyAppApi]
71
- */
72
- fun spotifyAppApi (block : SpotifyAppApiBuilder .() -> Unit ) = SpotifyAppApiBuilder ().apply (block)
73
-
74
- /*
75
- Client Api Builders
76
- */
77
-
78
- /* *
79
- * Instantiate a new [SpotifyClientApiBuilder] using a Spotify [clientId], [clientSecret], and [redirectUri], with the ability to configure
80
- * the api settings by providing a builder initialization [block]
81
- *
82
- * **Note**: If trying to build [SpotifyClientApi], you **must** provide client authorization in the [SpotifyClientApiBuilder.authorization]
83
- * block
84
- *
85
- * @param clientId Spotify [client id](https://developer.spotify.com/documentation/general/guides/app-settings/)
86
- * @param clientSecret Spotify [client secret](https://developer.spotify.com/documentation/general/guides/app-settings/)
87
- * @param redirectUri Spotify [redirect uri](https://developer.spotify.com/documentation/general/guides/app-settings/)
88
- * @param block Api settings block
89
- *
90
- * @return Configurable [SpotifyClientApiBuilder] that, when built, creates a new [SpotifyClientApi]
91
- */
92
- fun spotifyClientApi (
93
- clientId : String ,
94
- clientSecret : String ,
95
- redirectUri : String ,
96
- block : SpotifyClientApiBuilder .() -> Unit
97
- ) = SpotifyClientApiBuilder ().apply (block).apply {
98
- credentials {
99
- this .clientId = clientId
100
- this .clientSecret = clientSecret
101
- this .redirectUri = redirectUri
102
- }
103
- }
104
-
105
- /* *
106
- * Instantiate a new [SpotifyClientApiBuilder] by providing a builder initialization [block]
107
- *
108
- * **Note**: If trying to build [SpotifyClientApi], you **must** provide client authorization in the [SpotifyClientApiBuilder.authorization]
109
- * block
110
- *
111
- * @param block Api settings block
112
- *
113
- * @return Configurable [SpotifyClientApiBuilder] that, when built, creates a new [SpotifyClientApi]
114
- */
115
- fun spotifyClientApi (block : SpotifyClientApiBuilder .() -> Unit ) = SpotifyClientApiBuilder ().apply (block)
116
- }
117
- }
34
+ SpotifyApi .spotifyClientApi(block)
118
35
119
36
/* *
120
37
* Spotify API builder
0 commit comments