commonMain.app.moviebase.tmdb.api.TmdbPeopleApi.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tmdb-api-jvm Show documentation
Show all versions of tmdb-api-jvm Show documentation
Kotlin Multiplatform library to access the TMDB API.
The newest version!
package app.moviebase.tmdb.api
import app.moviebase.tmdb.model.AppendResponse
import app.moviebase.tmdb.model.TmdbPersonDetail
import app.moviebase.tmdb.model.TmdbPersonMovieCredits
import app.moviebase.tmdb.model.TmdbPersonShowCredits
import app.moviebase.tmdb.core.endPointV3
import app.moviebase.tmdb.core.parameterAppendResponses
import app.moviebase.tmdb.core.parameterLanguage
import io.ktor.client.*
import io.ktor.client.call.*
import io.ktor.client.request.*
class TmdbPeopleApi internal constructor(private val client: HttpClient) {
suspend fun getDetails(
personId: Int,
language: String? = null,
appendResponses: Iterable? = null
): TmdbPersonDetail = client.get {
endPointPerson(personId)
parameterLanguage(language)
parameterAppendResponses(appendResponses)
}.body()
suspend fun getShowCredits(
personId: Int,
language: String? = null
): TmdbPersonShowCredits = client.get {
endPointPerson(personId, "tv_credits")
parameterLanguage(language)
}.body()
suspend fun getMovieCredits(
personId: Int,
language: String? = null
): TmdbPersonMovieCredits = client.get {
endPointPerson(personId, "movie_credits")
parameterLanguage(language)
}.body()
private fun HttpRequestBuilder.endPointPerson(personId: Int, vararg paths: String) {
endPointV3("person", personId.toString(), *paths)
}
}