added tv show endpoints
This commit is contained in:
@@ -1,12 +1,7 @@
|
||||
import querystring, { ParsedUrlQueryInput } from 'querystring';
|
||||
import { BaseEndpoint } from './base';
|
||||
import { Changes } from '../types/changes';
|
||||
import { ChangeOptions, Changes } from '../types/changes';
|
||||
|
||||
export interface ChangeOptions extends ParsedUrlQueryInput {
|
||||
end_date?: string;
|
||||
start_date?: string;
|
||||
page?: number;
|
||||
}
|
||||
|
||||
export class ChangeEndpoint extends BaseEndpoint {
|
||||
constructor(protected readonly accessToken: string) {
|
||||
|
||||
@@ -8,3 +8,4 @@ export * from './search';
|
||||
export * from './genre';
|
||||
export * from './movies';
|
||||
export * from './configuration';
|
||||
export * from './tv-shows';
|
||||
|
||||
@@ -1,17 +1,26 @@
|
||||
import { BaseEndpoint } from './base';
|
||||
import {
|
||||
AlternativeTitles,
|
||||
ChangeOptions,
|
||||
Credits,
|
||||
ExternalIds,
|
||||
Images,
|
||||
Keywords, LatestMovie, MovieChanges,
|
||||
MovieDetails, MovieLists, MovieRecommendations, MovieReviews, MoviesPlayingNow, MovieTranslations, PopularMovies,
|
||||
Keywords,
|
||||
LatestMovie,
|
||||
MovieChanges,
|
||||
MovieDetails,
|
||||
MovieLists,
|
||||
MoviesPlayingNow,
|
||||
PopularMovies,
|
||||
Recommendations,
|
||||
ReleaseDates,
|
||||
SimilarMovies, TopRatedMovies, UpcomingMovies,
|
||||
Reviews,
|
||||
SimilarMovies,
|
||||
TopRatedMovies, Translations,
|
||||
UpcomingMovies,
|
||||
Videos,
|
||||
} from '../types/movie';
|
||||
import { ExternalIds } from '../types';
|
||||
import { WatchProviders } from '../types/watch-providers';
|
||||
import { ChangeOptions } from './changes';
|
||||
WatchProviders,
|
||||
} from '../types';
|
||||
import querystring from 'querystring';
|
||||
|
||||
const BASE_MOVIE = '/movie';
|
||||
@@ -55,18 +64,18 @@ export class MoviesEndpoint extends BaseEndpoint{
|
||||
return await this.api.get<MovieLists>(`${BASE_MOVIE}/${id}/lists?${params}`);
|
||||
}
|
||||
|
||||
async recommendations(id: number, options?: {page?: number}): Promise<MovieRecommendations>{
|
||||
async recommendations(id: number, options?: {page?: number}): Promise<Recommendations>{
|
||||
const params = querystring.encode(options);
|
||||
return await this.api.get<MovieRecommendations>(`${BASE_MOVIE}/${id}/recommendations?${params}`);
|
||||
return await this.api.get<Recommendations>(`${BASE_MOVIE}/${id}/recommendations?${params}`);
|
||||
}
|
||||
|
||||
async releaseDates(id: number): Promise<ReleaseDates>{
|
||||
return await this.api.get<ReleaseDates>(`${BASE_MOVIE}/${id}/release_dates`);
|
||||
}
|
||||
|
||||
async reviews(id: number, options?: {page?: number}): Promise<MovieReviews>{
|
||||
async reviews(id: number, options?: {page?: number}): Promise<Reviews>{
|
||||
const params = querystring.encode(options);
|
||||
return await this.api.get<MovieReviews>(`${BASE_MOVIE}/${id}/reviews?${params}`);
|
||||
return await this.api.get<Reviews>(`${BASE_MOVIE}/${id}/reviews?${params}`);
|
||||
}
|
||||
|
||||
async similar(id: number, options?: {page?: number}): Promise<SimilarMovies>{
|
||||
@@ -74,8 +83,8 @@ export class MoviesEndpoint extends BaseEndpoint{
|
||||
return await this.api.get<SimilarMovies>(`${BASE_MOVIE}/${id}/similar?${params}`);
|
||||
}
|
||||
|
||||
async translations(id: number): Promise<MovieTranslations>{
|
||||
return await this.api.get<MovieTranslations>(`${BASE_MOVIE}/${id}/translations`);
|
||||
async translations(id: number): Promise<Translations>{
|
||||
return await this.api.get<Translations>(`${BASE_MOVIE}/${id}/translations`);
|
||||
}
|
||||
|
||||
async videos(id: number): Promise<Videos>{
|
||||
@@ -94,7 +103,7 @@ export class MoviesEndpoint extends BaseEndpoint{
|
||||
return await this.api.get<LatestMovie>(`${BASE_MOVIE}/latest`);
|
||||
}
|
||||
|
||||
async nowPlaying(options?: {page?: number, region?: string}): Promise<MoviesPlayingNow>{
|
||||
async nowPlaying(options?: {page?: number, region?: string, language?: string}): Promise<MoviesPlayingNow>{
|
||||
const params = querystring.encode(options);
|
||||
return await this.api.get<MoviesPlayingNow>(`${BASE_MOVIE}/now_playing?${params}`);
|
||||
}
|
||||
@@ -104,12 +113,12 @@ export class MoviesEndpoint extends BaseEndpoint{
|
||||
return await this.api.get<PopularMovies>(`${BASE_MOVIE}/popular?${params}`);
|
||||
}
|
||||
|
||||
async topRated(options?: {page?: number, region?: string}): Promise<TopRatedMovies>{
|
||||
async topRated(options?: {page?: number, region?: string, language?: string}): Promise<TopRatedMovies>{
|
||||
const params = querystring.encode(options);
|
||||
return await this.api.get<TopRatedMovies>(`${BASE_MOVIE}/top_rated?${params}`);
|
||||
}
|
||||
|
||||
async upcoming(options?: {page?: number, region?: string}): Promise<UpcomingMovies>{
|
||||
async upcoming(options?: {page?: number, region?: string, language?: string}): Promise<UpcomingMovies>{
|
||||
const params = querystring.encode(options);
|
||||
return await this.api.get<UpcomingMovies>(`${BASE_MOVIE}/upcoming?${params}`);
|
||||
}
|
||||
|
||||
134
src/endpoints/tv-shows.ts
Normal file
134
src/endpoints/tv-shows.ts
Normal file
@@ -0,0 +1,134 @@
|
||||
import { BaseEndpoint } from './base';
|
||||
import {
|
||||
AlternativeTitles,
|
||||
ChangeOptions,
|
||||
ContentRatings,
|
||||
Credits,
|
||||
EpisodeGroups,
|
||||
ExternalIds,
|
||||
Images,
|
||||
Keywords,
|
||||
LatestTvShows,
|
||||
OnTheAir,
|
||||
PopularTvShows,
|
||||
Recommendations,
|
||||
Reviews,
|
||||
ScreenedTheatrically,
|
||||
SimilarTvShows,
|
||||
TopRatedTvShows,
|
||||
Translations,
|
||||
TvShowChanges,
|
||||
TvShowDetails,
|
||||
TvShowsAiringToday,
|
||||
Videos,
|
||||
WatchProviders,
|
||||
} from '../types';
|
||||
import querystring from 'querystring';
|
||||
|
||||
const BASE_TV = '/tv';
|
||||
|
||||
export class TvShowsEndpoint extends BaseEndpoint{
|
||||
constructor(protected readonly accessToken: string) {
|
||||
super(accessToken);
|
||||
}
|
||||
|
||||
async details(id: number): Promise<TvShowDetails>{
|
||||
return await this.api.get<TvShowDetails>(`${BASE_TV}/${id}`);
|
||||
}
|
||||
|
||||
async alternativeTitles(id: number): Promise<AlternativeTitles>{
|
||||
return await this.api.get<AlternativeTitles>(`${BASE_TV}/${id}/alternative_titles`);
|
||||
}
|
||||
|
||||
async changes(id: number, options?: ChangeOptions): Promise<TvShowChanges>{
|
||||
const params = querystring.encode(options);
|
||||
return await this.api.get<TvShowChanges>(`${BASE_TV}/${id}/changes?${params}`);
|
||||
}
|
||||
|
||||
async contentRatings(id: number): Promise<ContentRatings>{
|
||||
return await this.api.get<ContentRatings>(`${BASE_TV}/${id}/content_ratings`);
|
||||
}
|
||||
|
||||
async credits(id: number): Promise<Credits>{
|
||||
return await this.api.get<Credits>(`${BASE_TV}/${id}/credits`);
|
||||
}
|
||||
|
||||
|
||||
async episodeGroups(id: number): Promise<EpisodeGroups>{
|
||||
return await this.api.get<EpisodeGroups>(`${BASE_TV}/${id}/episode_groups`);
|
||||
}
|
||||
|
||||
async externalIds(id: number): Promise<ExternalIds>{
|
||||
return await this.api.get<ExternalIds>(`${BASE_TV}/${id}/external_ids`);
|
||||
}
|
||||
|
||||
async images(id: number): Promise<Images>{
|
||||
return await this.api.get<Images>(`${BASE_TV}/${id}/images`);
|
||||
}
|
||||
|
||||
async keywords(id: number): Promise<Keywords>{
|
||||
return await this.api.get<Keywords>(`${BASE_TV}/${id}/keywords`);
|
||||
}
|
||||
|
||||
async recommendations(id: number, options?: {page?: number}): Promise<Recommendations>{
|
||||
const params = querystring.encode(options);
|
||||
return await this.api.get<Recommendations>(`${BASE_TV}/${id}/recommendations?${params}`);
|
||||
}
|
||||
|
||||
async reviews(id: number, options?: {page?: number}): Promise<Reviews>{
|
||||
const params = querystring.encode(options);
|
||||
return await this.api.get<Reviews>(`${BASE_TV}/${id}/reviews?${params}`);
|
||||
}
|
||||
|
||||
async screenedTheatrically(id: number, options?: {page?: number}): Promise<ScreenedTheatrically>{
|
||||
const params = querystring.encode(options);
|
||||
return await this.api.get<ScreenedTheatrically>(`${BASE_TV}/${id}/screened_theatrically`);
|
||||
}
|
||||
|
||||
async similar(id: number, options?: {page?: number}): Promise<SimilarTvShows>{
|
||||
const params = querystring.encode(options);
|
||||
return await this.api.get<SimilarTvShows>(`${BASE_TV}/${id}/similar?${params}`);
|
||||
}
|
||||
|
||||
async translations(id: number): Promise<Translations>{
|
||||
return await this.api.get<Translations>(`${BASE_TV}/${id}/translations`);
|
||||
}
|
||||
|
||||
async videos(id: number): Promise<Videos>{
|
||||
return await this.api.get<Videos>(`${BASE_TV}/${id}/videos`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Powered by JustWatch
|
||||
* @param id
|
||||
*/
|
||||
async watchProviders(id: number): Promise<WatchProviders>{
|
||||
return await this.api.get<WatchProviders>(`${BASE_TV}/${id}/watch/providers`);
|
||||
}
|
||||
|
||||
async latest(): Promise<LatestTvShows>{
|
||||
return await this.api.get<LatestTvShows>(`${BASE_TV}/latest`);
|
||||
}
|
||||
|
||||
async onTheAir(): Promise<OnTheAir>{
|
||||
return await this.api.get<OnTheAir>(`${BASE_TV}/on_the_air`);
|
||||
}
|
||||
|
||||
async airingToday(options?: {page?: number, region?: string, language?: string}): Promise<TvShowsAiringToday>{
|
||||
const params = querystring.encode(options);
|
||||
return await this.api.get<TvShowsAiringToday>(`${BASE_TV}/airing_today?${params}`);
|
||||
}
|
||||
|
||||
async popular(options?: {page?: number}): Promise<PopularTvShows>{
|
||||
const params = querystring.encode(options);
|
||||
return await this.api.get<PopularTvShows>(`${BASE_TV}/popular?${params}`);
|
||||
}
|
||||
|
||||
async topRated(options?: {page?: number, region?: string, language?: string}): Promise<TopRatedTvShows>{
|
||||
const params = querystring.encode(options);
|
||||
return await this.api.get<TopRatedTvShows>(`${BASE_TV}/top_rated?${params}`);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user