Add ability to star a repository

This commit is contained in:
James R Sconfitto
2013-11-07 21:43:58 -05:00
parent 5b804b6ef9
commit 77cbd28194
+21
View File
@@ -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;
}
}
}
}