added Collection endpoint and types, buildable option interfaces
This commit is contained in:
17
src/endpoints/collections.ts
Normal file
17
src/endpoints/collections.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { DetailedCollection, LanguageOption, PageOption } from '../types';
|
||||||
|
import { BaseEndpoint } from './base';
|
||||||
|
import querystring from 'querystring';
|
||||||
|
|
||||||
|
const BASE_COLLECTION = '/collection';
|
||||||
|
|
||||||
|
export class CollectionsEndpoint extends BaseEndpoint {
|
||||||
|
constructor(protected readonly accessToken: string) {
|
||||||
|
super(accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
async details(id: number, options? : LanguageOption): Promise<DetailedCollection> {
|
||||||
|
const params = querystring.encode(options);
|
||||||
|
return await this.api.get<DetailedCollection>(`${BASE_COLLECTION}/${id}?${params}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -15,4 +15,5 @@ export * from './review';
|
|||||||
export * from './trending';
|
export * from './trending';
|
||||||
export * from './find';
|
export * from './find';
|
||||||
export * from './keywords';
|
export * from './keywords';
|
||||||
|
export * from './collections';
|
||||||
|
|
||||||
|
|||||||
16
src/types/collections.ts
Normal file
16
src/types/collections.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { Movie } from ".";
|
||||||
|
|
||||||
|
export interface Collection {
|
||||||
|
id: number;
|
||||||
|
backdrop_path: string;
|
||||||
|
name: string;
|
||||||
|
poster_path: string;
|
||||||
|
adult: boolean;
|
||||||
|
original_language: string;
|
||||||
|
original_name: string;
|
||||||
|
overview: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DetailedCollection extends Collection {
|
||||||
|
parts: Movie[]
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
export * from './options';
|
||||||
export * from './certification';
|
export * from './certification';
|
||||||
export * from './credits';
|
export * from './credits';
|
||||||
export * from './configuration';
|
export * from './configuration';
|
||||||
@@ -12,6 +13,7 @@ export * from './review';
|
|||||||
export * from './trending';
|
export * from './trending';
|
||||||
export * from './find';
|
export * from './find';
|
||||||
export * from './keywords';
|
export * from './keywords';
|
||||||
|
export * from './collections';
|
||||||
|
|
||||||
export interface AuthorDetails {
|
export interface AuthorDetails {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -49,13 +51,6 @@ export interface Person {
|
|||||||
popularity: number;
|
popularity: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Collection {
|
|
||||||
id:number;
|
|
||||||
backdrop_path: string;
|
|
||||||
name: string;
|
|
||||||
poster_path: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Movie {
|
export interface Movie {
|
||||||
id: number;
|
id: number;
|
||||||
logo_path: string;
|
logo_path: string;
|
||||||
|
|||||||
9
src/types/options.ts
Normal file
9
src/types/options.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import { ParsedUrlQueryInput } from 'querystring';
|
||||||
|
|
||||||
|
export interface LanguageOption extends ParsedUrlQueryInput {
|
||||||
|
language?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PageOption extends ParsedUrlQueryInput {
|
||||||
|
page?: number;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user