mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-04 11:24:44 +00:00
Add ability to star a repository
This commit is contained in:
@@ -95,5 +95,26 @@ namespace Octokit
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> StarRepo(string owner, string repo)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNull(repo, "repo");
|
||||
|
||||
try
|
||||
{
|
||||
var response = await Connection.PutAsync<object>(ApiUrls.Starred(owner, repo), null, null)
|
||||
.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user