22 lines
868 B
Kotlin
22 lines
868 B
Kotlin
package dev.fyloz.musicplayer.modules.spotify
|
|
|
|
import dev.fyloz.musicplayer.core.http.HttpProvider
|
|
import dev.fyloz.musicplayer.modules.spotify.api.SearchResponse
|
|
import dev.fyloz.musicplayer.modules.spotify.api.Track
|
|
|
|
class SpotifyApiProvider : HttpProvider("https://api.spotify.com/v1") {
|
|
suspend fun search(query: String, type: String, accessToken: String): Collection<Track> =
|
|
get<SearchResponse>("search", accessToken) {
|
|
url {
|
|
parameters.append("q", query)
|
|
parameters.append("type", type)
|
|
parameters.append("include_external", "audio")
|
|
parameters.append("limit", "50")
|
|
parameters.append("offset", "0")
|
|
}
|
|
}.tracks.items
|
|
|
|
suspend fun getSongById(songId: String, accessToken: String): Track =
|
|
get("tracks/$songId", accessToken)
|
|
}
|