added all people endpoints
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
import { PersonDetail, PersonMovieCredit, PersonTvShowCredit } from '../types';
|
import { ChangeOptions, ExternalIds, Image, PeopleTranslations, PersonChanges, PersonCombinedCredits, PersonDetail, PersonMovieCredit, PersonTvShowCredit, PopularPersons, TaggedImages } from '../types';
|
||||||
import { BaseEndpoint } from './base';
|
import { BaseEndpoint } from './base';
|
||||||
|
import querystring from 'querystring';
|
||||||
|
|
||||||
const BASE_PERSON = '/person';
|
const BASE_PERSON = '/person';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export class PeopleEndpoint extends BaseEndpoint {
|
export class PeopleEndpoint extends BaseEndpoint {
|
||||||
constructor(accessToken: string) {
|
constructor(accessToken: string) {
|
||||||
super(accessToken);
|
super(accessToken);
|
||||||
@@ -14,19 +14,46 @@ export class PeopleEndpoint extends BaseEndpoint {
|
|||||||
return await this.api.get<PersonDetail>(`${BASE_PERSON}/${id}`);
|
return await this.api.get<PersonDetail>(`${BASE_PERSON}/${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async movieCredits(
|
async changes(id: number, options? : ChangeOptions): Promise<PersonChanges> {
|
||||||
id: number
|
const params = querystring.encode(options);
|
||||||
): Promise<PersonMovieCredit> {
|
return await this.api.get<PersonChanges>(`${BASE_PERSON}/${id}/changes?${params}`);
|
||||||
return await this.api.get<PersonMovieCredit>(
|
|
||||||
`${BASE_PERSON}/${id}/movie_credits`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async tvShowCredits(
|
async movieCredits(id: number): Promise<PersonMovieCredit> {
|
||||||
id: number
|
return await this.api.get<PersonMovieCredit>(`${BASE_PERSON}/${id}/movie_credits`);
|
||||||
): Promise<PersonTvShowCredit> {
|
}
|
||||||
return await this.api.get<PersonTvShowCredit>(
|
|
||||||
`${BASE_PERSON}/${id}/tv_credits`
|
async tvShowCredits(id: number): Promise<PersonTvShowCredit> {
|
||||||
);
|
return await this.api.get<PersonTvShowCredit>(`${BASE_PERSON}/${id}/tv_credits`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async combinedCredits(id: number) : Promise<PersonCombinedCredits> {
|
||||||
|
return await this.api.get<PersonCombinedCredits>(`${BASE_PERSON}/${id}/combined_credits`)
|
||||||
|
}
|
||||||
|
|
||||||
|
async externalId(id: number): Promise<ExternalIds>{
|
||||||
|
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 taggedImages(id: number, options?: {page?: number}): Promise<TaggedImages>{
|
||||||
|
const params = querystring.encode(options);
|
||||||
|
return await this.api.get<TaggedImages>(`${BASE_PERSON}/${id}/tagged_images?${params}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async translation(id: number) : Promise<PeopleTranslations>{
|
||||||
|
return await this.api.get<PeopleTranslations>(`${BASE_PERSON}/${id}/translations`)
|
||||||
|
}
|
||||||
|
|
||||||
|
async latest(): Promise<PersonDetail>{
|
||||||
|
return await this.api.get<PersonDetail>(`${BASE_PERSON}/latest`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async popular(options?: {page?: number}): Promise<PopularPersons>{
|
||||||
|
const params = querystring.encode(options);
|
||||||
|
return await this.api.get<PopularPersons>(`${BASE_PERSON}/popular?${params}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -197,3 +197,13 @@ export interface Translations {
|
|||||||
id: number;
|
id: number;
|
||||||
translations: Translation[];
|
translations: Translation[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface Image{
|
||||||
|
aspect_ratio: number;
|
||||||
|
file_path: string;
|
||||||
|
height: number;
|
||||||
|
iso_639_1: string;
|
||||||
|
vote_average: number;
|
||||||
|
vote_count: number;
|
||||||
|
width: number;
|
||||||
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Movie, Person, TV, TvShowItem } from ".";
|
||||||
|
|
||||||
interface Cast {
|
interface Cast {
|
||||||
character: string;
|
character: string;
|
||||||
credit_id: string;
|
credit_id: string;
|
||||||
@@ -71,6 +73,12 @@ export interface PersonTvShowCredit {
|
|||||||
id: number;
|
id: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface PersonCombinedCredits {
|
||||||
|
cast: (PersonMovieCast & PersonTvShowCast)[];
|
||||||
|
crew: (PersonMovieCrew & PersonTvShowCrew)[];
|
||||||
|
id: number;
|
||||||
|
}
|
||||||
|
|
||||||
export interface PersonDetail {
|
export interface PersonDetail {
|
||||||
birthday: string,
|
birthday: string,
|
||||||
known_for_department: string,
|
known_for_department: string,
|
||||||
@@ -86,4 +94,62 @@ export interface PersonDetail {
|
|||||||
adult: boolean,
|
adult: boolean,
|
||||||
imdb_id: string,
|
imdb_id: string,
|
||||||
homepage: string
|
homepage: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PersonChange{
|
||||||
|
id: string;
|
||||||
|
action: string;
|
||||||
|
time: string;
|
||||||
|
iso_639_1: string;
|
||||||
|
iso_3166_1: string;
|
||||||
|
value: string | { profile: { file_path: string;} };
|
||||||
|
original_value: string | { profile: { file_path: string; } };
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PersonChanges {
|
||||||
|
changes: {
|
||||||
|
key: string;
|
||||||
|
items: PersonChange[];
|
||||||
|
}[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PopularPersons{
|
||||||
|
page: number;
|
||||||
|
results: Person[];
|
||||||
|
total_results: number;
|
||||||
|
total_pages: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TaggedImage{
|
||||||
|
aspect_ratio: number;
|
||||||
|
file_path: string;
|
||||||
|
height: number;
|
||||||
|
id: string;
|
||||||
|
iso_639_1: string;
|
||||||
|
vote_average: number;
|
||||||
|
vote_count: number;
|
||||||
|
width: number;
|
||||||
|
image_type: string;
|
||||||
|
media_type: string;
|
||||||
|
media: Movie | TV
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TaggedImages{
|
||||||
|
page: number;
|
||||||
|
results: TaggedImage[];
|
||||||
|
total_results: number;
|
||||||
|
total_pages: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PeopleTranslations{
|
||||||
|
id: number;
|
||||||
|
translations: {
|
||||||
|
iso_3166_1: string;
|
||||||
|
iso_639_1: string;
|
||||||
|
name: string;
|
||||||
|
english_name: string;
|
||||||
|
data: {
|
||||||
|
biography: string
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user