diff --git a/src/apis/LibraryApi.spec.ts b/src/apis/LibraryApi.spec.ts index a0bca65..890500e 100644 --- a/src/apis/LibraryApi.spec.ts +++ b/src/apis/LibraryApi.spec.ts @@ -330,6 +330,20 @@ describe('LibraryApi', () => { }); }); + describe('saveAlbum', () => { + it('should save an album for the current user', async () => { + const { httpMock, library } = setup(); + + await library.saveAlbum('foo'); + + expect(httpMock.put).toBeCalledWith('/me/albums', { + data: { + ids: ['foo'], + }, + }); + }); + }); + describe('saveAlbums', () => { it('should save albums for the current user', async () => { const { httpMock, library } = setup(); @@ -344,6 +358,20 @@ describe('LibraryApi', () => { }); }); + describe('saveShow', () => { + it('should save a show for the current user', async () => { + const { httpMock, library } = setup(); + + await library.saveShow('foo'); + + expect(httpMock.put).toBeCalledWith('/me/shows', { + params: { + ids: ['foo'], + }, + }); + }); + }); + describe('saveShows', () => { it('should save shows for the current user', async () => { const { httpMock, library } = setup(); @@ -358,6 +386,20 @@ describe('LibraryApi', () => { }); }); + describe('saveTrack', () => { + it('should save a track for the current user', async () => { + const { httpMock, library } = setup(); + + await library.saveTrack('foo'); + + expect(httpMock.put).toBeCalledWith('/me/tracks', { + data: { + ids: ['foo'], + }, + }); + }); + }); + describe('saveTracks', () => { it('should save tracks for the current user', async () => { const { httpMock, library } = setup(); diff --git a/src/apis/LibraryApi.ts b/src/apis/LibraryApi.ts index d243bc5..dc6f0c0 100644 --- a/src/apis/LibraryApi.ts +++ b/src/apis/LibraryApi.ts @@ -234,6 +234,17 @@ export class LibraryApi { }); } + /** + * Save Album for the Current User + * + * Save an album to the current user's library. + * + * @param albumId The Spotify ID of the album. + */ + saveAlbum(albumId: string): Promise { + return this.saveAlbums([albumId]); + } + /** * Save Albums for the Current User * @@ -249,10 +260,21 @@ export class LibraryApi { }); } + /** + * Save Show for the Current User + * + * Save a show to the current user's library. + * + * @param showId The Spotify ID of the show. + */ + saveShow(showId: string): Promise { + return this.saveShows([showId]); + } + /** * Save Shows for the Current User * - * Save one or more albums to the current user's library. + * Save one or more shows to the current user's library. * * @param showIds The Spotify IDs of the shows. */ @@ -264,6 +286,17 @@ export class LibraryApi { }); } + /** + * Save Track for the Current User + * + * Save a track to the current user's library. + * + * @param trackId The Spotify ID of the track. + */ + saveTrack(trackId: string): Promise { + return this.saveTracks([trackId]); + } + /** * Save Tracks for the Current User *