@spotify/web-api-ts-sdk
Version:
A typescript SDK for the Spotify Web API
146 lines • 5.39 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const EndpointsBase_js_1 = __importDefault(require("./EndpointsBase.js"));
class CurrentUserEndpoints extends EndpointsBase_js_1.default {
albums;
audiobooks;
episodes;
playlists;
shows;
tracks;
constructor(api) {
super(api);
this.albums = new CurrentUserAlbumsEndpoints(api);
this.audiobooks = new CurrentUserAudiobooksEndpoints(api);
this.episodes = new CurrentUserEpisodesEndpoints(api);
this.playlists = new CurrentUserPlaylistsEndpoints(api);
this.shows = new CurrentUserShowsEndpoints(api);
this.tracks = new CurrentUserTracksEndpoints(api);
}
profile() {
return this.getRequest('me');
}
topItems(type, time_range, limit, offset) {
const params = this.paramsFor({ time_range, limit, offset });
return this.getRequest(`me/top/${type}${params}`);
}
followedArtists(after, limit) {
const params = this.paramsFor({ type: "artist", after, limit });
return this.getRequest(`me/following${params}`);
}
async followArtistsOrUsers(ids, type) {
const params = this.paramsFor({ type });
await this.putRequest(`me/following${params}`, { ids });
}
async unfollowArtistsOrUsers(ids, type) {
const params = this.paramsFor({ type });
await this.deleteRequest(`me/following${params}`, { ids });
}
followsArtistsOrUsers(ids, type) {
const params = this.paramsFor({ ids, type });
return this.getRequest(`me/following/contains${params}`);
}
}
exports.default = CurrentUserEndpoints;
class CurrentUserAlbumsEndpoints extends EndpointsBase_js_1.default {
savedAlbums(limit, offset, market) {
const params = this.paramsFor({ limit, offset, market });
return this.getRequest(`me/albums${params}`);
}
async saveAlbums(ids) {
await this.putRequest('me/albums', ids);
}
async removeSavedAlbums(ids) {
await this.deleteRequest('me/albums', ids);
}
hasSavedAlbums(ids) {
const params = this.paramsFor({ ids });
return this.getRequest(`me/albums/contains${params}`);
}
}
class CurrentUserAudiobooksEndpoints extends EndpointsBase_js_1.default {
savedAudiobooks(limit, offset) {
const params = this.paramsFor({ limit, offset });
return this.getRequest(`me/audiobooks${params}`);
}
async saveAudiobooks(ids) {
await this.putRequest('me/audiobooks', ids);
}
async removeSavedAudiobooks(ids) {
await this.deleteRequest('me/audiobooks', ids);
}
hasSavedAudiobooks(ids) {
const params = this.paramsFor({ ids });
return this.getRequest(`me/audiobooks/contains${params}`);
}
}
class CurrentUserEpisodesEndpoints extends EndpointsBase_js_1.default {
savedEpisodes(market, limit, offset) {
const params = this.paramsFor({ market, limit, offset });
return this.getRequest(`me/episodes${params}`);
}
async saveEpisodes(ids) {
await this.putRequest(`me/episodes`, ids);
}
async removeSavedEpisodes(ids) {
await this.deleteRequest(`me/episodes`, ids);
}
hasSavedEpisodes(ids) {
const params = this.paramsFor({ ids });
return this.getRequest(`me/episodes/contains${params}`);
}
}
class CurrentUserPlaylistsEndpoints extends EndpointsBase_js_1.default {
playlists(limit, offset) {
const params = this.paramsFor({ limit, offset });
return this.getRequest(`me/playlists${params}`);
}
async follow(playlist_id) {
await this.putRequest(`playlists/${playlist_id}/followers`);
}
async unfollow(playlist_id) {
await this.deleteRequest(`playlists/${playlist_id}/followers`);
}
isFollowing(playlistId, ids) {
const params = this.paramsFor({ ids });
return this.getRequest(`playlists/${playlistId}/followers/contains${params}`);
}
}
class CurrentUserShowsEndpoints extends EndpointsBase_js_1.default {
savedShows(limit, offset) {
const params = this.paramsFor({ limit, offset });
return this.getRequest(`me/shows${params}`);
}
saveShows(ids) {
const params = this.paramsFor({ ids });
return this.putRequest(`me/shows${params}`);
}
removeSavedShows(ids, market) {
const params = this.paramsFor({ ids, market });
return this.deleteRequest(`me/shows${params}`);
}
hasSavedShow(ids) {
const params = this.paramsFor({ ids });
return this.getRequest(`me/shows/contains${params}`);
}
}
class CurrentUserTracksEndpoints extends EndpointsBase_js_1.default {
savedTracks(limit, offset, market) {
const params = this.paramsFor({ limit, offset, market });
return this.getRequest(`me/tracks${params}`);
}
async saveTracks(ids) {
await this.putRequest('me/tracks', ids);
}
async removeSavedTracks(ids) {
await this.deleteRequest('me/tracks', ids);
}
hasSavedTracks(ids) {
const params = this.paramsFor({ ids });
return this.getRequest(`me/tracks/contains${params}`);
}
}
//# sourceMappingURL=CurrentUserEndpoints.js.map
;