added find endpoint and types
This commit is contained in:
14
src/endpoints/find.ts
Normal file
14
src/endpoints/find.ts
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import { BaseEndpoint } from './base';
|
||||||
|
import querystring from 'querystring';
|
||||||
|
import { ExternalIdOptions, FindResult } from '../types';
|
||||||
|
|
||||||
|
export class FindEndpoint extends BaseEndpoint {
|
||||||
|
constructor(accessToken: string) {
|
||||||
|
super(accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
async byId(externalId: string, options: ExternalIdOptions): Promise<FindResult> {
|
||||||
|
const params = querystring.encode(options);
|
||||||
|
return await this.api.get<FindResult>(`/find/${externalId}?${params}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,4 +13,5 @@ export * from './discover';
|
|||||||
export * from './people';
|
export * from './people';
|
||||||
export * from './review';
|
export * from './review';
|
||||||
export * from './trending';
|
export * from './trending';
|
||||||
|
export * from './find';
|
||||||
|
|
||||||
|
|||||||
29
src/types/find.ts
Normal file
29
src/types/find.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import { ParsedUrlQueryInput } from 'querystring';
|
||||||
|
import { Episode, Media, MediaType, Movie, Person, Season, TV } from '.';
|
||||||
|
|
||||||
|
export type ExternalSource =
|
||||||
|
| 'imdb_id'
|
||||||
|
| 'freebase_mid'
|
||||||
|
| 'freebase_id'
|
||||||
|
| 'tvdb_id'
|
||||||
|
| 'tvrage_id'
|
||||||
|
| 'facebook_id'
|
||||||
|
| 'twitter_id'
|
||||||
|
| 'instagram_id';
|
||||||
|
|
||||||
|
export interface ExternalIdOptions extends ParsedUrlQueryInput {
|
||||||
|
external_source: ExternalSource;
|
||||||
|
language?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
type MediaTagged<T> = T & {
|
||||||
|
media_type: MediaType;
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface FindResult {
|
||||||
|
movie_results: MediaTagged<Movie>[];
|
||||||
|
person_results: MediaTagged<Person>[];
|
||||||
|
tv_results: MediaTagged<TV>[];
|
||||||
|
tv_episode_results: MediaTagged<Episode>[];
|
||||||
|
tv_season_results: MediaTagged<Season & { show_id: string }>[];
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ export * from './people';
|
|||||||
export * from './discover';
|
export * from './discover';
|
||||||
export * from './review';
|
export * from './review';
|
||||||
export * from './trending';
|
export * from './trending';
|
||||||
|
export * from './find';
|
||||||
|
|
||||||
export interface AuthorDetails {
|
export interface AuthorDetails {
|
||||||
name: string;
|
name: string;
|
||||||
|
|||||||
@@ -100,6 +100,8 @@ export interface Episode {
|
|||||||
still_path: string
|
still_path: string
|
||||||
vote_average: number
|
vote_average: number
|
||||||
vote_count: number
|
vote_count: number
|
||||||
|
show_id: number;
|
||||||
|
runtime: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SeasonDetails {
|
export interface SeasonDetails {
|
||||||
|
|||||||
Reference in New Issue
Block a user