Merge branch 'master' of github.com:blakejoy/tmdb-ts into feature/multi-search
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
import { BaseEndpoint } from './base';
|
||||
import { ChangeOptions, Changes } from '../types/changes';
|
||||
import { ChangeOptions, MediaChanges } from '../types/changes';
|
||||
|
||||
export class ChangeEndpoint extends BaseEndpoint {
|
||||
constructor(protected readonly accessToken: string) {
|
||||
super(accessToken);
|
||||
}
|
||||
|
||||
async movies(options?: ChangeOptions): Promise<Changes> {
|
||||
return await this.api.get<Changes>(`/movie/changes`, options);
|
||||
async movies(options?: ChangeOptions): Promise<MediaChanges> {
|
||||
return await this.api.get<MediaChanges>(`/movie/changes`, options);
|
||||
}
|
||||
|
||||
async tvShows(options?: ChangeOptions): Promise<Changes> {
|
||||
return await this.api.get<Changes>(`/tv/changes`, options);
|
||||
async tvShows(options?: ChangeOptions): Promise<MediaChanges> {
|
||||
return await this.api.get<MediaChanges>(`/tv/changes`, options);
|
||||
}
|
||||
|
||||
async person(options?: ChangeOptions): Promise<Changes> {
|
||||
return await this.api.get<Changes>(`/person/change`, options);
|
||||
async person(options?: ChangeOptions): Promise<MediaChanges> {
|
||||
return await this.api.get<MediaChanges>(`/person/change`, options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import { BaseEndpoint } from './base';
|
||||
import {
|
||||
AlternativeTitles,
|
||||
AppendToResponse,
|
||||
AppendToResponseMovieKey,
|
||||
ChangeOptions,
|
||||
Changes,
|
||||
Credits,
|
||||
ExternalIds,
|
||||
Images,
|
||||
Keywords,
|
||||
LanguageOption,
|
||||
LatestMovie,
|
||||
MovieChanges,
|
||||
MovieDetails,
|
||||
MovieLists,
|
||||
MoviesPlayingNow,
|
||||
@@ -33,8 +35,20 @@ export class MoviesEndpoint extends BaseEndpoint {
|
||||
super(accessToken);
|
||||
}
|
||||
|
||||
async details(id: number): Promise<MovieDetails> {
|
||||
return await this.api.get<MovieDetails>(`${BASE_MOVIE}/${id}`);
|
||||
async details<T extends AppendToResponseMovieKey[] | undefined>(
|
||||
id: number,
|
||||
appendToResponse?: T
|
||||
) {
|
||||
const options = {
|
||||
append_to_response: appendToResponse
|
||||
? appendToResponse.join(',')
|
||||
: undefined,
|
||||
};
|
||||
|
||||
return await this.api.get<AppendToResponse<MovieDetails, T, 'movie'>>(
|
||||
`${BASE_MOVIE}/${id}`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async alternativeTitles(id: number): Promise<AlternativeTitles> {
|
||||
@@ -43,11 +57,8 @@ export class MoviesEndpoint extends BaseEndpoint {
|
||||
);
|
||||
}
|
||||
|
||||
async changes(id: number, options?: ChangeOptions): Promise<MovieChanges> {
|
||||
return await this.api.get<MovieChanges>(
|
||||
`${BASE_MOVIE}/${id}/changes`,
|
||||
options
|
||||
);
|
||||
async changes(id: number, options?: ChangeOptions): Promise<Changes> {
|
||||
return await this.api.get<Changes>(`${BASE_MOVIE}/${id}/changes`, options);
|
||||
}
|
||||
|
||||
async credits(id: number): Promise<Credits> {
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import {
|
||||
AppendToResponse,
|
||||
AppendToResponsePersonKey,
|
||||
ChangeOptions,
|
||||
ExternalIds,
|
||||
Image,
|
||||
PageOption,
|
||||
PeopleTranslations,
|
||||
PeopleImages,
|
||||
PersonTranslations,
|
||||
PersonChanges,
|
||||
PersonCombinedCredits,
|
||||
PersonDetail,
|
||||
PersonDetails,
|
||||
PersonMovieCredit,
|
||||
PersonTvShowCredit,
|
||||
PopularPersons,
|
||||
@@ -21,8 +23,19 @@ export class PeopleEndpoint extends BaseEndpoint {
|
||||
super(accessToken);
|
||||
}
|
||||
|
||||
async details(id: number): Promise<PersonDetail> {
|
||||
return await this.api.get<PersonDetail>(`${BASE_PERSON}/${id}`);
|
||||
async details<T extends AppendToResponsePersonKey[] | undefined>(
|
||||
id: number,
|
||||
appendToResponse?: T
|
||||
) {
|
||||
const options = {
|
||||
append_to_response: appendToResponse
|
||||
? appendToResponse.join(',')
|
||||
: undefined,
|
||||
};
|
||||
return await this.api.get<AppendToResponse<PersonDetails, T, 'person'>>(
|
||||
`${BASE_PERSON}/${id}`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async changes(id: number, options?: ChangeOptions): Promise<PersonChanges> {
|
||||
@@ -54,10 +67,8 @@ export class PeopleEndpoint extends BaseEndpoint {
|
||||
return await this.api.get<ExternalIds>(`${BASE_PERSON}/${id}/external_ids`);
|
||||
}
|
||||
|
||||
async images(id: number): Promise<{ id: number; profiles: Image[] }> {
|
||||
return await this.api.get<{ id: number; profiles: Image[] }>(
|
||||
`${BASE_PERSON}/${id}/images`
|
||||
);
|
||||
async images(id: number): Promise<PeopleImages> {
|
||||
return await this.api.get<PeopleImages>(`${BASE_PERSON}/${id}/images`);
|
||||
}
|
||||
|
||||
async taggedImages(id: number, options?: PageOption): Promise<TaggedImages> {
|
||||
@@ -67,14 +78,14 @@ export class PeopleEndpoint extends BaseEndpoint {
|
||||
);
|
||||
}
|
||||
|
||||
async translation(id: number): Promise<PeopleTranslations> {
|
||||
return await this.api.get<PeopleTranslations>(
|
||||
async translation(id: number): Promise<PersonTranslations> {
|
||||
return await this.api.get<PersonTranslations>(
|
||||
`${BASE_PERSON}/${id}/translations`
|
||||
);
|
||||
}
|
||||
|
||||
async latest(): Promise<PersonDetail> {
|
||||
return await this.api.get<PersonDetail>(`${BASE_PERSON}/latest`);
|
||||
async latest(): Promise<PersonDetails> {
|
||||
return await this.api.get<PersonDetails>(`${BASE_PERSON}/latest`);
|
||||
}
|
||||
|
||||
async popular(options?: PageOption): Promise<PopularPersons> {
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import { BaseEndpoint } from './base';
|
||||
import {
|
||||
AlternativeTitles,
|
||||
AppendToResponse,
|
||||
AppendToResponseTvKey,
|
||||
ChangeOptions,
|
||||
Changes,
|
||||
ContentRatings,
|
||||
Credits,
|
||||
EpisodeGroups,
|
||||
@@ -21,7 +24,6 @@ import {
|
||||
SimilarTvShows,
|
||||
TopRatedTvShows,
|
||||
Translations,
|
||||
TvShowChanges,
|
||||
TvShowDetails,
|
||||
TvShowsAiringToday,
|
||||
Videos,
|
||||
@@ -35,8 +37,19 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
||||
super(accessToken);
|
||||
}
|
||||
|
||||
async details(id: number): Promise<TvShowDetails> {
|
||||
return await this.api.get<TvShowDetails>(`${BASE_TV}/${id}`);
|
||||
async details<T extends AppendToResponseTvKey[] | undefined>(
|
||||
id: number,
|
||||
appendToResponse?: T
|
||||
) {
|
||||
const options = {
|
||||
append_to_response: appendToResponse
|
||||
? appendToResponse.join(',')
|
||||
: undefined,
|
||||
};
|
||||
return await this.api.get<AppendToResponse<TvShowDetails, T, 'tvShow'>>(
|
||||
`${BASE_TV}/${id}`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async alternativeTitles(id: number): Promise<AlternativeTitles> {
|
||||
@@ -45,11 +58,8 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
||||
);
|
||||
}
|
||||
|
||||
async changes(id: number, options?: ChangeOptions): Promise<TvShowChanges> {
|
||||
return await this.api.get<TvShowChanges>(
|
||||
`${BASE_TV}/${id}/changes`,
|
||||
options
|
||||
);
|
||||
async changes(id: number, options?: ChangeOptions): Promise<Changes> {
|
||||
return await this.api.get<Changes>(`${BASE_TV}/${id}/changes`, options);
|
||||
}
|
||||
|
||||
async contentRatings(id: number): Promise<ContentRatings> {
|
||||
|
||||
Reference in New Issue
Block a user