import { BaseEndpoint } from './base'; import { AlternativeTitles, ChangeOptions, ContentRatings, Credits, EpisodeGroups, ExternalIds, Images, Keywords, LatestTvShows, LocaleOptions, OnTheAir, PageOptions, PopularTvShows, Recommendations, Reviews, ScreenedTheatrically, SeasonDetails, SimilarTvShows, TopRatedTvShows, Translations, TvShowChanges, 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): Promise{ return await this.api.get(`${BASE_TV}/${id}`); } async alternativeTitles(id: number): Promise{ return await this.api.get(`${BASE_TV}/${id}/alternative_titles`); } async changes(id: number, options?: ChangeOptions): Promise{ const params = options == undefined ? undefined : new URLSearchParams(Object.entries(options)).toString(); return await this.api.get(`${BASE_TV}/${id}/changes?${params}`); } 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?: PageOptions): Promise{ const params = options == undefined ? undefined : new URLSearchParams(Object.entries(options)).toString(); return await this.api.get(`${BASE_TV}/${id}/recommendations?${params}`); } async reviews(id: number, options?: PageOptions): Promise{ const params = options == undefined ? undefined : new URLSearchParams(Object.entries(options)).toString(); return await this.api.get(`${BASE_TV}/${id}/reviews?${params}`); } async screenedTheatrically(id: number): Promise{ return await this.api.get(`${BASE_TV}/${id}/screened_theatrically`); } async similar(id: number, options?: PageOptions): Promise{ const params = options == undefined ? undefined : new URLSearchParams(Object.entries(options)).toString(); return await this.api.get(`${BASE_TV}/${id}/similar?${params}`); } 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?: LocaleOptions): Promise{ const params = options == undefined ? undefined : new URLSearchParams(Object.entries(options)).toString(); return await this.api.get(`${BASE_TV}/airing_today?${params}`); } async popular(options?: PageOptions): Promise{ const params = options == undefined ? undefined : new URLSearchParams(Object.entries(options)).toString(); return await this.api.get(`${BASE_TV}/popular?${params}`); } async topRated(options?: LocaleOptions): Promise{ const params = options == undefined ? undefined : new URLSearchParams(Object.entries(options)).toString(); return await this.api.get(`${BASE_TV}/top_rated?${params}`); } }