From 06fdace3b417572311db6b5de43a41703726cb07 Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Fri, 27 May 2016 15:17:56 +0200 Subject: [PATCH] create classes for standalone reaction client and CommitCommentReaction --- Octokit/Clients/IReactionCommitComment.cs | 29 ++++++++++++++ Octokit/Clients/ReactionCommitComment.cs | 49 +++++++++++++++++++++++ Octokit/Clients/ReactionsClient.cs | 17 ++++++++ Octokit/GitHubClient.cs | 9 +++++ Octokit/IGitHubClient.cs | 8 ++++ Octokit/IReactionsClient.cs | 19 +++++++++ Octokit/Octokit-Mono.csproj | 4 ++ Octokit/Octokit-MonoAndroid.csproj | 4 ++ Octokit/Octokit-Monotouch.csproj | 4 ++ Octokit/Octokit-Portable.csproj | 6 ++- Octokit/Octokit-netcore45.csproj | 6 ++- Octokit/Octokit.csproj | 4 ++ 12 files changed, 157 insertions(+), 2 deletions(-) create mode 100644 Octokit/Clients/IReactionCommitComment.cs create mode 100644 Octokit/Clients/ReactionCommitComment.cs create mode 100644 Octokit/Clients/ReactionsClient.cs create mode 100644 Octokit/IReactionsClient.cs diff --git a/Octokit/Clients/IReactionCommitComment.cs b/Octokit/Clients/IReactionCommitComment.cs new file mode 100644 index 00000000..a6db7cc3 --- /dev/null +++ b/Octokit/Clients/IReactionCommitComment.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit +{ + public interface ICommitCommentReaction + { + /// + /// Creates a reaction for an specified Commit Comment + /// + /// http://developer.github.com/v3/repos/comments/#create-reaction-for-a-commit-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// The reaction for + /// + Task CreateReaction(string owner, string name, int number, NewReaction reaction); + + /// + /// List reactions for a specified Commit Comment + /// + /// http://developer.github.com/v3/repos/comments/#list-reaction-for-a-commit-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// + Task> ListReactions(string owner, string name, int number); + } +} diff --git a/Octokit/Clients/ReactionCommitComment.cs b/Octokit/Clients/ReactionCommitComment.cs new file mode 100644 index 00000000..11162ae2 --- /dev/null +++ b/Octokit/Clients/ReactionCommitComment.cs @@ -0,0 +1,49 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit +{ + public class CommitCommentReaction : ApiClient, ICommitCommentReaction + { + public CommitCommentReaction(IApiConnection apiConnection) + : base(apiConnection) + { + } + + /// + /// Creates a reaction for a specified Commit Comment + /// + /// http://developer.github.com/v3/repos/comments/#create-reaction-for-a-commit-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// The reaction for + /// + public Task CreateReaction(string owner, string name, int number, NewReaction reaction) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(reaction, "reaction"); + + return ApiConnection.Post(ApiUrls.CommitCommentReaction(owner, name, number), reaction, AcceptHeaders.ReactionsPreview); + } + + /// + /// List reactions for a specified Commit Comment + /// + /// http://developer.github.com/v3/repos/comments/#create-reaction-for-a-commit-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// The reaction for + /// + public Task> ListReactions(string owner, string name, int number, NewReaction reaction) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(reaction, "reaction"); + + return ApiConnection.Get(ApiUrls.CommitCommentReaction(owner, name, number),"", AcceptHeaders.ReactionsPreview); + } + } +} diff --git a/Octokit/Clients/ReactionsClient.cs b/Octokit/Clients/ReactionsClient.cs new file mode 100644 index 00000000..0c887deb --- /dev/null +++ b/Octokit/Clients/ReactionsClient.cs @@ -0,0 +1,17 @@ +namespace Octokit +{ + public class ReactionsClient : ApiClient, IReactionsClient + { + /// + /// Instantiates a new GitHub Reactions API client + /// + /// An API connection + public ReactionsClient(IApiConnection apiConnection) + : base(apiConnection) + { + CommitComments = new CommitCommentReaction(apiConnection); + } + + public ICommitCommentReaction CommitComments { get; private set; } + } +} diff --git a/Octokit/GitHubClient.cs b/Octokit/GitHubClient.cs index 4daa1bfc..9d7cb4ef 100644 --- a/Octokit/GitHubClient.cs +++ b/Octokit/GitHubClient.cs @@ -99,6 +99,7 @@ namespace Octokit Search = new SearchClient(apiConnection); SshKey = new SshKeysClient(apiConnection); User = new UsersClient(apiConnection); + Reaction = new ReactionsClient(apiConnection); } /// @@ -305,6 +306,14 @@ namespace Octokit /// public IEnterpriseClient Enterprise { get; private set; } + /// + /// Access GitHub's Reactions API + /// + /// + /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ + /// + public IReactionsClient Reaction { get; private set; } + static Uri FixUpBaseUri(Uri uri) { Ensure.ArgumentNotNull(uri, "uri"); diff --git a/Octokit/IGitHubClient.cs b/Octokit/IGitHubClient.cs index f91d99f3..03e861d7 100644 --- a/Octokit/IGitHubClient.cs +++ b/Octokit/IGitHubClient.cs @@ -162,5 +162,13 @@ namespace Octokit /// Refer to the API documentation for more information: https://developer.github.com/v3/enterprise/ /// IEnterpriseClient Enterprise { get; } + + /// + /// Access GitHub's Reactions API + /// + /// + /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ + /// + IReactionsClient Reaction { get; } } } diff --git a/Octokit/IReactionsClient.cs b/Octokit/IReactionsClient.cs new file mode 100644 index 00000000..5fc2115a --- /dev/null +++ b/Octokit/IReactionsClient.cs @@ -0,0 +1,19 @@ +namespace Octokit +{ + /// + /// A client for GitHub's Reactions Events API. + /// + /// + /// See the Reactions API documentation for more information + /// + public interface IReactionsClient + { + /// + /// Access GitHub's Reactions API. + /// + /// + /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ + /// + ICommitCommentReaction CommitComments { get; } + } +} diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj index e1d404be..4700c2fb 100644 --- a/Octokit/Octokit-Mono.csproj +++ b/Octokit/Octokit-Mono.csproj @@ -468,6 +468,10 @@ + + + + \ No newline at end of file diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj index 88be5cf0..3ecbbfab 100644 --- a/Octokit/Octokit-MonoAndroid.csproj +++ b/Octokit/Octokit-MonoAndroid.csproj @@ -479,6 +479,10 @@ + + + + \ No newline at end of file diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj index 0b16601c..5fc73261 100644 --- a/Octokit/Octokit-Monotouch.csproj +++ b/Octokit/Octokit-Monotouch.csproj @@ -475,6 +475,10 @@ + + + + diff --git a/Octokit/Octokit-Portable.csproj b/Octokit/Octokit-Portable.csproj index ca97a4c6..1d3e3bdd 100644 --- a/Octokit/Octokit-Portable.csproj +++ b/Octokit/Octokit-Portable.csproj @@ -462,9 +462,13 @@ - + + + + + diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj index 16f76baf..fdc22f54 100644 --- a/Octokit/Octokit-netcore45.csproj +++ b/Octokit/Octokit-netcore45.csproj @@ -469,9 +469,13 @@ - + + + + + diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 00b0cfca..5ec68bae 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -58,6 +58,7 @@ Properties\SolutionInfo.cs + @@ -85,6 +86,8 @@ + + @@ -118,6 +121,7 @@ +