Skip to content

Commit 64189f3

Browse files
Jiankai ZhengJiankai Zheng
authored andcommitted
feat(api): api call to unfollow playlist
1 parent ac384f1 commit 64189f3

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,24 @@ public void unfollowEntities(EntityType entityType, List<String> listOfEntityIds
167167
throw new HttpRequestFailedException(ex.getMessage());
168168
}
169169
}
170+
171+
@Override
172+
public void unfollowPlaylist(String playlistId) {
173+
logger.trace("Constructing HTTP call to unfollow playlist.");
174+
Call<Void> httpCall = followService.unfollowPlaylist("Bearer " + this.accessToken, playlistId);
175+
176+
try {
177+
logger.info("Executing HTTP call to unfollow playlist.");
178+
logger.debug(String.format("Unfollowing playlist %s ", playlistId));
179+
LoggingUtil.logHttpCall(logger, httpCall);
180+
Response<Void> response = httpCall.execute();
181+
182+
ResponseChecker.throwIfRequestHasNotBeenFulfilledCorrectly(response.errorBody());
183+
184+
logger.info("Playlist has been successfully unfollowed.");
185+
} catch (IOException ex) {
186+
logger.error("HTTP request to unfollow playlist has failed.");
187+
throw new HttpRequestFailedException(ex.getMessage());
188+
}
189+
}
170190
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ public interface FollowApi {
1919

2020
void unfollowEntities(EntityType entityType, List<String> listOfEntityIds);
2121

22+
void unfollowPlaylist(String playlistId);
2223
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@ public void unfollowEntities(EntityType entityType, List<String> listOfEntityIds
217217
followApi.unfollowEntities(entityType, listOfEntityIds);
218218
}
219219

220+
public void unfollowPlaylist(String playlistId) {
221+
logger.info("Requesting to unfollow playlist");
222+
followApi.unfollowPlaylist(playlistId);
223+
}
224+
220225
private void setup(String accessToken) {
221226
logger.trace("Constructing Retrofit APIs");
222227
this.trackApi = new TrackApiRetrofit(accessToken);

0 commit comments

Comments
 (0)