Skip to content

Commit 5ad33ea

Browse files
committed
lint, major version bump due to breaking library changes
1 parent af86639 commit 5ad33ea

File tree

20 files changed

+357
-361
lines changed

20 files changed

+357
-361
lines changed

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.1'
25+
version '2.3.0'
2626

2727
archivesBaseName = 'spotify-api-kotlin'
2828

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

Lines changed: 17 additions & 17 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
/**
@@ -326,9 +326,9 @@ class SpotifyApiBuilderDsl {
326326
* [authorizationCode] or [token] is provided
327327
*/
328328
private fun buildClient(
329-
authorizationCode: String? = null,
330-
tokenString: String? = null,
331-
token: Token? = null
329+
authorizationCode: String? = null,
330+
tokenString: String? = null,
331+
token: Token? = null
332332
): SpotifyClientAPI {
333333
val clientId = credentials.clientId
334334
val clientSecret = credentials.clientSecret

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

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ internal val base = "https://api.spotify.com/v1"
5555
*
5656
*/
5757
abstract class SpotifyAPI internal constructor(
58-
val clientId: String,
59-
val clientSecret: String,
60-
var token: Token,
61-
useCache: Boolean,
62-
var cacheLimit: Int?,
63-
var automaticRefresh: Boolean,
64-
var retryWhenRateLimited: Boolean,
65-
enableLogger: Boolean
58+
val clientId: String,
59+
val clientSecret: String,
60+
var token: Token,
61+
useCache: Boolean,
62+
var cacheLimit: Int?,
63+
var automaticRefresh: Boolean,
64+
var retryWhenRateLimited: Boolean,
65+
enableLogger: Boolean
6666
) {
6767
var useCache = useCache
6868
set(value) {
@@ -124,7 +124,6 @@ abstract class SpotifyAPI internal constructor(
124124
.add(KotlinJsonAdapterFactory())
125125
.build()
126126

127-
128127
private fun clearCaches(vararg endpoints: SpotifyEndpoint) {
129128
endpoints.forEach { it.cache.clear() }
130129
}
@@ -157,14 +156,14 @@ abstract class SpotifyAPI internal constructor(
157156
* client authentication
158157
*/
159158
class SpotifyAppAPI internal constructor(
160-
clientId: String,
161-
clientSecret: String,
162-
token: Token,
163-
useCache: Boolean,
164-
cacheLimit: Int?,
165-
automaticRefresh: Boolean,
166-
retryWhenRateLimited: Boolean,
167-
enableLogger: Boolean
159+
clientId: String,
160+
clientSecret: String,
161+
token: Token,
162+
useCache: Boolean,
163+
cacheLimit: Int?,
164+
automaticRefresh: Boolean,
165+
retryWhenRateLimited: Boolean,
166+
enableLogger: Boolean
168167
) : SpotifyAPI(clientId, clientSecret, token, useCache, cacheLimit, automaticRefresh, retryWhenRateLimited, enableLogger) {
169168

170169
override val search: SearchAPI = SearchAPI(this)
@@ -228,15 +227,15 @@ class SpotifyAppAPI internal constructor(
228227
* managed through the scopes exposed in [token]
229228
*/
230229
class SpotifyClientAPI internal constructor(
231-
clientId: String,
232-
clientSecret: String,
233-
token: Token,
234-
automaticRefresh: Boolean,
235-
var redirectUri: String,
236-
useCache: Boolean,
237-
cacheLimit: Int?,
238-
retryWhenRateLimited: Boolean,
239-
enableLogger: Boolean
230+
clientId: String,
231+
clientSecret: String,
232+
token: Token,
233+
automaticRefresh: Boolean,
234+
var redirectUri: String,
235+
useCache: Boolean,
236+
cacheLimit: Int?,
237+
retryWhenRateLimited: Boolean,
238+
enableLogger: Boolean
240239
) : SpotifyAPI(clientId, clientSecret, token, useCache, cacheLimit, automaticRefresh, retryWhenRateLimited, enableLogger) {
241240
override val search: SearchAPI = SearchAPI(this)
242241
override val albums: AlbumAPI = AlbumAPI(this)
@@ -390,7 +389,6 @@ fun getCredentialedToken(clientId: String, clientSecret: String, api: SpotifyAPI
390389
throw BadRequestException(response.body.toObject<AuthenticationError>(null))
391390
}
392391

393-
394392
internal fun executeTokenRequest(httpConnection: HttpConnection, clientId: String, clientSecret: String): HttpResponse {
395393
return httpConnection.execute(listOf(HttpHeader("Authorization", "Basic ${"$clientId:$clientSecret".byteEncode()}")))
396394
}

src/main/kotlin/com/adamratzman/spotify/endpoints/client/ClientPlayerAPI.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ class ClientPlayerAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
7070
*
7171
*/
7272
fun getRecentlyPlayed(
73-
limit: Int? = null,
74-
before: String? = null,
75-
after: String? = null
73+
limit: Int? = null,
74+
before: String? = null,
75+
after: String? = null
7676
): SpotifyRestActionPaging<PlayHistory, CursorBasedPagingObject<PlayHistory>> {
7777
return toActionPaging(Supplier {
7878
get(
@@ -232,13 +232,13 @@ class ClientPlayerAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
232232
* @throws BadRequestException if more than one type of play type is specified or the offset is illegal.
233233
*/
234234
fun startPlayback(
235-
album: String? = null,
236-
artist: String? = null,
237-
playlist: PlaylistURI? = null,
238-
offsetNum: Int? = null,
239-
offsetTrackId: String? = null,
240-
deviceId: String? = null,
241-
vararg tracksToPlay: String
235+
album: String? = null,
236+
artist: String? = null,
237+
playlist: PlaylistURI? = null,
238+
offsetNum: Int? = null,
239+
offsetTrackId: String? = null,
240+
deviceId: String? = null,
241+
vararg tracksToPlay: String
242242
): SpotifyRestAction<Unit> {
243243
return toAction(Supplier {
244244
val url = EndpointBuilder("/me/player/play").with("device_id", deviceId).toString()

src/main/kotlin/com/adamratzman/spotify/endpoints/client/ClientPlaylistAPI.kt

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ class ClientPlaylistAPI(api: SpotifyAPI) : PlaylistAPI(api) {
5454
* @return The created [Playlist] object with no tracks
5555
*/
5656
fun createPlaylist(
57-
name: String,
58-
description: String? = null,
59-
public: Boolean? = null,
60-
collaborative: Boolean? = null,
61-
user: String = (api as SpotifyClientAPI).userId
57+
name: String,
58+
description: String? = null,
59+
public: Boolean? = null,
60+
collaborative: Boolean? = null,
61+
user: String = (api as SpotifyClientAPI).userId
6262
): SpotifyRestAction<Playlist> {
6363
if (name.isEmpty()) throw BadRequestException(ErrorObject(400, "Name cannot be empty"))
6464
return toAction(Supplier {
@@ -133,11 +133,11 @@ class ClientPlaylistAPI(api: SpotifyAPI) : PlaylistAPI(api) {
133133
* @throws BadRequestException if the playlist is not found or parameters exceed the max length
134134
*/
135135
fun changePlaylistDetails(
136-
playlist: String,
137-
name: String? = null,
138-
public: Boolean? = null,
139-
collaborative: Boolean? = null,
140-
description: String? = null
136+
playlist: String,
137+
name: String? = null,
138+
public: Boolean? = null,
139+
collaborative: Boolean? = null,
140+
description: String? = null
141141
): SpotifyRestAction<Unit> {
142142
val json = jsonMap()
143143
if (name != null) json["name"] = name
@@ -166,8 +166,8 @@ class ClientPlaylistAPI(api: SpotifyAPI) : PlaylistAPI(api) {
166166
* @throws BadRequestException if the filters provided are illegal
167167
*/
168168
fun getPlaylists(
169-
limit: Int? = null,
170-
offset: Int? = null
169+
limit: Int? = null,
170+
offset: Int? = null
171171
): SpotifyRestActionPaging<SimplePlaylist, PagingObject<SimplePlaylist>> {
172172
if (limit != null && limit !in 1..50) throw IllegalArgumentException("Limit must be between 1 and 50. Provided $limit")
173173
if (offset != null && offset !in 0..100000) throw IllegalArgumentException("Offset must be between 0 and 100,000. Provided $limit")
@@ -229,11 +229,11 @@ class ClientPlaylistAPI(api: SpotifyAPI) : PlaylistAPI(api) {
229229
* @throws BadRequestException if the playlist is not found or illegal filters are applied
230230
*/
231231
fun reorderPlaylistTracks(
232-
playlist: String,
233-
reorderRangeStart: Int,
234-
reorderRangeLength: Int? = null,
235-
insertionPoint: Int,
236-
snapshotId: String? = null
232+
playlist: String,
233+
reorderRangeStart: Int,
234+
reorderRangeLength: Int? = null,
235+
insertionPoint: Int,
236+
snapshotId: String? = null
237237
): SpotifyRestAction<Snapshot> {
238238
return toAction(Supplier {
239239
val json = jsonMap()
@@ -316,12 +316,12 @@ class ClientPlaylistAPI(api: SpotifyAPI) : PlaylistAPI(api) {
316316
* @throws BadRequestException if invalid data is provided
317317
*/
318318
fun uploadPlaylistCover(
319-
playlist: String,
320-
imagePath: String? = null,
321-
imageFile: File? = null,
322-
image: BufferedImage? = null,
323-
imageData: String? = null,
324-
imageUrl: String? = null
319+
playlist: String,
320+
imagePath: String? = null,
321+
imageFile: File? = null,
322+
image: BufferedImage? = null,
323+
imageData: String? = null,
324+
imageUrl: String? = null
325325
): SpotifyRestAction<Unit> {
326326
return toAction(Supplier {
327327
val data = imageData ?: when {
@@ -351,10 +351,10 @@ class ClientPlaylistAPI(api: SpotifyAPI) : PlaylistAPI(api) {
351351
* @param snapshotId The playlist snapshot against which to apply this action. **recommended to have**
352352
*/
353353
fun removeTrackFromPlaylist(
354-
playlist: String,
355-
track: String,
356-
positions: SpotifyTrackPositions,
357-
snapshotId: String? = null
354+
playlist: String,
355+
track: String,
356+
positions: SpotifyTrackPositions,
357+
snapshotId: String? = null
358358
) = removeTracksFromPlaylist(playlist, track to positions, snapshotId = snapshotId)
359359

360360
/**
@@ -368,9 +368,9 @@ class ClientPlaylistAPI(api: SpotifyAPI) : PlaylistAPI(api) {
368368
* @param snapshotId The playlist snapshot against which to apply this action. **recommended to have**
369369
*/
370370
fun removeTrackFromPlaylist(
371-
playlist: String,
372-
track: String,
373-
snapshotId: String? = null
371+
playlist: String,
372+
track: String,
373+
snapshotId: String? = null
374374
) = removeTracksFromPlaylist(playlist, track, snapshotId = snapshotId)
375375

376376
/**
@@ -384,9 +384,9 @@ class ClientPlaylistAPI(api: SpotifyAPI) : PlaylistAPI(api) {
384384
* @param snapshotId The playlist snapshot against which to apply this action. **recommended to have**
385385
*/
386386
fun removeTracksFromPlaylist(
387-
playlist: String,
388-
vararg tracks: String,
389-
snapshotId: String? = null
387+
playlist: String,
388+
vararg tracks: String,
389+
snapshotId: String? = null
390390
) = removePlaylistTracksImpl(playlist, tracks.map { it to null }.toTypedArray(), snapshotId)
391391

392392
/**
@@ -400,15 +400,15 @@ class ClientPlaylistAPI(api: SpotifyAPI) : PlaylistAPI(api) {
400400
* @param snapshotId The playlist snapshot against which to apply this action. **recommended to have**
401401
*/
402402
fun removeTracksFromPlaylist(
403-
playlist: String,
404-
vararg tracks: Pair<String, SpotifyTrackPositions>,
405-
snapshotId: String? = null
403+
playlist: String,
404+
vararg tracks: Pair<String, SpotifyTrackPositions>,
405+
snapshotId: String? = null
406406
) = removePlaylistTracksImpl(playlist, tracks.toList().toTypedArray(), snapshotId)
407407

408408
private fun removePlaylistTracksImpl(
409-
playlist: String,
410-
tracks: Array<Pair<String, SpotifyTrackPositions?>>,
411-
snapshotId: String?
409+
playlist: String,
410+
tracks: Array<Pair<String, SpotifyTrackPositions?>>,
411+
snapshotId: String?
412412
): SpotifyRestAction<Snapshot> {
413413
return toAction(Supplier {
414414
if (tracks.isEmpty()) throw IllegalArgumentException("You need to provide at least one track to remove")

0 commit comments

Comments
 (0)