Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

easy-spotify-ts

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

easy-spotify-ts - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

dist/models/Request.d.ts

44

dist/EasySpotify.d.ts

@@ -1,33 +0,9 @@

import { AxiosInstance, AxiosRequestConfig } from "axios";
import EasySpotifyConfig from "./EasySpotifyConfig";
import { Album, Artist, Category, FeaturedAlbums, FeaturedPlaylists, PagingAlbums, PagingArtists, PagingCategories, PagingPlaylists, PagingSearch, PagingTracks, Recommendations, RecommendationsQuery, SimplifiedPlaylist, Track, User } from "./models";
export interface PagingRequestParams {
limit?: number;
offset?: number;
}
export interface OptionalRequestParams extends PagingRequestParams {
market?: string;
}
export interface SearchRequestParams extends OptionalRequestParams {
type: string;
include_external?: string;
}
export interface GetAlbumOptions {
market: string;
}
export interface GetArtistAlbumsOptions extends OptionalRequestParams {
include_groups?: string;
}
export interface CreatePlaylistParams {
name: string;
public?: boolean;
collaborative?: boolean;
description?: string;
}
export interface UpdatePlaylistParams {
name?: string;
public?: boolean;
collaborative?: boolean;
description?: string;
}
import { AxiosInstance, AxiosRequestConfig, Method } from 'axios';
import EasySpotifyConfig from './EasySpotifyConfig';
import { Album, Artist, FeaturedAlbums, FeaturedPlaylists, PagingAlbums, PagingArtists, PagingCategories, PagingPlaylists, PagingSearch, PagingTracks, Recommendations, RecommendationsQuery, SimplifiedPlaylist, Track, User } from './models';
import { GetAlbumOptions } from './models/Album';
import { GetArtistAlbumsOptions } from './models/Artist';
import { PagingRequestParams } from './models/Paging';
import { CreatePlaylistParams, UpdatePlaylistParams } from './models/Playlist';
import { OptionalRequestParams, SearchRequestParams } from './models/Request';
export default class EasySpotify {

@@ -57,3 +33,3 @@ config: EasySpotifyConfig;

locale?: string;
}): Promise<Category>;
}): Promise<any>;
getBrowseCategoryPlaylists(id: string, options: {

@@ -82,4 +58,4 @@ country?: string;

getUserProfile(userId?: string): Promise<User>;
buildRequest(endpoint: string, params?: AxiosRequestConfig["params"], method?: string): Promise<any>;
buildRequest(endpoint: string, params?: AxiosRequestConfig['params'], method?: Method): Promise<any>;
private buildHeaders;
}

@@ -14,6 +14,7 @@ "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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -52,10 +53,13 @@ });

var models_1 = require("./models");
var utils_1 = require("./utils");
var EasySpotify = /** @class */ (function () {
function EasySpotify(config) {
this.config = config;
this.httpClient = axios_1.default;
this.httpClient = axios_1.default.create({
validateStatus: function (status) { return status < 500; }
});
}
EasySpotify.prototype.setToken = function (token) {
if (token.trim() === "") {
throw new Error("Cannot set an empty token");
if (token.trim() === '') {
throw new Error('Cannot set an empty token');
}

@@ -65,4 +69,4 @@ this.config.token = token;

EasySpotify.prototype.setApiUrl = function (apiURL) {
if (apiURL.trim() === "") {
throw new Error("Cannot set an empty API Url");
if (apiURL.trim() === '') {
throw new Error('Cannot set an empty API Url');
}

@@ -79,21 +83,10 @@ this.config.apiURL = apiURL;

return __awaiter(this, void 0, void 0, function () {
var response, err_1;
var response, data;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.buildRequest("albums/" + id, options)];
case 0: return [4 /*yield*/, this.buildRequest("albums/" + id, options)];
case 1:
response = _a.sent();
if (response.data) {
return [2 /*return*/, new models_1.Album(response.data)];
}
else {
throw new Error("Could not find any album with that id");
}
return [3 /*break*/, 3];
case 2:
err_1 = _a.sent();
throw err_1;
case 3: return [2 /*return*/];
data = (0, utils_1.handleResponse)(response);
return [2 /*return*/, new models_1.Album(data)];
}

@@ -105,24 +98,10 @@ });

return __awaiter(this, void 0, void 0, function () {
var response, albums, err_2;
var response, data;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.buildRequest("albums", __assign({ ids: "" + ids }, options))];
case 0: return [4 /*yield*/, this.buildRequest('albums', __assign({ ids: "" + ids }, options))];
case 1:
response = _a.sent();
if (response.data.albums) {
albums = response.data.albums.map(function (album) {
return new models_1.Album(album);
});
return [2 /*return*/, albums];
}
else {
throw new Error("Could not find any albums with provided ids");
}
return [3 /*break*/, 3];
case 2:
err_2 = _a.sent();
throw err_2;
case 3: return [2 /*return*/];
data = (0, utils_1.handleResponse)(response);
return [2 /*return*/, data.albums.map(function (album) { return new models_1.Album(album); })];
}

@@ -134,21 +113,9 @@ });

return __awaiter(this, void 0, void 0, function () {
var response, err_3;
var response;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.buildRequest("albums/" + id + "/tracks", options)];
case 0: return [4 /*yield*/, this.buildRequest("albums/" + id + "/tracks", options)];
case 1:
response = _a.sent();
if (response.data) {
return [2 /*return*/, response.data];
}
else {
throw new Error("Could not find any tracks for provided id");
}
return [3 /*break*/, 3];
case 2:
err_3 = _a.sent();
throw err_3;
case 3: return [2 /*return*/];
return [2 /*return*/, (0, utils_1.handleResponse)(response)];
}

@@ -160,18 +127,10 @@ });

return __awaiter(this, void 0, void 0, function () {
var response, err_4;
var response, data;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.buildRequest("artists/" + id)];
case 0: return [4 /*yield*/, this.buildRequest("artists/" + id)];
case 1:
response = _a.sent();
if (response.data) {
return [2 /*return*/, response.data];
}
return [3 /*break*/, 3];
case 2:
err_4 = _a.sent();
throw err_4;
case 3: return [2 /*return*/];
data = (0, utils_1.handleResponse)(response);
return [2 /*return*/, new models_1.Artist(data)];
}

@@ -183,24 +142,12 @@ });

return __awaiter(this, void 0, void 0, function () {
var response, artists, err_5;
var response, data;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.buildRequest("artists", { ids: "" + ids })];
case 0: return [4 /*yield*/, this.buildRequest('artists', {
ids: "" + ids
})];
case 1:
response = _a.sent();
if (response.data.artists) {
artists = response.data.artists.map(function (artist) {
return new models_1.Artist(artist);
});
return [2 /*return*/, artists];
}
else {
throw new Error("No artists found");
}
return [3 /*break*/, 3];
case 2:
err_5 = _a.sent();
throw err_5;
case 3: return [2 /*return*/];
data = (0, utils_1.handleResponse)(response);
return [2 /*return*/, data.artists.map(function (artist) { return new models_1.Artist(artist); })];
}

@@ -212,21 +159,9 @@ });

return __awaiter(this, void 0, void 0, function () {
var response, err_6;
var response;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.buildRequest("artists/" + id + "/albums", options)];
case 0: return [4 /*yield*/, this.buildRequest("artists/" + id + "/albums", options)];
case 1:
response = _a.sent();
if (response.data) {
return [2 /*return*/, response.data];
}
else {
throw new Error("Could not find any tracks for provided id");
}
return [3 /*break*/, 3];
case 2:
err_6 = _a.sent();
throw err_6;
case 3: return [2 /*return*/];
return [2 /*return*/, (0, utils_1.handleResponse)(response)];
}

@@ -238,24 +173,10 @@ });

return __awaiter(this, void 0, void 0, function () {
var response, tracks, err_7;
var response, data;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.buildRequest("artists/" + id + "/top-tracks", options)];
case 0: return [4 /*yield*/, this.buildRequest("artists/" + id + "/top-tracks", options)];
case 1:
response = _a.sent();
if (response.data.tracks) {
tracks = response.data.tracks.map(function (track) {
return new models_1.Track(track);
});
return [2 /*return*/, tracks];
}
else {
throw new Error("Could not find any tracks for provided id");
}
return [3 /*break*/, 3];
case 2:
err_7 = _a.sent();
throw err_7;
case 3: return [2 /*return*/];
data = (0, utils_1.handleResponse)(response);
return [2 /*return*/, data.tracks.map(function (track) { return new models_1.Track(track); })];
}

@@ -267,21 +188,10 @@ });

return __awaiter(this, void 0, void 0, function () {
var response, artists, err_8;
var response, data;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.buildRequest("artists/" + id + "/related-artists")];
case 0: return [4 /*yield*/, this.buildRequest("artists/" + id + "/related-artists")];
case 1:
response = _a.sent();
if (response.data.artists) {
artists = response.data.artists.map(function (artist) {
return new models_1.Artist(artist);
});
return [2 /*return*/, artists];
}
return [3 /*break*/, 3];
case 2:
err_8 = _a.sent();
throw err_8;
case 3: return [2 /*return*/];
data = (0, utils_1.handleResponse)(response);
return [2 /*return*/, data.artists.map(function (artist) { return new models_1.Artist(artist); })];
}

@@ -293,19 +203,12 @@ });

return __awaiter(this, void 0, void 0, function () {
var params, response, err_9;
var params, response, data;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
params = __assign({}, options, { q: query, type: "album" });
return [4 /*yield*/, this.buildRequest("search", params)];
params = __assign(__assign({}, options), { q: query, type: 'album' });
return [4 /*yield*/, this.buildRequest('search', params)];
case 1:
response = _a.sent();
if (response.data.albums) {
return [2 /*return*/, response.data.albums];
}
return [3 /*break*/, 3];
case 2:
err_9 = _a.sent();
throw err_9;
case 3: return [2 /*return*/];
data = (0, utils_1.handleResponse)(response);
return [2 /*return*/, data.albums];
}

@@ -317,19 +220,12 @@ });

return __awaiter(this, void 0, void 0, function () {
var params, response, err_10;
var params, response, data;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
params = __assign({}, options, { q: query, type: "artist" });
return [4 /*yield*/, this.buildRequest("search", params)];
params = __assign(__assign({}, options), { q: query, type: 'artist' });
return [4 /*yield*/, this.buildRequest('search', params)];
case 1:
response = _a.sent();
if (response.data.artists) {
return [2 /*return*/, response.data.artists];
}
return [3 /*break*/, 3];
case 2:
err_10 = _a.sent();
throw err_10;
case 3: return [2 /*return*/];
data = (0, utils_1.handleResponse)(response);
return [2 /*return*/, data.artists];
}

@@ -341,19 +237,12 @@ });

return __awaiter(this, void 0, void 0, function () {
var params, response, err_11;
var params, response, data;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
params = __assign({}, options, { q: query, type: "playlist" });
return [4 /*yield*/, this.buildRequest("search", params)];
params = __assign(__assign({}, options), { q: query, type: 'playlist' });
return [4 /*yield*/, this.buildRequest('search', params)];
case 1:
response = _a.sent();
if (response.data.playlists) {
return [2 /*return*/, response.data.playlists];
}
return [3 /*break*/, 3];
case 2:
err_11 = _a.sent();
throw err_11;
case 3: return [2 /*return*/];
data = (0, utils_1.handleResponse)(response);
return [2 /*return*/, data.playlists];
}

@@ -365,19 +254,12 @@ });

return __awaiter(this, void 0, void 0, function () {
var params, response, err_12;
var params, response, data;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
params = __assign({}, options, { q: query, type: "track" });
return [4 /*yield*/, this.buildRequest("search", params)];
params = __assign(__assign({}, options), { q: query, type: 'track' });
return [4 /*yield*/, this.buildRequest('search', params)];
case 1:
response = _a.sent();
if (response.data.tracks) {
return [2 /*return*/, response.data.tracks];
}
return [3 /*break*/, 3];
case 2:
err_12 = _a.sent();
throw err_12;
case 3: return [2 /*return*/];
data = (0, utils_1.handleResponse)(response);
return [2 /*return*/, data.tracks];
}

@@ -389,18 +271,9 @@ });

return __awaiter(this, void 0, void 0, function () {
var response, err_13;
var response;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.buildRequest("search", __assign({}, options, { q: query }))];
case 0: return [4 /*yield*/, this.buildRequest('search', __assign(__assign({}, options), { q: query }))];
case 1:
response = _a.sent();
if (response.data) {
return [2 /*return*/, response.data];
}
return [3 /*break*/, 3];
case 2:
err_13 = _a.sent();
throw err_13;
case 3: return [2 /*return*/];
return [2 /*return*/, (0, utils_1.handleResponse)(response)];
}

@@ -412,21 +285,9 @@ });

return __awaiter(this, void 0, void 0, function () {
var response, err_14;
var response;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.buildRequest("browse/categories/" + id, options)];
case 0: return [4 /*yield*/, this.buildRequest("browse/categories/" + id, options)];
case 1:
response = _a.sent();
if (response.data) {
return [2 /*return*/, new models_1.Category(response.data)];
}
else {
throw new Error("Could not find any category with that id");
}
return [3 /*break*/, 3];
case 2:
err_14 = _a.sent();
throw err_14;
case 3: return [2 /*return*/];
return [2 /*return*/, (0, utils_1.handleResponse)(response)];
}

@@ -438,21 +299,10 @@ });

return __awaiter(this, void 0, void 0, function () {
var response, err_15;
var response, data;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.buildRequest("browse/categories/" + id + "/playlists", options)];
case 0: return [4 /*yield*/, this.buildRequest("browse/categories/" + id + "/playlists", options)];
case 1:
response = _a.sent();
if (response.data) {
return [2 /*return*/, response.data.playlists];
}
else {
throw new Error("Could not find any playlist from that category id");
}
return [3 /*break*/, 3];
case 2:
err_15 = _a.sent();
throw err_15;
case 3: return [2 /*return*/];
data = (0, utils_1.handleResponse)(response);
return [2 /*return*/, data.playlists];
}

@@ -464,21 +314,10 @@ });

return __awaiter(this, void 0, void 0, function () {
var response, err_16;
var response, data;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.buildRequest("browse/categories", options)];
case 0: return [4 /*yield*/, this.buildRequest('browse/categories', options)];
case 1:
response = _a.sent();
if (response.data) {
return [2 /*return*/, response.data.categories];
}
else {
throw new Error("Could not get any categories");
}
return [3 /*break*/, 3];
case 2:
err_16 = _a.sent();
throw err_16;
case 3: return [2 /*return*/];
data = (0, utils_1.handleResponse)(response);
return [2 /*return*/, data.categories];
}

@@ -490,24 +329,13 @@ });

return __awaiter(this, void 0, void 0, function () {
var response, err_17;
var response;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
if (options.timestamp) {
Object.assign(options, { timestamp: options.timestamp.toISOString() });
}
return [4 /*yield*/, this.buildRequest("browse/featured-playlists", options)];
return [4 /*yield*/, this.buildRequest('browse/featured-playlists', options)];
case 1:
response = _a.sent();
if (response.data) {
return [2 /*return*/, response.data];
}
else {
throw new Error("Could not get any featured playlists");
}
return [3 /*break*/, 3];
case 2:
err_17 = _a.sent();
throw err_17;
case 3: return [2 /*return*/];
return [2 /*return*/, (0, utils_1.handleResponse)(response)];
}

@@ -519,21 +347,9 @@ });

return __awaiter(this, void 0, void 0, function () {
var response, err_18;
var response;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.buildRequest("browse/new-releases", options)];
case 0: return [4 /*yield*/, this.buildRequest('browse/new-releases', options)];
case 1:
response = _a.sent();
if (response.data) {
return [2 /*return*/, response.data];
}
else {
throw new Error("Could not get any albums");
}
return [3 /*break*/, 3];
case 2:
err_18 = _a.sent();
throw err_18;
case 3: return [2 /*return*/];
return [2 /*return*/, (0, utils_1.handleResponse)(response)];
}

@@ -545,10 +361,9 @@ });

return __awaiter(this, void 0, void 0, function () {
var response, err_19;
var response;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
if (query.seed_artists && query.seed_artists.length) {
Object.assign(query, {
seed_artists: query.seed_artists.join(","),
seed_artists: query.seed_artists.join(',')
});

@@ -558,3 +373,3 @@ }

Object.assign(query, {
seed_genres: query.seed_genres.join(","),
seed_genres: query.seed_genres.join(',')
});

@@ -564,19 +379,9 @@ }

Object.assign(query, {
seed_tracks: query.seed_tracks.join(","),
seed_tracks: query.seed_tracks.join(',')
});
}
return [4 /*yield*/, this.buildRequest("recommendations", query)];
return [4 /*yield*/, this.buildRequest('recommendations', query)];
case 1:
response = _a.sent();
if (response.data) {
return [2 /*return*/, response.data];
}
else {
throw new Error("Could not get any recommendations");
}
return [3 /*break*/, 3];
case 2:
err_19 = _a.sent();
throw err_19;
case 3: return [2 /*return*/];
return [2 /*return*/, (0, utils_1.handleResponse)(response)];
}

@@ -588,19 +393,11 @@ });

return __awaiter(this, void 0, void 0, function () {
var endpoint, response, err_20;
var endpoint, response;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
endpoint = userId ? "users/" + userId + "/playlists" : "me/playlists";
endpoint = userId ? "users/" + userId + "/playlists" : 'me/playlists';
return [4 /*yield*/, this.buildRequest(endpoint, options)];
case 1:
response = _a.sent();
if (response.data) {
return [2 /*return*/, response.data];
}
return [3 /*break*/, 3];
case 2:
err_20 = _a.sent();
throw err_20;
case 3: return [2 /*return*/];
return [2 /*return*/, (0, utils_1.handleResponse)(response)];
}

@@ -612,18 +409,9 @@ });

return __awaiter(this, void 0, void 0, function () {
var response, err_21;
var response;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.buildRequest("users/" + userId + "/playlists", params, "post")];
case 0: return [4 /*yield*/, this.buildRequest("users/" + userId + "/playlists", params, 'POST')];
case 1:
response = _a.sent();
if (response.data) {
return [2 /*return*/, response.data];
}
return [3 /*break*/, 3];
case 2:
err_21 = _a.sent();
throw err_21;
case 3: return [2 /*return*/];
return [2 /*return*/, (0, utils_1.handleResponse)(response)];
}

@@ -635,15 +423,9 @@ });

return __awaiter(this, void 0, void 0, function () {
var err_22;
var response;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.buildRequest("playlists/" + playlistId, params, "put")];
case 0: return [4 /*yield*/, this.buildRequest("playlists/" + playlistId, params, 'PUT')];
case 1:
_a.sent();
return [3 /*break*/, 3];
case 2:
err_22 = _a.sent();
throw err_22;
case 3: return [2 /*return*/];
response = _a.sent();
return [2 /*return*/, (0, utils_1.handleResponse)(response)];
}

@@ -655,15 +437,9 @@ });

return __awaiter(this, void 0, void 0, function () {
var err_23;
var response;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.buildRequest("playlists/" + playlistId + "/tracks", { uris: uris }, "post")];
case 0: return [4 /*yield*/, this.buildRequest("playlists/" + playlistId + "/tracks", { uris: uris }, 'POST')];
case 1:
_a.sent();
return [3 /*break*/, 3];
case 2:
err_23 = _a.sent();
throw err_23;
case 3: return [2 /*return*/];
response = _a.sent();
return [2 /*return*/, (0, utils_1.handleResponse)(response)];
}

@@ -675,15 +451,9 @@ });

return __awaiter(this, void 0, void 0, function () {
var err_24;
var response;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.buildRequest("playlists/" + playlistId + "/tracks", { uris: uris }, "put")];
case 0: return [4 /*yield*/, this.buildRequest("playlists/" + playlistId + "/tracks", { uris: uris }, 'PUT')];
case 1:
_a.sent();
return [3 /*break*/, 3];
case 2:
err_24 = _a.sent();
throw err_24;
case 3: return [2 /*return*/];
response = _a.sent();
return [2 /*return*/, (0, utils_1.handleResponse)(response)];
}

@@ -695,15 +465,9 @@ });

return __awaiter(this, void 0, void 0, function () {
var err_25;
var response;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.buildRequest("playlists/" + playlistId + "/followers", undefined, "delete")];
case 0: return [4 /*yield*/, this.buildRequest("playlists/" + playlistId + "/followers", undefined, 'DELETE')];
case 1:
_a.sent();
return [3 /*break*/, 3];
case 2:
err_25 = _a.sent();
throw err_25;
case 3: return [2 /*return*/];
response = _a.sent();
return [2 /*return*/, (0, utils_1.handleResponse)(response)];
}

@@ -715,19 +479,11 @@ });

return __awaiter(this, void 0, void 0, function () {
var endpoint, response, err_26;
var endpoint, response;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
endpoint = userId ? "users/" + userId : "me";
endpoint = userId ? "users/" + userId : 'me';
return [4 /*yield*/, this.buildRequest(endpoint)];
case 1:
response = _a.sent();
if (response.data) {
return [2 /*return*/, response.data];
}
return [3 /*break*/, 3];
case 2:
err_26 = _a.sent();
throw err_26;
case 3: return [2 /*return*/];
return [2 /*return*/, (0, utils_1.handleResponse)(response)];
}

@@ -739,7 +495,9 @@ });

var _this = this;
if (method === void 0) { method = "get"; }
if (method === void 0) { method = 'GET'; }
return new Promise(function (resolve, reject) {
var _a;
try {
var paramsKey = ["put", "post", "patch"].some(function (m) { return m === method.toLowerCase(); }) ? "data" : "params";
var payloadKey = ['PUT', 'POST', 'PATCH'].some(function (m) { return m === method; })
? 'data'
: 'params';
_this.httpClient((_a = {

@@ -749,6 +507,9 @@ headers: _this.buildHeaders(),

},
_a[paramsKey] = params,
_a[payloadKey] = params,
_a.url = _this.getApiUrl() + "/" + endpoint,
_a)).then(resolve, function (e) {
var retryAfter = (e.response && e.response.headers) && e.response.headers["retry-after"];
var _a, _b;
var retryAfter = ((_a = e.response) === null || _a === void 0 ? void 0 : _a.headers)
? (_b = e.response) === null || _b === void 0 ? void 0 : _b.headers['retry-after']
: null;
if (retryAfter) {

@@ -771,4 +532,4 @@ setTimeout(function () {

return {
"Authorization": "Bearer " + this.config.token,
"Content-Type": "application/json",
Authorization: "Bearer " + this.config.token,
'Content-Type': 'application/json'
};

@@ -775,0 +536,0 @@ };

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var API_URL = "https://api.spotify.com/v1";
var API_URL = 'https://api.spotify.com/v1';
var EasySpotifyConfig = /** @class */ (function () {

@@ -5,0 +5,0 @@ function EasySpotifyConfig(token, apiURL) {

@@ -1,3 +0,3 @@

import EasySpotify from "./EasySpotify";
import EasySpotifyConfig from "./EasySpotifyConfig";
import EasySpotify from './EasySpotify';
import EasySpotifyConfig from './EasySpotifyConfig';
export { EasySpotify, EasySpotifyConfig };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EasySpotifyConfig = exports.EasySpotify = void 0;
var EasySpotify_1 = require("./EasySpotify");

@@ -4,0 +5,0 @@ exports.EasySpotify = EasySpotify_1.default;

@@ -1,7 +0,7 @@

import { SimplifiedArtist } from "./Artist";
import { Copyright } from "./Copyright";
import { ExternalIDS } from "./ExternalIDS";
import { ExternalUrls } from "./ExternalUrls";
import { Image } from "./Image";
import { PagingTracks, PagingAlbums } from "./Paging";
import { SimplifiedArtist } from './Artist';
import { Copyright } from './Copyright';
import { ExternalIDS } from './ExternalIDS';
import { ExternalUrls } from './ExternalUrls';
import { Image } from './Image';
import { PagingTracks, PagingAlbums } from './Paging';
export interface FeaturedAlbums {

@@ -48,1 +48,4 @@ message: string;

}
export interface GetAlbumOptions {
market: string;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Album = void 0;
var Album = /** @class */ (function () {

@@ -4,0 +5,0 @@ function Album(response) {

@@ -1,4 +0,5 @@

import { ExternalUrls } from "./ExternalUrls";
import { Followers } from "./Followers";
import { Image } from "./Image";
import { ExternalUrls } from './ExternalUrls';
import { Followers } from './Followers';
import { Image } from './Image';
import { OptionalRequestParams } from './Request';
export interface SimplifiedArtist {

@@ -12,2 +13,5 @@ external_urls: ExternalUrls;

}
export interface GetArtistAlbumsOptions extends OptionalRequestParams {
include_groups?: string;
}
export declare class Artist implements SimplifiedArtist {

@@ -14,0 +18,0 @@ external_urls: ExternalUrls;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Artist = void 0;
var Artist = /** @class */ (function () {

@@ -4,0 +5,0 @@ function Artist(response) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Category = void 0;
var Category = /** @class */ (function () {

@@ -4,0 +5,0 @@ function Category(response) {

@@ -1,15 +0,15 @@

import { Album, FeaturedAlbums, SimplifiedAlbum } from "./Album";
import { Artist, SimplifiedArtist } from "./Artist";
import { Category } from "./Category";
import { Copyright } from "./Copyright";
import { ExternalIDS } from "./ExternalIDS";
import { ExternalUrls } from "./ExternalUrls";
import { Followers } from "./Followers";
import { Image } from "./Image";
import { Paging, PagingAlbums, PagingArtists, PagingCategories, PagingPlaylists, PagingSearch, PagingTracks } from "./Paging";
import { FeaturedPlaylists, SimplifiedPlaylist } from "./Playlist";
import { Recommendations, RecommendationsQuery } from "./Recomendations";
import { SimplifiedTrack } from "./SimplifiedTrack";
import { Track } from "./Track";
import { User } from "./User";
export { Album, Artist, Category, Copyright, ExternalIDS, ExternalUrls, FeaturedAlbums, FeaturedPlaylists, Followers, Image, Paging, PagingAlbums, PagingArtists, PagingCategories, PagingPlaylists, PagingSearch, PagingTracks, Recommendations, RecommendationsQuery, SimplifiedAlbum, SimplifiedArtist, SimplifiedPlaylist, SimplifiedTrack, Track, User, };
import { Album, FeaturedAlbums, SimplifiedAlbum } from './Album';
import { Artist, SimplifiedArtist } from './Artist';
import { Category } from './Category';
import { Copyright } from './Copyright';
import { ExternalIDS } from './ExternalIDS';
import { ExternalUrls } from './ExternalUrls';
import { Followers } from './Followers';
import { Image } from './Image';
import { Paging, PagingAlbums, PagingArtists, PagingCategories, PagingPlaylists, PagingSearch, PagingTracks } from './Paging';
import { FeaturedPlaylists, SimplifiedPlaylist } from './Playlist';
import { Recommendations, RecommendationsQuery } from './Recomendations';
import { SimplifiedTrack } from './SimplifiedTrack';
import { Track } from './Track';
import { User } from './User';
export { Album, Artist, Category, Copyright, ExternalIDS, ExternalUrls, FeaturedAlbums, FeaturedPlaylists, Followers, Image, Paging, PagingAlbums, PagingArtists, PagingCategories, PagingPlaylists, PagingSearch, PagingTracks, Recommendations, RecommendationsQuery, SimplifiedAlbum, SimplifiedArtist, SimplifiedPlaylist, SimplifiedTrack, Track, User };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Track = exports.Recommendations = exports.Category = exports.Artist = exports.Album = void 0;
var Album_1 = require("./Album");
exports.Album = Album_1.Album;
Object.defineProperty(exports, "Album", { enumerable: true, get: function () { return Album_1.Album; } });
var Artist_1 = require("./Artist");
exports.Artist = Artist_1.Artist;
Object.defineProperty(exports, "Artist", { enumerable: true, get: function () { return Artist_1.Artist; } });
var Category_1 = require("./Category");
exports.Category = Category_1.Category;
Object.defineProperty(exports, "Category", { enumerable: true, get: function () { return Category_1.Category; } });
var Recomendations_1 = require("./Recomendations");
exports.Recommendations = Recomendations_1.Recommendations;
Object.defineProperty(exports, "Recommendations", { enumerable: true, get: function () { return Recomendations_1.Recommendations; } });
var Track_1 = require("./Track");
exports.Track = Track_1.Track;
Object.defineProperty(exports, "Track", { enumerable: true, get: function () { return Track_1.Track; } });

@@ -1,6 +0,6 @@

import { SimplifiedAlbum } from "./Album";
import { SimplifiedArtist } from "./Artist";
import { Category } from "./Category";
import { SimplifiedPlaylist } from "./Playlist";
import { SimplifiedTrack } from "./SimplifiedTrack";
import { SimplifiedAlbum } from './Album';
import { SimplifiedArtist } from './Artist';
import { Category } from './Category';
import { SimplifiedPlaylist } from './Playlist';
import { SimplifiedTrack } from './SimplifiedTrack';
export interface Paging {

@@ -36,1 +36,5 @@ href: string;

}
export interface PagingRequestParams {
limit?: number;
offset?: number;
}

@@ -1,5 +0,5 @@

import { ExternalUrls } from "./ExternalUrls";
import { Image } from "./Image";
import { PagingPlaylists } from "./Paging";
import { User } from "./User";
import { ExternalUrls } from './ExternalUrls';
import { Image } from './Image';
import { PagingPlaylists } from './Paging';
import { User } from './User';
export interface FeaturedPlaylists {

@@ -9,2 +9,6 @@ message: string;

}
interface Tracks {
href: string;
total: number;
}
export interface SimplifiedPlaylist {

@@ -22,10 +26,18 @@ collaborative: boolean;

tracks: Tracks;
type: "playlist";
type: 'playlist';
uri: string;
description: string;
}
interface Tracks {
href: string;
total: number;
export interface CreatePlaylistParams {
name: string;
public?: boolean;
collaborative?: boolean;
description?: string;
}
export interface UpdatePlaylistParams {
name?: string;
public?: boolean;
collaborative?: boolean;
description?: string;
}
export {};

@@ -1,6 +0,2 @@

import { SimplifiedTrack } from ".";
export declare class Recommendations {
seeds: RecommendationsSeed[];
tracks: SimplifiedTrack[];
}
import { SimplifiedTrack } from '.';
export interface RecommendationsSeed {

@@ -12,4 +8,8 @@ afterFilteringSize: number;

initialPoolSize: number;
type: "artist" | "genre" | "track";
type: 'artist' | 'genre' | 'track';
}
export declare class Recommendations {
seeds: RecommendationsSeed[];
tracks: SimplifiedTrack[];
}
export interface RecommendationsQuery {

@@ -16,0 +16,0 @@ limit?: number;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Recommendations = void 0;
var Recommendations = /** @class */ (function () {

@@ -4,0 +5,0 @@ function Recommendations() {

@@ -1,3 +0,3 @@

import { SimplifiedArtist } from "./Artist";
import { ExternalUrls } from "./ExternalUrls";
import { SimplifiedArtist } from './Artist';
import { ExternalUrls } from './ExternalUrls';
export interface SimplifiedTrack {

@@ -4,0 +4,0 @@ artists: SimplifiedArtist[];

@@ -1,5 +0,5 @@

import { SimplifiedAlbum } from "./Album";
import { SimplifiedArtist } from "./Artist";
import { ExternalIDS } from "./ExternalIDS";
import { ExternalUrls } from "./ExternalUrls";
import { SimplifiedAlbum } from './Album';
import { SimplifiedArtist } from './Artist';
import { ExternalIDS } from './ExternalIDS';
import { ExternalUrls } from './ExternalUrls';
export interface TrackLink {

@@ -6,0 +6,0 @@ external_urls: ExternalUrls;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Track = void 0;
var Track = /** @class */ (function () {

@@ -4,0 +5,0 @@ function Track(response) {

@@ -1,4 +0,4 @@

import { ExternalUrls } from "./ExternalUrls";
import { Followers } from "./Followers";
import { Image } from "./Image";
import { ExternalUrls } from './ExternalUrls';
import { Followers } from './Followers';
import { Image } from './Image';
export interface User {

@@ -5,0 +5,0 @@ display_name: string;

{
"name": "easy-spotify-ts",
"version": "0.2.2",
"version": "0.2.3",
"description": "A Spotify Web API library in Typescript",

@@ -8,3 +8,3 @@ "main": "dist/index.js",

"dependencies": {
"axios": "^0.18.1"
"axios": "^0.21.4"
},

@@ -16,9 +16,21 @@ "files": [

"@types/chai": "^4.1.7",
"@types/mocha": "^5.2.5",
"@types/mocha": "^9.0.0",
"@types/node": "14.17.6",
"@types/sinon": "^5.0.7",
"@types/sinon-chai": "^3.2.1",
"@typescript-eslint/eslint-plugin": "^4.31.1",
"@typescript-eslint/parser": "^4.31.1",
"chai": "^4.2.0",
"codecov": "^3.2.0",
"mocha": "^5.2.0",
"eslint": "^7.2.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-chai-expect": "^2.2.0",
"eslint-plugin-chai-friendly": "^0.7.2",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-mocha": "^9.0.0",
"eslint-plugin-prettier": "^4.0.0",
"mocha": "^9.1.1",
"nyc": "^15.0.0",
"prettier": "^2.4.1",
"rimraf": "^2.6.2",

@@ -28,5 +40,4 @@ "sinon": "^7.1.1",

"ts-loader": "^5.3.0",
"ts-node": "^7.0.1",
"tslint": "^5.11.0",
"typescript": "^3.1.6"
"ts-node": "^10.2.1",
"typescript": "^4.4.3"
},

@@ -36,11 +47,11 @@ "scripts": {

"example": "node dist/examples/app.js",
"build:tsc": "npm run clear && tsc",
"build:tsc": "yarn run clear && tsc",
"build:example": "rimraf ./example/dist && tsc ./examples/app.ts --outDir ./examples/dist --lib es2015,es6,dom",
"build:all": "npm run build:tsc && npm run build:example",
"build:all": "yarn run build:tsc && yarn run build:example",
"dev": "tsc -w",
"test": "mocha -r ts-node/register tests/**/*.spec.ts",
"test:tdd": "mocha -r ts-node/register tests/**/*.spec.ts --watch-extensions ts --watch",
"lint": "tslint -p .",
"prepush": "npm run lint",
"test:coverage": "nyc npm test",
"test:tdd": "mocha -r ts-node/register tests/**/*.spec.ts --watch --watch-files src/**/*.ts,tests/**/*.ts",
"lint": "eslint '*/**/*.{js,ts}' --quiet --fix",
"prepush": "yarn run lint",
"test:coverage": "nyc yarn test",
"test:report": "nyc report --reporter=text-lcov > coverage.lcov"

@@ -47,0 +58,0 @@ },

@@ -6,3 +6,3 @@ # EasySpotifyTS - A Spotify Web Api TS Wrapper

[![Build Status](https://travis-ci.org/bruno-lombardi/easy-spotify-ts.svg?branch=master)](https://travis-ci.org/bruno-lombardi/easy-spotify-ts)
[![Build Status](https://app.travis-ci.com/bruno-lombardi/easy-spotify-ts.svg?branch=master)](https://app.travis-ci.com/bruno-lombardi/easy-spotify-ts)
[![codecov](https://codecov.io/gh/bruno-lombardi/easy-spotify-ts/branch/master/graph/badge.svg)](https://codecov.io/gh/bruno-lombardi/easy-spotify-ts)

@@ -9,0 +9,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc