Socket
Socket
Sign inDemoInstall

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.0 to 0.2.1

50

dist/EasySpotify.d.ts

@@ -1,13 +0,9 @@

import { AxiosInstance, AxiosPromise, AxiosRequestConfig } from "axios";
import { AxiosInstance, AxiosRequestConfig } from "axios";
import EasySpotifyConfig from "./EasySpotifyConfig";
import { Album, FeaturedAlbums } from "./models/Album";
import { Artist } from "./models/Artist";
import { PagingAlbums, PagingArtists, PagingPlaylists, PagingTracks, PagingSearch, PagingCategories } from "./models/Paging";
import { Track } from "./models/Track";
import { Category } from './models/Category';
import { FeaturedPlaylists } from "./models/Playlist";
import { RecommendationsQuery, Recommendations } from "./models/Recomendations";
export interface OptionalRequestParams {
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;

@@ -25,2 +21,14 @@ }

}
export interface CreatePlaylistParams {
name: string;
public?: boolean;
collaborative?: boolean;
description?: string;
}
export interface UpdatePlaylistParams {
name?: string;
public?: boolean;
collaborative?: boolean;
description?: string;
}
export default class EasySpotify {

@@ -53,11 +61,7 @@ config: EasySpotifyConfig;

country?: string;
limit?: number;
offset?: number;
}): Promise<PagingPlaylists>;
} & PagingRequestParams): Promise<PagingPlaylists>;
getBrowseListOfCategories(options: {
locale?: string;
country?: string;
offset?: number;
limit?: number;
}): Promise<PagingCategories>;
} & PagingRequestParams): Promise<PagingCategories>;
getBrowseFeaturedPlaylists(options: {

@@ -67,13 +71,15 @@ locale?: string;

timestamp?: Date;
limit?: number;
offset?: number;
}): Promise<FeaturedPlaylists>;
} & PagingRequestParams): Promise<FeaturedPlaylists>;
getBrowseNewReleases(options: {
country?: string;
limit?: number;
offset?: number;
}): Promise<FeaturedAlbums>;
} & PagingRequestParams): Promise<FeaturedAlbums>;
getBrowseRecommendations(query: RecommendationsQuery): Promise<Recommendations>;
buildRequest(endpoint: string, params?: AxiosRequestConfig["params"], method?: string): AxiosPromise<any>;
getPlaylists(userId?: string, options?: PagingRequestParams): Promise<PagingPlaylists>;
createPlaylist(userId: string, params: CreatePlaylistParams): Promise<SimplifiedPlaylist>;
updatePlaylistDetails(playlistId: string, params: UpdatePlaylistParams): Promise<void>;
replacePlaylistTracks(playlistId: string, uris: string[]): Promise<void>;
unfollowPlaylist(playlistId: string): Promise<void>;
getUserProfile(userId?: string): Promise<User>;
buildRequest(endpoint: string, params?: AxiosRequestConfig["params"], method?: string): Promise<any>;
private buildHeaders;
}

@@ -50,6 +50,3 @@ "use strict";

var axios_1 = require("axios");
var Album_1 = require("./models/Album");
var Artist_1 = require("./models/Artist");
var Track_1 = require("./models/Track");
var Category_1 = require("./models/Category");
var models_1 = require("./models");
var EasySpotify = /** @class */ (function () {

@@ -89,3 +86,3 @@ function EasySpotify(config) {

if (response.data) {
return [2 /*return*/, new Album_1.Album(response.data)];
return [2 /*return*/, new models_1.Album(response.data)];
}

@@ -116,3 +113,3 @@ else {

albums = response.data.albums.map(function (album) {
return new Album_1.Album(album);
return new models_1.Album(album);
});

@@ -192,3 +189,3 @@ return [2 /*return*/, albums];

artists = response.data.artists.map(function (artist) {
return new Artist_1.Artist(artist);
return new models_1.Artist(artist);
});

@@ -246,3 +243,3 @@ return [2 /*return*/, artists];

tracks = response.data.tracks.map(function (track) {
return new Track_1.Track(track);
return new models_1.Track(track);
});

@@ -275,3 +272,3 @@ return [2 /*return*/, tracks];

artists = response.data.artists.map(function (artist) {
return new Artist_1.Artist(artist);
return new models_1.Artist(artist);
});

@@ -414,3 +411,3 @@ return [2 /*return*/, artists];

if (response.data) {
return [2 /*return*/, new Category_1.Category(response.data)];
return [2 /*return*/, new models_1.Category(response.data)];
}

@@ -572,13 +569,162 @@ else {

};
EasySpotify.prototype.getPlaylists = function (userId, options) {
return __awaiter(this, void 0, void 0, function () {
var endpoint, response, err_20;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
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*/];
}
});
});
};
EasySpotify.prototype.createPlaylist = function (userId, params) {
return __awaiter(this, void 0, void 0, function () {
var response, err_21;
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 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*/];
}
});
});
};
EasySpotify.prototype.updatePlaylistDetails = function (playlistId, params) {
return __awaiter(this, void 0, void 0, function () {
var err_22;
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 1:
_a.sent();
return [3 /*break*/, 3];
case 2:
err_22 = _a.sent();
throw err_22;
case 3: return [2 /*return*/];
}
});
});
};
EasySpotify.prototype.replacePlaylistTracks = function (playlistId, uris) {
return __awaiter(this, void 0, void 0, function () {
var err_23;
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 1:
_a.sent();
return [3 /*break*/, 3];
case 2:
err_23 = _a.sent();
throw err_23;
case 3: return [2 /*return*/];
}
});
});
};
EasySpotify.prototype.unfollowPlaylist = function (playlistId) {
return __awaiter(this, void 0, void 0, function () {
var err_24;
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 1:
_a.sent();
return [3 /*break*/, 3];
case 2:
err_24 = _a.sent();
throw err_24;
case 3: return [2 /*return*/];
}
});
});
};
EasySpotify.prototype.getUserProfile = function (userId) {
return __awaiter(this, void 0, void 0, function () {
var endpoint, response, err_25;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
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_25 = _a.sent();
throw err_25;
case 3: return [2 /*return*/];
}
});
});
};
EasySpotify.prototype.buildRequest = function (endpoint, params, method) {
var _this = this;
if (method === void 0) { method = "get"; }
return this.httpClient({
headers: this.buildHeaders(),
method: method,
params: params,
url: this.getApiUrl() + "/" + endpoint,
return new Promise(function (resolve, reject) {
var _a;
try {
var paramsKey = ["put", "post", "patch"].some(function (m) { return m === method.toLowerCase(); }) ? "data" : "params";
_this.httpClient((_a = {
headers: _this.buildHeaders(),
method: method
},
_a[paramsKey] = params,
_a.url = _this.getApiUrl() + "/" + endpoint,
_a)).then(resolve, function (e) {
var retryAfter = (e.response && e.response.headers) && e.response.headers["retry-after"];
if (retryAfter) {
setTimeout(function () {
_this.buildRequest(endpoint, params, method).then(resolve, reject);
}, (retryAfter + 1) * 1000);
}
else {
reject(e);
}
});
}
catch (e) {
reject(e);
}
});
};
EasySpotify.prototype.buildHeaders = function () {
return { Authorization: "Bearer " + this.config.token };
return {
"Authorization": "Bearer " + this.config.token,
"Content-Type": "application/json",
};
};

@@ -585,0 +731,0 @@ return EasySpotify;

@@ -0,0 +0,0 @@ export default class EasySpotifyConfig {

@@ -0,0 +0,0 @@ "use strict";

import EasySpotify from "./EasySpotify";
import EasySpotifyConfig from "./EasySpotifyConfig";
export { EasySpotify, EasySpotifyConfig };

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { SimplifiedArtist } from "./Artist";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { ExternalUrls } from "./ExternalUrls";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { Image } from './Image';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ export interface Copyright {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export interface ExternalIDS {
upc: string;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export interface ExternalUrls {
spotify: string;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

@@ -0,0 +0,0 @@ export interface Followers {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

@@ -0,0 +0,0 @@ export interface Image {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

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

import { Album } from "./Album";
import { Album, FeaturedAlbums, SimplifiedAlbum } from "./Album";
import { Artist, SimplifiedArtist } from "./Artist";
import { Category } from "./Category";
import { Copyright } from "./Copyright";

@@ -8,4 +9,8 @@ import { ExternalIDS } from "./ExternalIDS";

import { Image } from "./Image";
import { Paging, PagingTracks } from "./Paging";
import { Paging, PagingAlbums, PagingArtists, PagingCategories, PagingPlaylists, PagingSearch, PagingTracks } from "./Paging";
import { FeaturedPlaylists, SimplifiedPlaylist } from "./Playlist";
import { Recommendations, RecommendationsQuery } from "./Recomendations";
import { SimplifiedTrack } from "./SimplifiedTrack";
export { Album, Artist, SimplifiedArtist, Copyright, ExternalIDS, ExternalUrls, Followers, Image, Paging, PagingTracks, 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, };

@@ -7,1 +7,7 @@ "use strict";

exports.Artist = Artist_1.Artist;
var Category_1 = require("./Category");
exports.Category = Category_1.Category;
var Recomendations_1 = require("./Recomendations");
exports.Recommendations = Recomendations_1.Recommendations;
var Track_1 = require("./Track");
exports.Track = Track_1.Track;
import { SimplifiedAlbum } from "./Album";
import { SimplifiedArtist } from "./Artist";
import { Category } from "./Category";
import { SimplifiedPlaylist } from "./Playlist";
import { SimplifiedTrack } from "./SimplifiedTrack";
import { Category } from "./Category";
export interface Paging {

@@ -7,0 +7,0 @@ href: string;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
import { ExternalUrls } from "./ExternalUrls";
import { Image } from "./Image";
import { PagingPlaylists } from "./Paging";
import { User } from "./User";
import { PagingPlaylists } from "./Paging";
export interface FeaturedPlaylists {

@@ -21,4 +21,5 @@ message: string;

tracks: Tracks;
type: string;
type: "playlist";
uri: string;
description: string;
}

@@ -25,0 +26,0 @@ interface Tracks {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

@@ -0,0 +0,0 @@ import { SimplifiedTrack } from ".";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { SimplifiedArtist } from "./Artist";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

@@ -0,0 +0,0 @@ import { SimplifiedAlbum } from "./Album";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { ExternalUrls } from "./ExternalUrls";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

@@ -0,0 +0,0 @@ MIT License

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

@@ -5,0 +5,0 @@ "main": "dist/index.js",

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

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