commit5d38a76997Merge:7cccdb9f160e23Author: Blake <blakejoy@users.noreply.github.com> Date: Sat Apr 15 11:44:39 2023 -0400 Merge pull request #22 from blakejoy/feat/add_linting feat - add linting and prettier commitf160e2362cAuthor: Blake Joynes <blakejoynes@gmail.com> Date: Sat Apr 15 11:44:00 2023 -0400 add pre commit hook commit0fd8317884Merge:bc91674d1e87baAuthor: Blake Joynes <blakejoynes@gmail.com> Date: Sat Apr 15 11:41:28 2023 -0400 add husky commitbc91674c4bAuthor: Blake Joynes <blakejoynes@gmail.com> Date: Sat Apr 15 11:39:24 2023 -0400 add husky commitd1e87ba7beAuthor: Blake <blakejoy@users.noreply.github.com> Date: Fri Apr 14 08:48:33 2023 -0400 Update .prettierrc commitd064d4d86fAuthor: Blake Joynes <blakejoynes@gmail.com> Date: Fri Apr 14 03:09:39 2023 -0400 turn off linebreak rules commit06155bd323Author: Blake Joynes <blakejoynes@gmail.com> Date: Thu Apr 13 21:58:41 2023 -0400 add linting and prettier
126 lines
3.6 KiB
TypeScript
126 lines
3.6 KiB
TypeScript
import { BaseEndpoint } from './base';
|
|
import {
|
|
AlternativeTitles,
|
|
ChangeOptions,
|
|
Credits,
|
|
ExternalIds,
|
|
Images,
|
|
Keywords,
|
|
LanguageOption,
|
|
LatestMovie,
|
|
MovieChanges,
|
|
MovieDetails,
|
|
MovieLists,
|
|
MoviesPlayingNow,
|
|
PageOption,
|
|
PopularMovies,
|
|
Recommendations,
|
|
RegionOption,
|
|
ReleaseDates,
|
|
Reviews,
|
|
SimilarMovies,
|
|
TopRatedMovies,
|
|
Translations,
|
|
UpcomingMovies,
|
|
Videos,
|
|
WatchProviders,
|
|
} from '../types';
|
|
|
|
const BASE_MOVIE = '/movie';
|
|
|
|
export class MoviesEndpoint extends BaseEndpoint {
|
|
constructor(protected readonly accessToken: string) {
|
|
super(accessToken);
|
|
}
|
|
|
|
async details(id: number): Promise<MovieDetails> {
|
|
return await this.api.get<MovieDetails>(`${BASE_MOVIE}/${id}`);
|
|
}
|
|
|
|
async alternativeTitles(id: number): Promise<AlternativeTitles> {
|
|
return await this.api.get<AlternativeTitles>(
|
|
`${BASE_MOVIE}/${id}/alternative_titles`
|
|
);
|
|
}
|
|
|
|
async changes(id: number, options?: ChangeOptions): Promise<MovieChanges>{
|
|
return await this.api.get<MovieChanges>(`${BASE_MOVIE}/${id}/changes`, options);
|
|
}
|
|
|
|
async credits(id: number): Promise<Credits> {
|
|
return await this.api.get<Credits>(`${BASE_MOVIE}/${id}/credits`);
|
|
}
|
|
|
|
async externalIds(id: number): Promise<ExternalIds> {
|
|
return await this.api.get<ExternalIds>(`${BASE_MOVIE}/${id}/external_ids`);
|
|
}
|
|
|
|
async images(id: number): Promise<Images> {
|
|
return await this.api.get<Images>(`${BASE_MOVIE}/${id}/images`);
|
|
}
|
|
|
|
async keywords(id: number): Promise<Keywords> {
|
|
return await this.api.get<Keywords>(`${BASE_MOVIE}/${id}/keywords`);
|
|
}
|
|
|
|
async lists(id: number, options?: LanguageOption | PageOption): Promise<MovieLists>{
|
|
return await this.api.get<MovieLists>(`${BASE_MOVIE}/${id}/lists`, options);
|
|
}
|
|
|
|
async recommendations(id: number, options?: PageOption): Promise<Recommendations>{
|
|
return await this.api.get<Recommendations>(`${BASE_MOVIE}/${id}/recommendations`, options);
|
|
}
|
|
|
|
async releaseDates(id: number): Promise<ReleaseDates> {
|
|
return await this.api.get<ReleaseDates>(
|
|
`${BASE_MOVIE}/${id}/release_dates`
|
|
);
|
|
}
|
|
|
|
async reviews(id: number, options?: PageOption): Promise<Reviews>{
|
|
return await this.api.get<Reviews>(`${BASE_MOVIE}/${id}/reviews`, options);
|
|
}
|
|
|
|
async similar(id: number, options?: PageOption): Promise<SimilarMovies>{
|
|
return await this.api.get<SimilarMovies>(`${BASE_MOVIE}/${id}/similar`, options);
|
|
}
|
|
|
|
async translations(id: number): Promise<Translations> {
|
|
return await this.api.get<Translations>(`${BASE_MOVIE}/${id}/translations`);
|
|
}
|
|
|
|
async videos(id: number): Promise<Videos> {
|
|
return await this.api.get<Videos>(`${BASE_MOVIE}/${id}/videos`);
|
|
}
|
|
|
|
/**
|
|
* Powered by JustWatch
|
|
* @param id
|
|
*/
|
|
async watchProviders(id: number): Promise<WatchProviders> {
|
|
return await this.api.get<WatchProviders>(
|
|
`${BASE_MOVIE}/${id}/watch/providers`
|
|
);
|
|
}
|
|
|
|
async latest(): Promise<LatestMovie> {
|
|
return await this.api.get<LatestMovie>(`${BASE_MOVIE}/latest`);
|
|
}
|
|
|
|
async nowPlaying(options?: PageOption & LanguageOption & RegionOption): Promise<MoviesPlayingNow>{
|
|
return await this.api.get<MoviesPlayingNow>(`${BASE_MOVIE}/now_playing`, options);
|
|
}
|
|
|
|
async popular(options?: PageOption): Promise<PopularMovies>{
|
|
return await this.api.get<PopularMovies>(`${BASE_MOVIE}/popular`, options);
|
|
}
|
|
|
|
async topRated(options?: PageOption & LanguageOption & RegionOption): Promise<TopRatedMovies>{
|
|
return await this.api.get<TopRatedMovies>(`${BASE_MOVIE}/top_rated`, options);
|
|
}
|
|
|
|
async upcoming(options?: PageOption & LanguageOption & RegionOption): Promise<UpcomingMovies>{
|
|
return await this.api.get<UpcomingMovies>(`${BASE_MOVIE}/upcoming`, options);
|
|
}
|
|
}
|