Merge branch 'blakejoy:master' into master
This commit is contained in:
28
package-lock.json
generated
28
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "tmdb-ts",
|
"name": "tmdb-ts",
|
||||||
"version": "0.1.3",
|
"version": "0.1.4",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "tmdb-ts",
|
"name": "tmdb-ts",
|
||||||
"version": "0.1.3",
|
"version": "0.1.4",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cross-fetch": "^3.1.4"
|
"cross-fetch": "^3.1.4"
|
||||||
@@ -1704,9 +1704,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/json5": {
|
"node_modules/json5": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz",
|
||||||
"integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==",
|
"integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"minimist": "^1.2.0"
|
"minimist": "^1.2.0"
|
||||||
@@ -1836,9 +1836,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/minimatch": {
|
"node_modules/minimatch": {
|
||||||
"version": "3.0.4",
|
"version": "3.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
|
||||||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"brace-expansion": "^1.1.7"
|
"brace-expansion": "^1.1.7"
|
||||||
@@ -4099,9 +4099,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"json5": {
|
"json5": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz",
|
||||||
"integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==",
|
"integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"minimist": "^1.2.0"
|
"minimist": "^1.2.0"
|
||||||
@@ -4204,9 +4204,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"minimatch": {
|
"minimatch": {
|
||||||
"version": "3.0.4",
|
"version": "3.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
|
||||||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"brace-expansion": "^1.1.7"
|
"brace-expansion": "^1.1.7"
|
||||||
|
|||||||
27
src/endpoints/collections.ts
Normal file
27
src/endpoints/collections.ts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import { DetailedCollection, ImageCollection, LanguageOption, Translations } 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}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async images(id: number, options? : LanguageOption): Promise<ImageCollection> {
|
||||||
|
const params = querystring.encode(options);
|
||||||
|
return await this.api.get<ImageCollection>(`${BASE_COLLECTION}/${id}/images?${params}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async translations(id: number, options? : LanguageOption): Promise<Translations> {
|
||||||
|
const params = querystring.encode(options);
|
||||||
|
return await this.api.get<Translations>(`${BASE_COLLECTION}/${id}/translations?${params}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -14,4 +14,6 @@ export * from './people';
|
|||||||
export * from './review';
|
export * from './review';
|
||||||
export * from './trending';
|
export * from './trending';
|
||||||
export * from './find';
|
export * from './find';
|
||||||
|
export * from './keywords';
|
||||||
|
export * from './collections';
|
||||||
|
|
||||||
|
|||||||
20
src/endpoints/keywords.ts
Normal file
20
src/endpoints/keywords.ts
Normal 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}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
10
src/tmdb.ts
10
src/tmdb.ts
@@ -13,6 +13,8 @@ import {
|
|||||||
ReviewEndpoint,
|
ReviewEndpoint,
|
||||||
TrendingEndpoint,
|
TrendingEndpoint,
|
||||||
FindEndpoint,
|
FindEndpoint,
|
||||||
|
KeywordsEndpoint,
|
||||||
|
CollectionsEndpoint,
|
||||||
} from './endpoints';
|
} from './endpoints';
|
||||||
|
|
||||||
export default class TMDB {
|
export default class TMDB {
|
||||||
@@ -77,4 +79,12 @@ export default class TMDB {
|
|||||||
get find() : FindEndpoint{
|
get find() : FindEndpoint{
|
||||||
return new FindEndpoint(this.accessToken);
|
return new FindEndpoint(this.accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get keywords() : KeywordsEndpoint{
|
||||||
|
return new KeywordsEndpoint(this.accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
get collections() : CollectionsEndpoint{
|
||||||
|
return new CollectionsEndpoint(this.accessToken);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
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,4 +1,4 @@
|
|||||||
import { Person } from './';
|
import { Image, Person } from './';
|
||||||
|
|
||||||
export interface CreditSeason {
|
export interface CreditSeason {
|
||||||
air_date?: string;
|
air_date?: string;
|
||||||
@@ -82,31 +82,10 @@ export interface Credits {
|
|||||||
crew: Crew[];
|
crew: Crew[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ImageCollection {
|
||||||
export interface Backdrop {
|
|
||||||
aspect_ratio: number;
|
|
||||||
file_path: string;
|
|
||||||
height: number;
|
|
||||||
iso_639_1?: any;
|
|
||||||
vote_average: number;
|
|
||||||
vote_count: number;
|
|
||||||
width: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Poster {
|
|
||||||
aspect_ratio: number;
|
|
||||||
file_path: string;
|
|
||||||
height: number;
|
|
||||||
iso_639_1: string;
|
|
||||||
vote_average: number;
|
|
||||||
vote_count: number;
|
|
||||||
width: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface CreditImages {
|
|
||||||
id: number;
|
id: number;
|
||||||
backdrops: Backdrop[];
|
backdrops: Image[];
|
||||||
posters: Poster[];
|
posters: Image[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -125,13 +104,3 @@ export interface Videos {
|
|||||||
id: number;
|
id: number;
|
||||||
results: Video[];
|
results: Video[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Keywords {
|
|
||||||
id: number;
|
|
||||||
keywords: Array<{
|
|
||||||
id: number;
|
|
||||||
name: string;
|
|
||||||
}>
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -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,8 @@ export * from './discover';
|
|||||||
export * from './review';
|
export * from './review';
|
||||||
export * from './trending';
|
export * from './trending';
|
||||||
export * from './find';
|
export * from './find';
|
||||||
|
export * from './keywords';
|
||||||
|
export * from './collections';
|
||||||
|
|
||||||
export interface AuthorDetails {
|
export interface AuthorDetails {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -49,17 +52,8 @@ 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;
|
|
||||||
name: string;
|
|
||||||
poster_path: string;
|
poster_path: string;
|
||||||
adult: boolean;
|
adult: boolean;
|
||||||
overview: string;
|
overview: string;
|
||||||
|
|||||||
24
src/types/keywords.ts
Normal file
24
src/types/keywords.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import { ParsedUrlQueryInput } from 'querystring';
|
||||||
|
import { Movie } from '.';
|
||||||
|
|
||||||
|
export interface KeywordsOptions extends ParsedUrlQueryInput {
|
||||||
|
include_adult?: boolean;
|
||||||
|
language?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BelongingMovies{
|
||||||
|
page: number;
|
||||||
|
results: Movie[];
|
||||||
|
total_results: number;
|
||||||
|
total_pages: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Keyword{
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Keywords {
|
||||||
|
id: number;
|
||||||
|
keywords: Keyword[];
|
||||||
|
}
|
||||||
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