Skip to content

Commit e56d70c

Browse files
Jiankai ZhengJiankai Zheng
authored andcommitted
feat(api): api call to delete saved shows
1 parent 31c0934 commit e56d70c

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

src/main/java/spotify/api/impl/LibraryApiRetrofit.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,4 +257,28 @@ public void deleteAlbums(List<String> listOfAlbumIds) {
257257
throw new HttpRequestFailedException(ex.getMessage());
258258
}
259259
}
260+
261+
@Override
262+
public void deleteShows(List<String> listOfShowIds, Map<String, String> options) {
263+
options = ValidatorUtil.optionsValueCheck(options);
264+
265+
String showIds = String.join(",", listOfShowIds);
266+
267+
logger.trace("Constructing HTTP call to delete the saved shows");
268+
Call<Void> httpCall = libraryService.deleteShows("Bearer " + this.accessToken, showIds, options);
269+
270+
try {
271+
logger.info("Executing HTTP call to delete the saved shows.");
272+
logger.debug(String.format("Deleting saved shows with following show ids: %s and parameter values: %s.", showIds, options));
273+
LoggingUtil.logHttpCall(logger, httpCall);
274+
Response<Void> response = httpCall.execute();
275+
276+
ResponseChecker.throwIfRequestHasNotBeenFulfilledCorrectly(response, HttpStatusCode.OK);
277+
278+
logger.info("Saved shows have been successfully deleted");
279+
} catch (IOException ex) {
280+
logger.error("HTTP request to delete saved shows has failed.");
281+
throw new HttpRequestFailedException(ex.getMessage());
282+
}
283+
}
260284
}

src/main/java/spotify/api/interfaces/LibraryApi.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,6 @@ public interface LibraryApi {
2828
void saveTracks(List<String> listOfTrackIds);
2929

3030
void deleteAlbums(List<String> listOfAlbumIds);
31+
32+
void deleteShows(List<String> listOfShowIds, Map<String, String> options);
3133
}

src/main/java/spotify/api/spotify/SpotifyApi.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,10 @@ public void deleteAlbums(List<String> listOfAlbumIds) {
276276
libraryApi.deleteAlbums(listOfAlbumIds);
277277
}
278278

279+
public void deleteShows(List<String> listOfShowIds, Map<String, String> options) {
280+
logger.info("Requesting to delete saved shows");
281+
libraryApi.deleteShows(listOfShowIds, options);
282+
}
279283

280284
private void setup(final String accessToken) {
281285
logger.trace("Constructing Retrofit APIs");

0 commit comments

Comments
 (0)