diff --git a/src/endpoints/index.ts b/src/endpoints/index.ts index 6c2fa6a..6345ae4 100644 --- a/src/endpoints/index.ts +++ b/src/endpoints/index.ts @@ -14,3 +14,4 @@ export * from './trending'; export * from './find'; export * from './keywords'; export * from './collections'; +export * from './tv-seasons'; diff --git a/src/endpoints/tv-seasons.ts b/src/endpoints/tv-seasons.ts new file mode 100644 index 0000000..045ed0a --- /dev/null +++ b/src/endpoints/tv-seasons.ts @@ -0,0 +1,97 @@ +import { + ChangeOptions, + Changes, + Credits, + ExternalIds, + Images, + LanguageOption, + SeasonDetails, + SeasonSelection, + Translations, + Videos, +} from '..'; +import { BaseEndpoint } from './base'; + +const BASE_SEASON = (seasonSelection: SeasonSelection): string => { + return `/tv/${seasonSelection.tvShowID}/season/${seasonSelection.seasonNumber}`; +}; + +export class TvSeasonsEndpoint extends BaseEndpoint { + constructor(accessToken: string) { + super(accessToken); + } + + async details(seasonSelection: SeasonSelection, options: LanguageOption) { + return await this.api.get( + `${BASE_SEASON(seasonSelection)}`, + options + ); + } + + async aggregateCredits( + seasonSelection: SeasonSelection, + options: LanguageOption + ) { + return await this.api.get( + `${BASE_SEASON(seasonSelection)}/aggregate_credits`, + options + ); + } + + async changes(seasonId: number, options: ChangeOptions) { + return await this.api.get( + `tv/season/${seasonId}/changes`, + options + ); + } + + async credits( + seasonSelection: SeasonSelection, + options: LanguageOption + ) { + return await this.api.get( + `${BASE_SEASON(seasonSelection)}/credits`, + options + ); + } + + async externalIds( + seasonSelection: SeasonSelection, + options: LanguageOption + ) { + return await this.api.get( + `${BASE_SEASON(seasonSelection)}/external_ids`, + options + ); + } + + async images( + seasonSelection: SeasonSelection, + options: LanguageOption + ) { + return await this.api.get( + `${BASE_SEASON(seasonSelection)}/images`, + options + ); + } + + async videos( + seasonSelection: SeasonSelection, + options: LanguageOption + ) { + return await this.api.get( + `${BASE_SEASON(seasonSelection)}/videos`, + options + ); + } + + async translations( + seasonSelection: SeasonSelection, + options: LanguageOption + ) { + return await this.api.get( + `${BASE_SEASON(seasonSelection)}/translations`, + options + ); + } +} diff --git a/src/tmdb.ts b/src/tmdb.ts index b0a5416..22107a1 100644 --- a/src/tmdb.ts +++ b/src/tmdb.ts @@ -15,6 +15,7 @@ import { FindEndpoint, KeywordsEndpoint, CollectionsEndpoint, + TvSeasonsEndpoint, } from './endpoints'; export class TMDB { @@ -87,4 +88,8 @@ export class TMDB { get collections(): CollectionsEndpoint { return new CollectionsEndpoint(this.accessToken); } + + get tvSeasons() : TvSeasonsEndpoint { + return new TvSeasonsEndpoint(this.accessToken); + } } diff --git a/src/types/index.ts b/src/types/index.ts index a6f0c0b..4339a00 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -14,6 +14,7 @@ export * from './trending'; export * from './find'; export * from './keywords'; export * from './collections'; +export * from './tv-seasons'; export type MediaType = 'movie' | 'tv' | 'person'; diff --git a/src/types/tv-seasons.ts b/src/types/tv-seasons.ts new file mode 100644 index 0000000..fbdb497 --- /dev/null +++ b/src/types/tv-seasons.ts @@ -0,0 +1,16 @@ +import { Episode } from "."; + +export interface SeasonSelection { + tvShowID: number; + seasonNumber: number; +} + +export interface SeasonDetails { + air_date: string; + episodes: Episode[]; + name: string; + overview: string; + id: number; + poster_path: string | null; + season_number: number; +} diff --git a/src/types/tv-shows.ts b/src/types/tv-shows.ts index a38f533..64cea2d 100644 --- a/src/types/tv-shows.ts +++ b/src/types/tv-shows.ts @@ -124,16 +124,6 @@ export interface Episode { runtime: number; } -export interface SeasonDetails { - air_date: string; - episodes: Episode[]; - name: string; - overview: string; - id: number; - poster_path: string | null; - season_number: number; -} - export interface Network { id: number; logo_path: string;