mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-03 19:11:30 +00:00
Add ability to stop starring a repository
Change the `DeleteAsync` method to return `Task<IResponse<object>>` in order to check the status code
This commit is contained in:
@@ -116,5 +116,27 @@ namespace Octokit
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> RemoveStarFromRepo(string owner, string repo)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNull(repo, "repo");
|
||||
|
||||
try
|
||||
{
|
||||
var response = await Connection.DeleteAsync(ApiUrls.Starred(owner, repo))
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (response.StatusCode != HttpStatusCode.NotFound && response.StatusCode != HttpStatusCode.NoContent)
|
||||
{
|
||||
throw new ApiException("Invalid Status Code returned. Expected a 204 or a 404", response.StatusCode);
|
||||
}
|
||||
return response.StatusCode == HttpStatusCode.NoContent;
|
||||
}
|
||||
catch (NotFoundException)
|
||||
{
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ namespace Octokit
|
||||
return Run<T>(request);
|
||||
}
|
||||
|
||||
public Task DeleteAsync(Uri uri)
|
||||
public Task<IResponse<object>> DeleteAsync(Uri uri)
|
||||
{
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Octokit
|
||||
Task<IResponse<T>> PutAsync<T>(Uri uri, object body);
|
||||
Task<IResponse<T>> PutAsync<T>(Uri uri, object body, string twoFactorAuthenticationCode);
|
||||
|
||||
Task DeleteAsync(Uri uri);
|
||||
Task<IResponse<object>> DeleteAsync(Uri uri);
|
||||
|
||||
Uri BaseAddress { get; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user