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:
James R Sconfitto
2013-11-08 07:51:51 -05:00
parent 77cbd28194
commit ff136ee824
3 changed files with 24 additions and 2 deletions
+22
View File
@@ -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 ;
}
}
}
}
+1 -1
View File
@@ -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");
+1 -1
View File
@@ -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; }