Skip to content

Commit f53fd62

Browse files
committed
code cleanup
1 parent ade1483 commit f53fd62

17 files changed

+47
-47
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
3131
import java.util.concurrent.Executors
3232
import java.util.concurrent.ScheduledExecutorService
3333

34-
internal val base = "https://api.spotify.com/v1"
34+
internal const val base = "https://api.spotify.com/v1"
3535

3636
/**
3737
* Represents an instance of the Spotify API client, with common

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
7777
get(
7878
EndpointBuilder("/me/following/contains").with("type", "user")
7979
.with("ids", users.joinToString(",") { UserURI(it).id.encode() }).toString()
80-
).toArray<Boolean>(api)
80+
).toArray(api)
8181
})
8282
}
8383

@@ -112,7 +112,7 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
112112
get(
113113
EndpointBuilder("/me/following/contains").with("type", "artist")
114114
.with("ids", artists.joinToString(",") { ArtistURI(it).id.encode() }).toString()
115-
).toArray<Boolean>(api)
115+
).toArray(api)
116116
})
117117
}
118118

@@ -137,7 +137,7 @@ class ClientFollowingAPI(api: SpotifyAPI) : FollowingAPI(api) {
137137
"after",
138138
after
139139
).toString()
140-
).toCursorBasedPagingObject<Artist>("artists", this)
140+
).toCursorBasedPagingObject("artists", this)
141141
})
142142
}
143143

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class ClientLibraryAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
4343
get(
4444
EndpointBuilder("/me/tracks").with("limit", limit).with("offset", offset).with("market", market?.name)
4545
.toString()
46-
).toPagingObject<SavedTrack>(endpoint = this)
46+
).toPagingObject(endpoint = this)
4747
})
4848
}
4949

@@ -68,7 +68,7 @@ class ClientLibraryAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
6868
get(
6969
EndpointBuilder("/me/albums").with("limit", limit).with("offset", offset).with("market", market?.name)
7070
.toString()
71-
).toPagingObject<SavedAlbum>(endpoint = this)
71+
).toPagingObject(endpoint = this)
7272
})
7373
}
7474

@@ -103,7 +103,7 @@ class ClientLibraryAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
103103
get(
104104
EndpointBuilder("/me/$type/contains").with("ids", ids.joinToString(",") { type.id(it).encode() })
105105
.toString()
106-
).toArray<Boolean>(api)
106+
).toArray(api)
107107
})
108108
}
109109

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class ClientPersonalizationAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
5858
EndpointBuilder("/me/top/artists").with("limit", limit).with("offset", offset)
5959
.with("time_range", timeRange).toString()
6060
)
61-
.toPagingObject<Artist>(endpoint = this)
61+
.toPagingObject(endpoint = this)
6262
})
6363
}
6464

@@ -91,7 +91,7 @@ class ClientPersonalizationAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
9191
EndpointBuilder("/me/top/tracks").with("limit", limit).with("offset", offset)
9292
.with("time_range", timeRange).toString()
9393
)
94-
.toPagingObject<Track>(endpoint = this)
94+
.toPagingObject(endpoint = this)
9595
})
9696
}
9797
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class ClientPlayerAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
3838
*/
3939
fun getDevices(): SpotifyRestAction<List<Device>> {
4040
return toAction(Supplier {
41-
get(EndpointBuilder("/me/player/devices").toString()).toInnerObject<List<Device>>(
41+
get(EndpointBuilder("/me/player/devices").toString()).toInnerObject(
4242
"devices"
4343
)
4444
})
@@ -78,7 +78,7 @@ class ClientPlayerAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
7878
get(
7979
EndpointBuilder("/me/player/recently-played")
8080
.with("limit", limit).with("before", before).with("after", after).toString()
81-
).toCursorBasedPagingObject<PlayHistory>(
81+
).toCursorBasedPagingObject(
8282
endpoint = this
8383
)
8484
})

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class ClientPlaylistAPI(api: SpotifyAPI) : PlaylistAPI(api) {
7070
post(
7171
EndpointBuilder("/users/${UserURI(user).id.encode()}/playlists").toString(),
7272
json.toJson()
73-
).toObject<Playlist>(api)
73+
).toObject(api)
7474
})
7575
}
7676

@@ -173,7 +173,7 @@ class ClientPlaylistAPI(api: SpotifyAPI) : PlaylistAPI(api) {
173173
if (offset != null && offset !in 0..100000) throw IllegalArgumentException("Offset must be between 0 and 100,000. Provided $limit")
174174
return toActionPaging(Supplier {
175175
get(EndpointBuilder("/me/playlists").with("limit", limit).with("offset", offset).toString())
176-
.toPagingObject<SimplePlaylist>(endpoint = this)
176+
.toPagingObject(endpoint = this)
177177
})
178178
}
179179

@@ -244,7 +244,7 @@ class ClientPlaylistAPI(api: SpotifyAPI) : PlaylistAPI(api) {
244244
put(
245245
EndpointBuilder("/playlists/${PlaylistURI(playlist).id.encode()}/tracks").toString(),
246246
json.toJson()
247-
).toObject<Snapshot>(api)
247+
).toObject(api)
248248
})
249249
}
250250

@@ -423,7 +423,7 @@ class ClientPlaylistAPI(api: SpotifyAPI) : PlaylistAPI(api) {
423423
}.let { json.put("tracks", it) }
424424
delete(
425425
EndpointBuilder("/playlists/${PlaylistURI(playlist).id}/tracks").toString(), body = json.toJson()
426-
).toObject<Snapshot>(api)
426+
).toObject(api)
427427
})
428428
}
429429

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ClientUserAPI(api: SpotifyAPI) : UserAPI(api) {
2626
*/
2727
fun getUserProfile(): SpotifyRestAction<SpotifyUserInformation> {
2828
return toAction(Supplier {
29-
get(EndpointBuilder("/me").toString()).toObject<SpotifyUserInformation>(api)
29+
get(EndpointBuilder("/me").toString()).toObject(api)
3030
})
3131
}
3232
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class AlbumAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
3535
return toAction(Supplier {
3636
catch {
3737
get(EndpointBuilder("/albums/${AlbumURI(album).id}").with("market", market?.name).toString())
38-
.toObject<Album>(api)
38+
.toObject(api)
3939
}
4040
})
4141
}
@@ -82,7 +82,7 @@ class AlbumAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
8282
offset
8383
).with("market", market?.name)
8484
.toString()
85-
).toPagingObject<SimpleTrack>(endpoint = this)
85+
).toPagingObject(endpoint = this)
8686
})
8787
}
8888
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ArtistsAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
3737
return toAction(Supplier {
3838
catch {
3939
get(EndpointBuilder("/artists/${ArtistURI(artist).id.encode()}").toString())
40-
.toObject<Artist>(api)
40+
.toObject(api)
4141
}
4242
})
4343
}
@@ -85,7 +85,7 @@ class ArtistsAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
8585
offset
8686
).with("market", market?.name)
8787
.with("include_groups", include.joinToString(",") { it.keyword }).toString()
88-
).toPagingObject<SimpleAlbum>(null, this)
88+
).toPagingObject(null, this)
8989
})
9090
}
9191

@@ -120,7 +120,7 @@ class ArtistsAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
120120
"country",
121121
market.name
122122
).toString()
123-
).toInnerArray<Track>("tracks")
123+
).toInnerArray("tracks")
124124
})
125125
}
126126

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class BrowseAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
3939
*/
4040
fun getAvailableGenreSeeds(): SpotifyRestAction<List<String>> {
4141
return toAction(Supplier {
42-
get(EndpointBuilder("/recommendations/available-genre-seeds").toString()).toInnerArray<String>(
42+
get(EndpointBuilder("/recommendations/available-genre-seeds").toString()).toInnerArray(
4343
"genres"
4444
)
4545
})
@@ -67,7 +67,7 @@ class BrowseAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
6767
"country",
6868
market?.name
6969
).toString()
70-
).toPagingObject<SimpleAlbum>(
70+
).toPagingObject(
7171
"albums", endpoint = this
7272
)
7373
})
@@ -107,7 +107,7 @@ class BrowseAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
107107
.with("locale", locale).with("timestamp", timestamp?.let {
108108
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(Date.from(Instant.ofEpochMilli(timestamp)))
109109
}).toString()
110-
).toObject<FeaturedPlaylists>(api)
110+
).toObject(api)
111111
})
112112
}
113113

@@ -138,7 +138,7 @@ class BrowseAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
138138
"market",
139139
market?.name
140140
).with("locale", locale).toString()
141-
).toPagingObject<SpotifyCategory>(
141+
).toPagingObject(
142142
"categories", endpoint = this
143143
)
144144
})
@@ -166,7 +166,7 @@ class BrowseAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
166166
get(
167167
EndpointBuilder("/browse/categories/${categoryId.encode()}").with("market", market?.name)
168168
.with("locale", locale).toString()
169-
).toObject<SpotifyCategory>(api)
169+
).toObject(api)
170170
})
171171
}
172172

@@ -194,7 +194,7 @@ class BrowseAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
194194
limit
195195
).with("offset", offset)
196196
.with("market", market?.name).toString()
197-
).toPagingObject<SimplePlaylist>("playlists", endpoint = this)
197+
).toPagingObject("playlists", endpoint = this)
198198
})
199199
}
200200

@@ -301,10 +301,10 @@ class BrowseAPI(api: SpotifyAPI) : SpotifyEndpoint(api) {
301301
.with("seed_artists", seedArtists?.joinToString(",") { ArtistURI(it).id.encode() })
302302
.with("seed_genres", seedGenres?.joinToString(",") { it.encode() })
303303
.with("seed_tracks", seedTracks?.joinToString(",") { TrackURI(it).id.encode() })
304-
targetAttributes.forEach { attribute, value -> builder.with("target_$attribute", value) }
305-
minAttributes.forEach { attribute, value -> builder.with("min_$attribute", value) }
306-
maxAttributes.forEach { attribute, value -> builder.with("max_$attribute", value) }
307-
get(builder.toString()).toObject<RecommendationResponse>(api)
304+
targetAttributes.forEach { (attribute, value) -> builder.with("target_$attribute", value) }
305+
minAttributes.forEach { (attribute, value) -> builder.with("min_$attribute", value) }
306+
maxAttributes.forEach { (attribute, value) -> builder.with("max_$attribute", value) }
307+
get(builder.toString()).toObject(api)
308308
})
309309
}
310310
}

0 commit comments

Comments
 (0)