added keywords endpoint and types

This commit is contained in:
DerPenz
2023-02-27 15:40:22 +01:00
parent fe86aed01f
commit ea430efcf5
4 changed files with 41 additions and 0 deletions

View File

@@ -14,4 +14,5 @@ export * from './people';
export * from './review';
export * from './trending';
export * from './find';
export * from './keywords';

20
src/endpoints/keywords.ts Normal file
View File

@@ -0,0 +1,20 @@
import { BaseEndpoint } from './base';
import querystring from 'querystring';
import { BelongingMovies, Keyword, KeywordsOptions } from '../types';
const BASE_Keyword = '/keyword';
export class KeywordsEndpoint extends BaseEndpoint {
constructor(accessToken: string) {
super(accessToken);
}
async details(keywordId : number): Promise<Keyword> {
return await this.api.get<Keyword>(`${BASE_Keyword}/${keywordId}`);
}
async belongingMovies(keywordId : number, options?: KeywordsOptions): Promise<BelongingMovies> {
const params = querystring.encode(options);
return await this.api.get<BelongingMovies>(`${BASE_Keyword}/${keywordId}/movies?${params}`);
}
}