tv seasons endpoint
This commit is contained in:
@@ -14,3 +14,4 @@ export * from './trending';
|
||||
export * from './find';
|
||||
export * from './keywords';
|
||||
export * from './collections';
|
||||
export * from './tv-seasons';
|
||||
|
||||
97
src/endpoints/tv-seasons.ts
Normal file
97
src/endpoints/tv-seasons.ts
Normal file
@@ -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<SeasonDetails>(
|
||||
`${BASE_SEASON(seasonSelection)}`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async aggregateCredits(
|
||||
seasonSelection: SeasonSelection,
|
||||
options: LanguageOption
|
||||
) {
|
||||
return await this.api.get<Credits>(
|
||||
`${BASE_SEASON(seasonSelection)}/aggregate_credits`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async changes(seasonId: number, options: ChangeOptions) {
|
||||
return await this.api.get<Changes>(
|
||||
`tv/season/${seasonId}/changes`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async credits(
|
||||
seasonSelection: SeasonSelection,
|
||||
options: LanguageOption
|
||||
) {
|
||||
return await this.api.get<Credits>(
|
||||
`${BASE_SEASON(seasonSelection)}/credits`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async externalIds(
|
||||
seasonSelection: SeasonSelection,
|
||||
options: LanguageOption
|
||||
) {
|
||||
return await this.api.get<ExternalIds>(
|
||||
`${BASE_SEASON(seasonSelection)}/external_ids`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async images(
|
||||
seasonSelection: SeasonSelection,
|
||||
options: LanguageOption
|
||||
) {
|
||||
return await this.api.get<Images>(
|
||||
`${BASE_SEASON(seasonSelection)}/images`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async videos(
|
||||
seasonSelection: SeasonSelection,
|
||||
options: LanguageOption
|
||||
) {
|
||||
return await this.api.get<Videos>(
|
||||
`${BASE_SEASON(seasonSelection)}/videos`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async translations(
|
||||
seasonSelection: SeasonSelection,
|
||||
options: LanguageOption
|
||||
) {
|
||||
return await this.api.get<Translations>(
|
||||
`${BASE_SEASON(seasonSelection)}/translations`,
|
||||
options
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
16
src/types/tv-seasons.ts
Normal file
16
src/types/tv-seasons.ts
Normal file
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user