Skip to content

Commit

Permalink
Switch more checks to the 200-299 success checks
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyCrazy committed Oct 12, 2024
1 parent f7ba9c6 commit acb8b98
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions SpotifyAPI.Web/Clients/FollowClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public async Task<bool> FollowPlaylist(string playlistId, CancellationToken canc
var statusCode = await API
.Put(URLs.PlaylistFollowers(playlistId), null, null, cancel)
.ConfigureAwait(false);
return statusCode == HttpStatusCode.OK;
return HTTPUtil.StatusCodeIsSuccess(statusCode);
}

public async Task<bool> FollowPlaylist(string playlistId, FollowPlaylistRequest request, CancellationToken cancel = default)
Expand All @@ -54,7 +54,7 @@ public async Task<bool> FollowPlaylist(string playlistId, FollowPlaylistRequest
var statusCode = await API
.Put(URLs.PlaylistFollowers(playlistId), null, request.BuildBodyParams(), cancel)
.ConfigureAwait(false);
return statusCode == HttpStatusCode.OK;
return HTTPUtil.StatusCodeIsSuccess(statusCode);
}

public Task<FollowedArtistsResponse> OfCurrentUser(CancellationToken cancel = default)
Expand Down Expand Up @@ -88,7 +88,7 @@ public async Task<bool> UnfollowPlaylist(string playlistId, CancellationToken ca
var statusCode = await API
.Delete(URLs.PlaylistFollowers(playlistId), null, null, cancel)
.ConfigureAwait(false);
return statusCode == HttpStatusCode.OK;
return HTTPUtil.StatusCodeIsSuccess(statusCode);
}
}
}
20 changes: 10 additions & 10 deletions SpotifyAPI.Web/Clients/LibraryClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,79 +98,79 @@ public async Task<bool> RemoveAlbums(LibraryRemoveAlbumsRequest request, Cancell
Ensure.ArgumentNotNull(request, nameof(request));

var statusCode = await API.Delete(SpotifyUrls.LibraryAlbums(), request.BuildQueryParams(), null, cancel).ConfigureAwait(false);
return statusCode == HttpStatusCode.OK;
return HTTPUtil.StatusCodeIsSuccess(statusCode);
}

public async Task<bool> RemoveShows(LibraryRemoveShowsRequest request, CancellationToken cancel = default)
{
Ensure.ArgumentNotNull(request, nameof(request));

var statusCode = await API.Delete(SpotifyUrls.LibraryShows(), request.BuildQueryParams(), null, cancel).ConfigureAwait(false);
return statusCode == HttpStatusCode.OK;
return HTTPUtil.StatusCodeIsSuccess(statusCode);
}

public async Task<bool> RemoveTracks(LibraryRemoveTracksRequest request, CancellationToken cancel = default)
{
Ensure.ArgumentNotNull(request, nameof(request));

var statusCode = await API.Delete(SpotifyUrls.LibraryTracks(), request.BuildQueryParams(), null, cancel).ConfigureAwait(false);
return statusCode == HttpStatusCode.OK;
return HTTPUtil.StatusCodeIsSuccess(statusCode);
}

public async Task<bool> RemoveEpisodes(LibraryRemoveEpisodesRequest request, CancellationToken cancel = default)
{
Ensure.ArgumentNotNull(request, nameof(request));

var statusCode = await API.Delete(SpotifyUrls.LibraryEpisodes(), request.BuildQueryParams(), null, cancel).ConfigureAwait(false);
return statusCode == HttpStatusCode.OK;
return HTTPUtil.StatusCodeIsSuccess(statusCode);
}

public async Task<bool> SaveAlbums(LibrarySaveAlbumsRequest request, CancellationToken cancel = default)
{
Ensure.ArgumentNotNull(request, nameof(request));

var statusCode = await API.Put(SpotifyUrls.LibraryAlbums(), request.BuildQueryParams(), null, cancel).ConfigureAwait(false);
return statusCode == HttpStatusCode.OK;
return HTTPUtil.StatusCodeIsSuccess(statusCode);
}

public async Task<bool> SaveShows(LibrarySaveShowsRequest request, CancellationToken cancel = default)
{
Ensure.ArgumentNotNull(request, nameof(request));

var statusCode = await API.Put(SpotifyUrls.LibraryShows(), request.BuildQueryParams(), null, cancel).ConfigureAwait(false);
return statusCode == HttpStatusCode.OK;
return HTTPUtil.StatusCodeIsSuccess(statusCode);
}

public async Task<bool> SaveTracks(LibrarySaveTracksRequest request, CancellationToken cancel = default)
{
Ensure.ArgumentNotNull(request, nameof(request));

var statusCode = await API.Put(SpotifyUrls.LibraryTracks(), request.BuildQueryParams(), null, cancel).ConfigureAwait(false);
return statusCode == HttpStatusCode.OK;
return HTTPUtil.StatusCodeIsSuccess(statusCode);
}

public async Task<bool> SaveEpisodes(LibrarySaveEpisodesRequest request, CancellationToken cancel = default)
{
Ensure.ArgumentNotNull(request, nameof(request));

var statusCode = await API.Put(SpotifyUrls.LibraryEpisodes(), request.BuildQueryParams(), null, cancel).ConfigureAwait(false);
return statusCode == HttpStatusCode.OK;
return HTTPUtil.StatusCodeIsSuccess(statusCode);
}

public async Task<bool> SaveAudiobooks(LibrarySaveAudiobooksRequest request, CancellationToken cancel = default)
{
Ensure.ArgumentNotNull(request, nameof(request));

var statusCode = await API.Put(SpotifyUrls.LibraryAudiobooks(), request.BuildQueryParams(), null, cancel).ConfigureAwait(false);
return statusCode == HttpStatusCode.OK;
return HTTPUtil.StatusCodeIsSuccess(statusCode);
}

public async Task<bool> RemoveAudiobooks(LibraryRemoveAudiobooksRequest request, CancellationToken cancel = default)
{
Ensure.ArgumentNotNull(request, nameof(request));

var statusCode = await API.Delete(SpotifyUrls.LibraryAudiobooks(), request.BuildQueryParams(), null, cancel).ConfigureAwait(false);
return statusCode == HttpStatusCode.OK;
return HTTPUtil.StatusCodeIsSuccess(statusCode);
}

public Task<List<bool>> CheckAudiobooks(LibraryCheckAudiobooksRequest request, CancellationToken cancel = default)
Expand Down
2 changes: 1 addition & 1 deletion SpotifyAPI.Web/Clients/PlaylistsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public async Task<bool> ChangeDetails(string playlistId, PlaylistChangeDetailsRe
Ensure.ArgumentNotNull(request, nameof(request));

var statusCode = await API.Put(URLs.Playlist(playlistId), null, request.BuildBodyParams(), cancel).ConfigureAwait(false);
return statusCode == HttpStatusCode.OK;
return HTTPUtil.StatusCodeIsSuccess(statusCode);
}

public Task<SnapshotResponse> ReorderItems(string playlistId, PlaylistReorderItemsRequest request, CancellationToken cancel = default)
Expand Down

0 comments on commit acb8b98

Please sign in to comment.