Skip to content

Commit f005428

Browse files
committed
standardize enums, mimic get values for tuneabletrackattributes
1 parent 22d3cf4 commit f005428

File tree

13 files changed

+54
-20
lines changed

13 files changed

+54
-20
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ repositories {
2929
jcenter()
3030
}
3131
32-
compile group: 'com.adamratzman', name: 'spotify-api-kotlin', version: '2.3.04'
32+
compile group: 'com.adamratzman', name: 'spotify-api-kotlin', version: '2.3.05'
3333
```
3434

3535
To use the latest snapshot instead, you must add the Jitpack repository as well
@@ -51,7 +51,7 @@ dependencies {
5151
<dependency>
5252
<groupId>com.adamratzman</groupId>
5353
<artifactId>spotify-api-kotlin</artifactId>
54-
<version>2.3.04</version>
54+
<version>2.3.05</version>
5555
</dependency>
5656
5757
<repository>

build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ buildscript {
1111
}
1212
}
1313

14-
1514
plugins {
1615
id "com.diffplug.gradle.spotless" version "3.24.0"
1716
id "base"
@@ -23,7 +22,7 @@ apply plugin: 'kotlin'
2322
apply plugin: 'org.jetbrains.dokka'
2423

2524
group 'com.adamratzman'
26-
version '2.3.04'
25+
version '2.3.05'
2726

2827
archivesBaseName = 'spotify-api-kotlin'
2928

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,5 +496,6 @@ class SpotifyApiBuilderDsl {
496496
}
497497

498498
enum class AuthorizationType {
499-
CLIENT, APPLICATION
499+
CLIENT,
500+
APPLICATION;
500501
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ class ClientLibraryAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
185185
* @param id How to transform an id (or uri) input into its Spotify id
186186
*/
187187
enum class LibraryType(private val value: String, internal val id: (String) -> String) {
188-
TRACK("tracks", { TrackURI(it).id }), ALBUM("albums", { AlbumURI(it).id });
188+
TRACK("tracks", { TrackURI(it).id }),
189+
ALBUM("albums", { AlbumURI(it).id });
189190

190191
override fun toString() = value
191192
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ class ClientPersonalizationAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
2222
* @param id the Spotify id of the time frame
2323
*/
2424
enum class TimeRange(val id: String) {
25-
LONG_TERM("long_term"), MEDIUM_TERM("medium_term"), SHORT_TERM("short_term");
25+
LONG_TERM("long_term"),
26+
MEDIUM_TERM("medium_term"),
27+
SHORT_TERM("short_term");
2628

2729
override fun toString() = id
2830
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,6 @@ class ClientPlayerAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
317317
/**
318318
* Will turn repeat off
319319
*/
320-
OFF
320+
OFF;
321321
}
322322
}

src/main/kotlin/com/adamratzman/spotify/endpoints/public/ArtistsAPI.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ class ArtistsAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
9595
* @param keyword The spotify id of the strategy
9696
*/
9797
enum class AlbumInclusionStrategy(val keyword: String) {
98-
ALBUM("album"), SINGLE("single"), APPEARS_ON("appears_on"), COMPILATION("compilation")
98+
ALBUM("album"),
99+
SINGLE("single"),
100+
APPEARS_ON("appears_on"),
101+
COMPILATION("compilation");
99102
}
100103

101104
/**

src/main/kotlin/com/adamratzman/spotify/endpoints/public/BrowseAPI.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,25 @@ sealed class TuneableTrackAttribute<T : Number>(val attribute: String, val integ
423423

424424
return TrackAttribute(this, value)
425425
}
426+
427+
companion object {
428+
fun values() = listOf(
429+
ACOUSTICNESS,
430+
DANCEABILITY,
431+
DURATION_IN_MILLISECONDS,
432+
ENERGY,
433+
INSTRUMENTALNESS,
434+
KEY,
435+
LIVENESS,
436+
LOUDNESS,
437+
MODE,
438+
POPULARITY,
439+
SPEECHINESS,
440+
TEMPO,
441+
TIME_SIGNATURE,
442+
VALENCE
443+
)
444+
}
426445
}
427446

428447
data class TrackAttribute<T : Number>(val tuneableTrackAttribute: TuneableTrackAttribute<T>, val value: T) {

src/main/kotlin/com/adamratzman/spotify/endpoints/public/SearchAPI.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ class SearchAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
2828
* @param id The internal spotify id
2929
*/
3030
enum class SearchType(internal val id: String) {
31-
ALBUM("album"), TRACK("track"), ARTIST("artist"), PLAYLIST("playlist")
31+
ALBUM("album"),
32+
TRACK("track"),
33+
ARTIST("artist"),
34+
PLAYLIST("playlist");
3235
}
3336

3437
/**

src/main/kotlin/com/adamratzman/spotify/http/HttpConnection.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ import com.google.api.client.http.GenericUrl
88
import com.google.api.client.http.javanet.NetHttpTransport
99
import java.util.concurrent.TimeUnit
1010

11-
enum class HttpRequestMethod { GET, POST, PUT, DELETE }
11+
enum class HttpRequestMethod {
12+
GET,
13+
POST,
14+
PUT,
15+
DELETE;
16+
}
17+
1218
data class HttpHeader(val key: String, val value: String)
1319

1420
internal class HttpConnection(

0 commit comments

Comments
 (0)