import { BaseEndpoint } from './base'; import { AlternativeTitles, AppendToResponse, AppendToResponseTvKey, ChangeOption, Changes, ContentRatings, Credits, EpisodeGroups, ExternalIds, Images, Keywords, LanguageOption, LatestTvShows, OnTheAir, PageOption, PopularTvShows, Recommendations, RegionOption, Reviews, ScreenedTheatrically, SeasonDetails, SimilarTvShows, TopRatedTvShows, Translations, TvShowChangeValue, TvShowDetails, TvShowsAiringToday, Videos, WatchProviders, } from '../types'; const BASE_TV = '/tv'; export class TvShowsEndpoint extends BaseEndpoint { constructor(protected readonly accessToken: string) { super(accessToken); } async details( id: number, appendToResponse?: T ) { const options = { append_to_response: appendToResponse ? appendToResponse.join(',') : undefined, }; return await this.api.get>( `${BASE_TV}/${id}`, options ); } async alternativeTitles(id: number): Promise { return await this.api.get( `${BASE_TV}/${id}/alternative_titles` ); } async changes(id: number, options?: ChangeOption): Promise> { return await this.api.get>(`${BASE_TV}/${id}/changes`, options); } async contentRatings(id: number): Promise { return await this.api.get( `${BASE_TV}/${id}/content_ratings` ); } async credits(id: number): Promise { return await this.api.get(`${BASE_TV}/${id}/credits`); } async season(tvId: number, seasonNumber: number): Promise { return await this.api.get( `${BASE_TV}/${tvId}/season/${seasonNumber}` ); } async episodeGroups(id: number): Promise { return await this.api.get(`${BASE_TV}/${id}/episode_groups`); } async externalIds(id: number): Promise { return await this.api.get(`${BASE_TV}/${id}/external_ids`); } async images(id: number): Promise { return await this.api.get(`${BASE_TV}/${id}/images`); } async keywords(id: number): Promise { return await this.api.get(`${BASE_TV}/${id}/keywords`); } async recommendations( id: number, options?: PageOption ): Promise { return await this.api.get( `${BASE_TV}/${id}/recommendations`, options ); } async reviews(id: number, options?: PageOption): Promise { return await this.api.get(`${BASE_TV}/${id}/reviews`, options); } async screenedTheatrically(id: number): Promise { return await this.api.get( `${BASE_TV}/${id}/screened_theatrically` ); } async similar(id: number, options?: PageOption): Promise { return await this.api.get( `${BASE_TV}/${id}/similar`, options ); } async translations(id: number): Promise { return await this.api.get(`${BASE_TV}/${id}/translations`); } async videos(id: number): Promise { return await this.api.get(`${BASE_TV}/${id}/videos`); } /** * Powered by JustWatch * @param id */ async watchProviders(id: number): Promise { return await this.api.get( `${BASE_TV}/${id}/watch/providers` ); } async latest(): Promise { return await this.api.get(`${BASE_TV}/latest`); } async onTheAir(): Promise { return await this.api.get(`${BASE_TV}/on_the_air`); } async airingToday( options?: PageOption & LanguageOption & RegionOption ): Promise { return await this.api.get( `${BASE_TV}/airing_today`, options ); } async popular( options?: PageOption & LanguageOption & RegionOption ): Promise { return await this.api.get(`${BASE_TV}/popular`, options); } async topRated( options?: PageOption & LanguageOption & RegionOption ): Promise { return await this.api.get(`${BASE_TV}/top_rated`, options); } }