From a8e47d323f992a05de50a3c072ffba6f246c71fe Mon Sep 17 00:00:00 2001 From: James R Sconfitto Date: Fri, 8 Nov 2013 18:35:41 -0500 Subject: [PATCH] Code review fixes * Add all `StarredClient` methods to the interface * Add xml doc comments * Correct parameter names --- Octokit/Clients/IStarredClient.cs | 59 +++++++++++++++++++++++++++++-- Octokit/Clients/StarredClient.cs | 54 ++++++++++++++++++++-------- 2 files changed, 95 insertions(+), 18 deletions(-) diff --git a/Octokit/Clients/IStarredClient.cs b/Octokit/Clients/IStarredClient.cs index 5539ea6e..d2c7c646 100644 --- a/Octokit/Clients/IStarredClient.cs +++ b/Octokit/Clients/IStarredClient.cs @@ -6,16 +6,69 @@ namespace Octokit interface IStarredClient { /// - /// Retrieves all of the starred (ies) for the authenticated user. + /// Retrieves all of the stargazers for the passed repository. + /// + /// The owner of the repository + /// The name of the repository + /// Thrown if the client is not authenticated. + /// A of . + Task> GetAllStargazers(string owner, string name); + + /// + /// Retrieves all of the starred (ies) for the current user. /// /// Thrown if the client is not authenticated. /// A of . Task> GetAllForCurrent(); /// - /// Retrieves all of the (ies) starred by the passed user. + /// Retrieves all of the starred (ies) for the current user. /// - /// A of . + /// Star-specific request parameters that sort the results + /// Thrown if the client is not authenticated. + /// A of . + Task> GetAllForCurrent(StarredRequest request); + + /// + /// Retrieves all of the (ies) starred by the specified user. + /// + /// The login of the user + /// Thrown if the client is not authenticated. + /// A starred by the specified user. Task> GetAllForUser(string user); + + /// + /// Retrieves all of the (ies) starred by the specified user. + /// + /// The login of the user + /// Star-specific request parameters that sort the results + /// Thrown if the client is not authenticated. + /// A starred by the specified user. + Task> GetAllForUser(string user, StarredRequest request); + + /// + /// Check if a repository is starred by the current authenticated user. + /// + /// The owner of the repository + /// The name of the repository + /// Thrown if the client is not authenticated. + /// A bool representing the success of the operation + Task CheckStarred(string owner, string name); + + /// + /// Stars a repository for the authenticated user. + /// + /// The owner of the repository to star + /// The name of the repository to star + /// A bool representing the success of starring + Task StarRepo(string owner, string name); + + /// + /// Unstars a repository for the authenticated user. + /// + /// The owner of the repository to unstar + /// The name of the repository to unstar + /// A bool representing the success of the operation + Task RemoveStarFromRepo(string owner, string name); } } diff --git a/Octokit/Clients/StarredClient.cs b/Octokit/Clients/StarredClient.cs index 6e24af1f..cedb2cc8 100644 --- a/Octokit/Clients/StarredClient.cs +++ b/Octokit/Clients/StarredClient.cs @@ -14,11 +14,16 @@ namespace Octokit /// /// Retrieves all of the stargazers for the passed repository. /// + /// The owner of the repository + /// The name of the repository /// Thrown if the client is not authenticated. /// A of . - public Task> GetAllStargazers(string owner, string repo) + public Task> GetAllStargazers(string owner, string name) { - return ApiConnection.GetAll(ApiUrls.Stargazers(owner, repo)); + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return ApiConnection.GetAll(ApiUrls.Stargazers(owner, name)); } /// @@ -34,7 +39,7 @@ namespace Octokit /// /// Retrieves all of the starred (ies) for the current user. /// - /// Star-specific request parameters that sort the resulting stars + /// Star-specific request parameters that sort the results /// Thrown if the client is not authenticated. /// A of . [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters", @@ -49,6 +54,8 @@ namespace Octokit /// /// Retrieves all of the (ies) starred by the specified user. /// + /// The login of the user + /// Thrown if the client is not authenticated. /// A starred by the specified user. public Task> GetAllForUser(string user) { @@ -60,6 +67,9 @@ namespace Octokit /// /// Retrieves all of the (ies) starred by the specified user. /// + /// The login of the user + /// Star-specific request parameters that sort the results + /// Thrown if the client is not authenticated. /// A starred by the specified user. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] public Task> GetAllForUser(string user, StarredRequest request) @@ -71,18 +81,20 @@ namespace Octokit } /// - /// Check if a repository is starred by the current authenticated user + /// Check if a repository is starred by the current authenticated user. /// /// The owner of the repository - /// The name of the repository - public async Task CheckStarred(string owner, string repo) + /// The name of the repository + /// Thrown if the client is not authenticated. + /// A bool representing the success of the operation + public async Task CheckStarred(string owner, string name) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNull(repo, "repo"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); try { - var response = await Connection.GetAsync(ApiUrls.Starred(owner, repo), null, null) + var response = await Connection.GetAsync(ApiUrls.Starred(owner, name), null, null) .ConfigureAwait(false); if (response.StatusCode != HttpStatusCode.NotFound && response.StatusCode != HttpStatusCode.NoContent) { @@ -96,14 +108,20 @@ namespace Octokit } } - public async Task StarRepo(string owner, string repo) + /// + /// Stars a repository for the authenticated user. + /// + /// The owner of the repository to star + /// The name of the repository to star + /// A bool representing the success of starring the repository. + public async Task StarRepo(string owner, string name) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNull(repo, "repo"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); try { - var response = await Connection.PutAsync(ApiUrls.Starred(owner, repo), null, null) + var response = await Connection.PutAsync(ApiUrls.Starred(owner, name), null, null) .ConfigureAwait(false); if (response.StatusCode != HttpStatusCode.NotFound && response.StatusCode != HttpStatusCode.NoContent) { @@ -117,14 +135,20 @@ namespace Octokit } } - public async Task RemoveStarFromRepo(string owner, string repo) + /// + /// Unstars a repository for the authenticated user. + /// + /// The owner of the repository to unstar + /// The name of the repository to unstar + /// A bool representing the success of unstarring the repository. + public async Task RemoveStarFromRepo(string owner, string name) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNull(repo, "repo"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); try { - var response = await Connection.DeleteAsync(ApiUrls.Starred(owner, repo)) + var response = await Connection.DeleteAsync(ApiUrls.Starred(owner, name)) .ConfigureAwait(false); if (response.StatusCode != HttpStatusCode.NotFound && response.StatusCode != HttpStatusCode.NoContent) @@ -135,7 +159,7 @@ namespace Octokit } catch (NotFoundException) { - return false ; + return false; } } }