Comparing version 0.1.9 to 0.2.0
export default class Api { | ||
private accessToken; | ||
constructor(accessToken: string); | ||
get<T>(path: string): Promise<T>; | ||
get<T>(path: string, options?: Record<string, any>): Promise<T>; | ||
} |
@@ -7,2 +7,3 @@ "use strict"; | ||
const cross_fetch_1 = __importDefault(require("cross-fetch")); | ||
const utils_1 = require("./utils"); | ||
const BASE_URL_V3 = 'https://api.themoviedb.org/3'; | ||
@@ -14,4 +15,5 @@ class Api { | ||
} | ||
async get(path) { | ||
const response = await (0, cross_fetch_1.default)(`${BASE_URL_V3}${path}`, { | ||
async get(path, options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
const response = await (0, cross_fetch_1.default)(`${BASE_URL_V3}${path}?${params}`, { | ||
method: 'GET', | ||
@@ -18,0 +20,0 @@ headers: { |
@@ -5,3 +5,2 @@ "use strict"; | ||
const base_1 = require("./base"); | ||
const utils_1 = require("../utils"); | ||
class ChangeEndpoint extends base_1.BaseEndpoint { | ||
@@ -13,12 +12,9 @@ constructor(accessToken) { | ||
async movies(options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`/movie/changes?${params}`); | ||
return await this.api.get(`/movie/changes`, options); | ||
} | ||
async tvShows(options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`/tv/changes?${params}`); | ||
return await this.api.get(`/tv/changes`, options); | ||
} | ||
async person(options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`/person/changes${params}`); | ||
return await this.api.get(`/person/change`, options); | ||
} | ||
@@ -25,0 +21,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CollectionsEndpoint = void 0; | ||
const utils_1 = require("../utils"); | ||
const base_1 = require("./base"); | ||
@@ -13,12 +12,9 @@ const BASE_COLLECTION = '/collection'; | ||
async details(id, options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`${BASE_COLLECTION}/${id}?${params}`); | ||
return await this.api.get(`${BASE_COLLECTION}/${id}`, options); | ||
} | ||
async images(id, options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`${BASE_COLLECTION}/${id}/images?${params}`); | ||
return await this.api.get(`${BASE_COLLECTION}/${id}/images`, options); | ||
} | ||
async translations(id, options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`${BASE_COLLECTION}/${id}/translations?${params}`); | ||
return await this.api.get(`${BASE_COLLECTION}/${id}/translations`, options); | ||
} | ||
@@ -25,0 +21,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DiscoverEndpoint = void 0; | ||
const utils_1 = require("../utils"); | ||
const base_1 = require("./base"); | ||
@@ -12,8 +11,6 @@ const BASE_DISCOVER = '/discover'; | ||
async movie(options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`${BASE_DISCOVER}/movie?${params}`); | ||
return await this.api.get(`${BASE_DISCOVER}/movie`, options); | ||
} | ||
async tvShow(options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`${BASE_DISCOVER}/tv?${params}`); | ||
return await this.api.get(`${BASE_DISCOVER}/tv`, options); | ||
} | ||
@@ -20,0 +17,0 @@ } |
@@ -5,3 +5,2 @@ "use strict"; | ||
const base_1 = require("./base"); | ||
const utils_1 = require("../utils"); | ||
class FindEndpoint extends base_1.BaseEndpoint { | ||
@@ -12,4 +11,3 @@ constructor(accessToken) { | ||
async byId(externalId, options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`/find/${externalId}?${params}`); | ||
return await this.api.get(`/find/${externalId}`, options); | ||
} | ||
@@ -16,0 +14,0 @@ } |
@@ -5,3 +5,2 @@ "use strict"; | ||
const base_1 = require("./base"); | ||
const utils_1 = require("../utils"); | ||
const BASE_Keyword = '/keyword'; | ||
@@ -16,4 +15,3 @@ class KeywordsEndpoint extends base_1.BaseEndpoint { | ||
async belongingMovies(keywordId, options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`${BASE_Keyword}/${keywordId}/movies?${params}`); | ||
return await this.api.get(`${BASE_Keyword}/${keywordId}/movies`, options); | ||
} | ||
@@ -20,0 +18,0 @@ } |
@@ -5,3 +5,2 @@ "use strict"; | ||
const base_1 = require("./base"); | ||
const utils_1 = require("../utils"); | ||
const BASE_MOVIE = '/movie'; | ||
@@ -20,4 +19,3 @@ class MoviesEndpoint extends base_1.BaseEndpoint { | ||
async changes(id, options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`${BASE_MOVIE}/${id}/changes?${params}`); | ||
return await this.api.get(`${BASE_MOVIE}/${id}/changes`, options); | ||
} | ||
@@ -37,8 +35,6 @@ async credits(id) { | ||
async lists(id, options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`${BASE_MOVIE}/${id}/lists?${params}`); | ||
return await this.api.get(`${BASE_MOVIE}/${id}/lists`, options); | ||
} | ||
async recommendations(id, options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`${BASE_MOVIE}/${id}/recommendations?${params}`); | ||
return await this.api.get(`${BASE_MOVIE}/${id}/recommendations`, options); | ||
} | ||
@@ -49,8 +45,6 @@ async releaseDates(id) { | ||
async reviews(id, options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`${BASE_MOVIE}/${id}/reviews?${params}`); | ||
return await this.api.get(`${BASE_MOVIE}/${id}/reviews`, options); | ||
} | ||
async similar(id, options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`${BASE_MOVIE}/${id}/similar?${params}`); | ||
return await this.api.get(`${BASE_MOVIE}/${id}/similar`, options); | ||
} | ||
@@ -74,16 +68,12 @@ async translations(id) { | ||
async nowPlaying(options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`${BASE_MOVIE}/now_playing?${params}`); | ||
return await this.api.get(`${BASE_MOVIE}/now_playing`, options); | ||
} | ||
async popular(options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`${BASE_MOVIE}/popular?${params}`); | ||
return await this.api.get(`${BASE_MOVIE}/popular`, options); | ||
} | ||
async topRated(options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`${BASE_MOVIE}/top_rated?${params}`); | ||
return await this.api.get(`${BASE_MOVIE}/top_rated`, options); | ||
} | ||
async upcoming(options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`${BASE_MOVIE}/upcoming?${params}`); | ||
return await this.api.get(`${BASE_MOVIE}/upcoming`, options); | ||
} | ||
@@ -90,0 +80,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.PeopleEndpoint = void 0; | ||
const utils_1 = require("../utils"); | ||
const base_1 = require("./base"); | ||
@@ -15,4 +14,3 @@ const BASE_PERSON = '/person'; | ||
async changes(id, options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`${BASE_PERSON}/${id}/changes?${params}`); | ||
return await this.api.get(`${BASE_PERSON}/${id}/changes`, options); | ||
} | ||
@@ -35,4 +33,3 @@ async movieCredits(id) { | ||
async taggedImages(id, options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`${BASE_PERSON}/${id}/tagged_images?${params}`); | ||
return await this.api.get(`${BASE_PERSON}/${id}/tagged_images`, options); | ||
} | ||
@@ -46,4 +43,3 @@ async translation(id) { | ||
async popular(options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`${BASE_PERSON}/popular?${params}`); | ||
return await this.api.get(`${BASE_PERSON}/popular`, options); | ||
} | ||
@@ -50,0 +46,0 @@ } |
@@ -5,3 +5,2 @@ "use strict"; | ||
const base_1 = require("./base"); | ||
const utils_1 = require("../utils"); | ||
const BASE_SEARCH = '/search'; | ||
@@ -14,25 +13,19 @@ class SearchEndpoint extends base_1.BaseEndpoint { | ||
async companies(options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`${BASE_SEARCH}/company?${params}`); | ||
return await this.api.get(`${BASE_SEARCH}/company`, options); | ||
} | ||
async collections(options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`${BASE_SEARCH}/collection?${params}`); | ||
return await this.api.get(`${BASE_SEARCH}/collection`, options); | ||
} | ||
async keywords(options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`${BASE_SEARCH}/keyword?${params}`); | ||
return await this.api.get(`${BASE_SEARCH}/keyword`, options); | ||
} | ||
async movies(options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`${BASE_SEARCH}/movie?${params}`); | ||
return await this.api.get(`${BASE_SEARCH}/movie`, options); | ||
} | ||
async people(options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`${BASE_SEARCH}/person?${params}`); | ||
return await this.api.get(`${BASE_SEARCH}/person`, options); | ||
} | ||
// TODO: Multi search | ||
async tvShows(options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`${BASE_SEARCH}/tv?${params}`); | ||
return await this.api.get(`${BASE_SEARCH}/tv`, options); | ||
} | ||
@@ -39,0 +32,0 @@ } |
@@ -5,3 +5,2 @@ "use strict"; | ||
const base_1 = require("./base"); | ||
const utils_1 = require("../utils"); | ||
const BASE_TV = '/tv'; | ||
@@ -20,4 +19,3 @@ class TvShowsEndpoint extends base_1.BaseEndpoint { | ||
async changes(id, options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`${BASE_TV}/${id}/changes?${params}`); | ||
return await this.api.get(`${BASE_TV}/${id}/changes`, options); | ||
} | ||
@@ -46,8 +44,6 @@ async contentRatings(id) { | ||
async recommendations(id, options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`${BASE_TV}/${id}/recommendations?${params}`); | ||
return await this.api.get(`${BASE_TV}/${id}/recommendations`, options); | ||
} | ||
async reviews(id, options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`${BASE_TV}/${id}/reviews?${params}`); | ||
return await this.api.get(`${BASE_TV}/${id}/reviews`, options); | ||
} | ||
@@ -58,4 +54,3 @@ async screenedTheatrically(id) { | ||
async similar(id, options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`${BASE_TV}/${id}/similar?${params}`); | ||
return await this.api.get(`${BASE_TV}/${id}/similar`, options); | ||
} | ||
@@ -82,12 +77,9 @@ async translations(id) { | ||
async airingToday(options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`${BASE_TV}/airing_today?${params}`); | ||
return await this.api.get(`${BASE_TV}/airing_today`, options); | ||
} | ||
async popular(options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`${BASE_TV}/popular?${params}`); | ||
return await this.api.get(`${BASE_TV}/popular`, options); | ||
} | ||
async topRated(options) { | ||
const params = (0, utils_1.parseOptions)(options); | ||
return await this.api.get(`${BASE_TV}/top_rated?${params}`); | ||
return await this.api.get(`${BASE_TV}/top_rated`, options); | ||
} | ||
@@ -94,0 +86,0 @@ } |
@@ -1,3 +0,1 @@ | ||
export declare function parseOptions(options?: { | ||
[s: string]: any; | ||
}): string; | ||
export declare function parseOptions(options?: Record<string, any>): string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parseOptions = void 0; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
function parseOptions(options) { | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
return options ? new URLSearchParams(Object.entries(options)).toString() : ''; | ||
@@ -7,0 +7,0 @@ } |
{ | ||
"name": "tmdb-ts", | ||
"version": "0.1.9", | ||
"version": "0.2.0", | ||
"description": "TMDB v3 library wrapper", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
96160
2441