UNPKG

better-trakt

Version:

A Trakt.tv client with native Typescript support and quality of life features

113 lines 4.26 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Lists = void 0; const utils_1 = require("../utils"); const requiredArg_1 = require("../utils/requiredArg"); /** * Lists api namespace */ class Lists { constructor(config) { this.config = { apiUrl: `${config.apiUrl}/lists`, client: config.client, }; } /** * Returns all lists with the most likes and comments over the last 7 days. * @param pagination * @returns lists */ trending({ pagination }) { return __awaiter(this, void 0, void 0, function* () { (0, requiredArg_1.checkRequiredArg)(pagination, 'pagination', 'object'); const url = `${this.config.apiUrl}/trending`; const response = yield (0, utils_1.fetch)(this.config.client, url, { pagination }); return response; }); } /** * Returns the most popular lists. * @param pagination * @returns lists */ popular({ pagination }) { return __awaiter(this, void 0, void 0, function* () { (0, requiredArg_1.checkRequiredArg)(pagination, 'pagination', 'object'); const url = `${this.config.apiUrl}/popular`; const response = yield (0, utils_1.fetch)(this.config.client, url, { pagination }); return response; }); } /** * Returns a single list. * @param id list id * @returns list */ getList({ id }) { return __awaiter(this, void 0, void 0, function* () { (0, requiredArg_1.checkRequiredArg)(id, 'id', 'string'); const url = `${this.config.apiUrl}/${id}`; const response = yield (0, utils_1.fetch)(this.config.client, url); return response; }); } /** * Returns all users who liked a list. * @param id list id * @param pagination * @returns */ getLikes({ id, pagination }) { return __awaiter(this, void 0, void 0, function* () { (0, requiredArg_1.checkRequiredArg)(id, 'id', 'string'); (0, requiredArg_1.checkRequiredArg)(pagination, 'pagination', 'object'); const url = `${this.config.apiUrl}/${id}/likes`; const response = yield (0, utils_1.fetch)(this.config.client, url, { pagination }); return response; }); } /** * Get all items on a personal list. * @param id list id * @param type * @param pagination * @returns */ getItems({ id, pagination, type, }) { return __awaiter(this, void 0, void 0, function* () { (0, requiredArg_1.checkRequiredArg)(id, 'id', 'string'); let url = `${this.config.apiUrl}/${id}/items/`; if (type !== undefined) url += `${type}`; const response = yield (0, utils_1.fetch)(this.config.client, url, { pagination }); return response; }); } /** * Returns all top level comments for a list. * @param id list id * @param sort * @param pagination * @returns */ getComments({ id, pagination, sort, }) { return __awaiter(this, void 0, void 0, function* () { (0, requiredArg_1.checkRequiredArg)(id, 'id', 'string'); const url = `${this.config.apiUrl}/${id}/comments`; const response = yield (0, utils_1.fetch)(this.config.client, url, { pagination, sort }); return response; }); } } exports.Lists = Lists; //# sourceMappingURL=index.js.map