feat: upcoming movies on discover

This commit is contained in:
sct
2020-11-12 23:38:26 +00:00
parent 2b46268824
commit 67290dd502
6 changed files with 161 additions and 0 deletions

View File

@@ -1,4 +1,5 @@
import axios, { AxiosInstance } from 'axios';
import { number } from 'yup';
interface SearchOptions {
query: string;
@@ -100,6 +101,14 @@ interface TmdbSearchTvResponse extends TmdbPaginatedResponse {
results: TmdbTvResult[];
}
interface TmdbUpcomingMoviesResponse extends TmdbPaginatedResponse {
dates: {
maximum: string;
minimum: string;
};
results: TmdbMovieResult[];
}
interface TmdbExternalIdResponse {
movie_results: TmdbMovieResult[];
tv_results: TmdbTvResult[];
@@ -520,6 +529,30 @@ class TheMovieDb {
}
};
public getUpcomingMovies = async ({
page = 1,
language = 'en-US',
}: {
page: number;
language: string;
}): Promise<TmdbUpcomingMoviesResponse> => {
try {
const response = await this.axios.get<TmdbUpcomingMoviesResponse>(
'/movie/upcoming',
{
params: {
page,
language,
},
}
);
return response.data;
} catch (e) {
throw new Error(`[TMDB] Failed to fetch upcoming movies: ${e.message}`);
}
};
public getAllTrending = async ({
page = 1,
timeWindow = 'day',