UNPKG

spotify-ts-wrapper

Version:

Spotify TypeScript wrapper.

33 lines (32 loc) 2.17 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.getPodcastShow = getPodcastShow; const url_modifiers_1 = require("../Modifiers/url+modifiers"); const show_parser_1 = require("../Parser/show.parser"); const Context_1 = require("../Structure/Context"); const RequestClient_1 = require("../Structure/RequestClient"); function getPodcastShow(options) { return __awaiter(this, void 0, void 0, function* () { var _a, _b, _c, _d; const token = yield RequestClient_1.client.getAccessToken(); const context = (0, Context_1.createSpotifyAuthorizationContext)(token); const params = (0, url_modifiers_1.createSpotifyShowParams)({ id: options === null || options === void 0 ? void 0 : options.id, offSet: (_b = (_a = options.pagePagination) === null || _a === void 0 ? void 0 : _a.offSet) !== null && _b !== void 0 ? _b : 0, limit: (_d = (_c = options === null || options === void 0 ? void 0 : options.pagePagination) === null || _c === void 0 ? void 0 : _c.limit) !== null && _d !== void 0 ? _d : 20, }); const spotifyResolvedObjectURL = (0, url_modifiers_1.getSpotifyURL)(params); const doubleEncodedURL = (0, url_modifiers_1.fixDoubleEncodedUrl)(spotifyResolvedObjectURL); const fetchRequest = yield RequestClient_1.client.request(doubleEncodedURL, Object.assign({}, context)); return (0, show_parser_1.parsePodcastShow)(fetchRequest); }); }