File tree Expand file tree Collapse file tree 3 files changed +30
-0
lines changed
src/main/java/spotify/api Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -235,4 +235,26 @@ public void saveTracks(List<String> listOfTrackIds) {
235235 throw new HttpRequestFailedException (ex .getMessage ());
236236 }
237237 }
238+
239+ @ Override
240+ public void deleteAlbums (List <String > listOfAlbumIds ) {
241+ String albumIds = String .join ("," , listOfAlbumIds );
242+
243+ logger .trace ("Constructing HTTP call to delete the saved albums" );
244+ Call <Void > httpCall = libraryService .deleteAlbums ("Bearer " + this .accessToken , albumIds );
245+
246+ try {
247+ logger .info ("Executing HTTP call to delete the saved albums." );
248+ logger .debug (String .format ("Deleting saved albums with following album ids: %s." , albumIds ));
249+ LoggingUtil .logHttpCall (logger , httpCall );
250+ Response <Void > response = httpCall .execute ();
251+
252+ ResponseChecker .throwIfRequestHasNotBeenFulfilledCorrectly (response , HttpStatusCode .OK );
253+
254+ logger .info ("Saved albums have been successfully deleted" );
255+ } catch (IOException ex ) {
256+ logger .error ("HTTP request to delete saved albums has failed." );
257+ throw new HttpRequestFailedException (ex .getMessage ());
258+ }
259+ }
238260}
Original file line number Diff line number Diff line change @@ -26,4 +26,6 @@ public interface LibraryApi {
2626 void saveShows (List <String > listOfShowIds );
2727
2828 void saveTracks (List <String > listOfTrackIds );
29+
30+ void deleteAlbums (List <String > listOfAlbumIds );
2931}
Original file line number Diff line number Diff line change @@ -271,6 +271,12 @@ public void saveTracks(List<String> listOfTrackIds) {
271271 libraryApi .saveTracks (listOfTrackIds );
272272 }
273273
274+ public void deleteAlbums (List <String > listOfAlbumIds ) {
275+ logger .info ("Requesting to delete saved albums" );
276+ libraryApi .deleteAlbums (listOfAlbumIds );
277+ }
278+
279+
274280 private void setup (final String accessToken ) {
275281 logger .trace ("Constructing Retrofit APIs" );
276282 this .trackApi = new TrackApiRetrofit (accessToken );
You can’t perform that action at this time.
0 commit comments