spotify-ts-wrapper
Version:
Spotify TypeScript wrapper.
26 lines (25 loc) • 1.98 kB
JavaScript
;
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.getUser = getUser;
const Context_1 = require("../Structure/Context");
const RequestClient_1 = require("../Structure/RequestClient");
const user_parser_1 = require("../Parser/user.parser");
function getUser(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 MODIFIED_URL = `https://spclient.wg.spotify.com/user-profile-view/v3/profile/${options === null || options === void 0 ? void 0 : options.id}?playlist_limit=${(_b = (_a = options === null || options === void 0 ? void 0 : options.paginationOptions) === null || _a === void 0 ? void 0 : _a.playlistLimit) !== null && _b !== void 0 ? _b : 10}&artist_limit=${(_d = (_c = options === null || options === void 0 ? void 0 : options.paginationOptions) === null || _c === void 0 ? void 0 : _c.artistLimit) !== null && _d !== void 0 ? _d : 10}&episode_limit=10&market=from_token`;
const fetchRequest = yield RequestClient_1.client.request(MODIFIED_URL, Object.assign({}, context));
return (0, user_parser_1.parseUser)(fetchRequest);
});
}