diff --git a/Octokit.Reactive/Clients/IObservableCommitCommentReactionsClient.cs b/Octokit.Reactive/Clients/IObservableCommitCommentReactionsClient.cs index 2488a6fa..b44b78ba 100644 --- a/Octokit.Reactive/Clients/IObservableCommitCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservableCommitCommentReactionsClient.cs @@ -1,4 +1,5 @@ using System; +using System.Reactive; namespace Octokit.Reactive { @@ -70,5 +71,26 @@ namespace Octokit.Reactive /// Options for changing the API response /// IObservable GetAll(long repositoryId, int number, ApiOptions options); + + /// + /// Deletes a reaction for a specified Commit Comment + /// + /// https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction + /// The owner of the repository + /// The name of the repository + /// The comment id + /// The reaction id + /// + IObservable Delete(string owner, string name, int commentId, int reactionId); + + /// + /// Deletes a reaction for a specified Commit Comment + /// + /// https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction + /// The Id of the repository + /// The comment id + /// The reaction id + /// + IObservable Delete(long repositoryId, int commentId, int reactionId); } } diff --git a/Octokit.Reactive/Clients/IObservableIssueCommentReactionsClient.cs b/Octokit.Reactive/Clients/IObservableIssueCommentReactionsClient.cs index 6a8f032b..43fcef4e 100644 --- a/Octokit.Reactive/Clients/IObservableIssueCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservableIssueCommentReactionsClient.cs @@ -1,4 +1,5 @@ using System; +using System.Reactive; namespace Octokit.Reactive { @@ -64,5 +65,26 @@ namespace Octokit.Reactive /// The comment id /// Options for changing the API response IObservable GetAll(long repositoryId, int number, ApiOptions options); + + /// + /// Deletes a reaction for a specified Issue Comment + /// + /// https://docs.github.com/en/rest/reactions#delete-an-issue-comment-reaction + /// The owner of the repository + /// The name of the repository + /// The comment id + /// The reaction id + /// + IObservable Delete(string owner, string name, int commentId, int reactionId); + + /// + /// Deletes a reaction for a specified Commit Comment + /// + /// https://docs.github.com/en/rest/reactions#delete-an-issue-comment-reaction + /// The Id of the repository + /// The comment id + /// The reaction id + /// + IObservable Delete(long repositoryId, int commentId, int reactionId); } } diff --git a/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs b/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs index 8d762064..6acd9b27 100644 --- a/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs @@ -1,4 +1,5 @@ using System; +using System.Reactive; namespace Octokit.Reactive { @@ -64,5 +65,26 @@ namespace Octokit.Reactive /// The issue id /// The reaction to create IObservable Create(long repositoryId, int number, NewReaction reaction); + + /// + /// Deletes a reaction for a specified Issue + /// + /// https://docs.github.com/en/rest/reactions#delete-an-issue-reaction + /// The owner of the repository + /// The name of the repository + /// The issue number + /// The reaction id + /// + IObservable Delete(string owner, string name, int issueNumber, int reactionId); + + /// + /// Deletes a reaction for a specified Issue + /// + /// https://docs.github.com/en/rest/reactions#delete-an-issue-reaction + /// The owner of the repository + /// The issue number + /// The reaction id + /// + IObservable Delete(long repositoryId, int issueNumber, int reactionId); } } diff --git a/Octokit.Reactive/Clients/IObservablePullRequestReviewCommentReactionsClient.cs b/Octokit.Reactive/Clients/IObservablePullRequestReviewCommentReactionsClient.cs index ced771bd..0c3e06e0 100644 --- a/Octokit.Reactive/Clients/IObservablePullRequestReviewCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservablePullRequestReviewCommentReactionsClient.cs @@ -1,4 +1,5 @@ using System; +using System.Reactive; namespace Octokit.Reactive { @@ -64,5 +65,26 @@ namespace Octokit.Reactive /// The comment id /// The reaction to create IObservable Create(long repositoryId, int number, NewReaction reaction); + + /// + /// Deletes a reaction for a specified Pull Request comment + /// + /// https://docs.github.com/en/rest/reactions#delete-a-pull-request-comment-reaction + /// The owner of the repository + /// The name of the repository + /// The comment id + /// The reaction id + /// + IObservable Delete(string owner, string name, int commentId, int reactionId); + + /// + /// Deletes a reaction for a specified Pull Request comment + /// + /// https://docs.github.com/en/rest/reactions#delete-a-pull-request-comment-reaction + /// The owner of the repository + /// The comment id + /// The reaction id + /// + IObservable Delete(long repositoryId, int commentId, int reactionId); } } diff --git a/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs b/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs index 8286a520..c95814ae 100644 --- a/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs @@ -1,4 +1,5 @@ using System; +using System.Reactive; using System.Reactive.Threading.Tasks; using Octokit.Reactive.Internal; @@ -113,5 +114,38 @@ namespace Octokit.Reactive return _connection.GetAndFlattenAllPages(ApiUrls.CommitCommentReactions(repositoryId, number), null, AcceptHeaders.ReactionsPreview, options); } + + /// + /// Deletes a reaction for a specified Commit Comment + /// + /// https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction + /// The owner of the repository + /// The name of the repository + /// The comment id + /// The reaction id + /// + public IObservable Delete(string owner, string name, int commentId, int reactionId) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(reactionId, nameof(reactionId)); + + return _client.Delete(owner, name, commentId, reactionId).ToObservable(); + } + + /// + /// Deletes a reaction for a specified Commit Comment + /// + /// https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction + /// The Id of the repository + /// The comment id + /// The reaction id + /// + public IObservable Delete(long repositoryId, int commentId, int reactionid) + { + Ensure.ArgumentNotNull(reactionid, nameof(reactionid)); + + return _client.Delete(repositoryId, commentId, reactionid).ToObservable(); + } } } diff --git a/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs b/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs index f6689482..9a4d61cd 100644 --- a/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs @@ -1,4 +1,5 @@ using System; +using System.Reactive; using System.Reactive.Threading.Tasks; using Octokit.Reactive.Internal; @@ -110,5 +111,38 @@ namespace Octokit.Reactive return _connection.GetAndFlattenAllPages(ApiUrls.IssueCommentReactions(repositoryId, number), null, AcceptHeaders.ReactionsPreview, options); } + + /// + /// Deletes a reaction for a specified Issue Comment + /// + /// https://docs.github.com/en/rest/reactions#delete-an-issue-comment-reaction + /// The owner of the repository + /// The name of the repository + /// The comment id + /// The reaction id + /// + public IObservable Delete(string owner, string name, int commentId, int reactionId) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(reactionId, nameof(reactionId)); + + return _client.Delete(owner, name, commentId, reactionId).ToObservable(); + } + + /// + /// Deletes a reaction for a specified Commit Comment + /// + /// https://docs.github.com/en/rest/reactions#delete-an-issue-comment-reaction + /// The Id of the repository + /// The comment id + /// The reaction id + /// + public IObservable Delete(long repositoryId, int commentId, int reactionId) + { + Ensure.ArgumentNotNull(reactionId, nameof(reactionId)); + + return _client.Delete(repositoryId, commentId, reactionId).ToObservable(); + } } } diff --git a/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs b/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs index 19de83a0..12da4058 100644 --- a/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs @@ -1,4 +1,5 @@ using System; +using System.Reactive; using System.Reactive.Threading.Tasks; using Octokit.Reactive.Internal; @@ -107,5 +108,38 @@ namespace Octokit.Reactive return _client.Create(repositoryId, number, reaction).ToObservable(); } + + /// + /// Deletes a reaction for a specified Issue + /// + /// https://docs.github.com/en/rest/reactions#delete-an-issue-reaction + /// The owner of the repository + /// The name of the repository + /// The issue number + /// The reaction id + /// + public IObservable Delete(string owner, string name, int issueNumber, int reactionId) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(reactionId, nameof(reactionId)); + + return _client.Delete(owner, name, issueNumber, reactionId).ToObservable(); + } + + /// + /// Deletes a reaction for a specified Issue + /// + /// https://docs.github.com/en/rest/reactions#delete-an-issue-reaction + /// The owner of the repository + /// The issue number + /// The reaction id + /// + public IObservable Delete(long repositoryId, int issueNumber, int reactionId) + { + Ensure.ArgumentNotNull(reactionId, nameof(reactionId)); + + return _client.Delete(repositoryId, issueNumber, reactionId).ToObservable(); + } } } diff --git a/Octokit.Reactive/Clients/ObservablePullRequestReviewCommentReactionsClient.cs b/Octokit.Reactive/Clients/ObservablePullRequestReviewCommentReactionsClient.cs index 1be8335d..967aaa1d 100644 --- a/Octokit.Reactive/Clients/ObservablePullRequestReviewCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservablePullRequestReviewCommentReactionsClient.cs @@ -1,4 +1,5 @@ using System; +using System.Reactive; using System.Reactive.Threading.Tasks; using Octokit.Reactive.Internal; @@ -41,7 +42,7 @@ namespace Octokit.Reactive Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages(ApiUrls.PullRequestReviewCommentReaction(owner, name, number), null, AcceptHeaders.ReactionsPreview, options); + return _connection.GetAndFlattenAllPages(ApiUrls.PullRequestReviewCommentReactions(owner, name, number), null, AcceptHeaders.ReactionsPreview, options); } /// @@ -66,7 +67,7 @@ namespace Octokit.Reactive { Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages(ApiUrls.PullRequestReviewCommentReaction(repositoryId, number), null, AcceptHeaders.ReactionsPreview, options); + return _connection.GetAndFlattenAllPages(ApiUrls.PullRequestReviewCommentReactions(repositoryId, number), null, AcceptHeaders.ReactionsPreview, options); } /// @@ -99,5 +100,38 @@ namespace Octokit.Reactive return _client.Create(repositoryId, number, reaction).ToObservable(); } + + /// + /// Deletes a reaction for a specified Pull Request comment + /// + /// https://docs.github.com/en/rest/reactions#delete-a-pull-request-comment-reaction + /// The owner of the repository + /// The name of the repository + /// The comment id + /// The reaction id + /// + public IObservable Delete(string owner, string name, int commentId, int reactionId) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(reactionId, nameof(reactionId)); + + return _client.Delete(owner, name, commentId, reactionId).ToObservable(); + } + + /// + /// Deletes a reaction for a specified Pull Request comment + /// + /// https://docs.github.com/en/rest/reactions#delete-a-pull-request-comment-reaction + /// The owner of the repository + /// The comment id + /// The reaction id + /// + public IObservable Delete(long repositoryId, int commentId, int reactionId) + { + Ensure.ArgumentNotNull(reactionId, nameof(reactionId)); + + return _client.Delete(repositoryId, commentId, reactionId).ToObservable(); + } } } diff --git a/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs b/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs index 7e18eb69..237e9988 100644 --- a/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs @@ -352,6 +352,54 @@ public class CommitCommentReactionsClientTests Assert.Equal(result.User.Id, reaction.User.Id); } + + [IntegrationTest] + public async Task CanDeleteReaction() + { + var commit = await SetupCommitForRepository(_github); + + var comment = new NewCommitComment("test"); + + var result = await _github.Repository.Comment.Create(_context.RepositoryOwner, _context.RepositoryName, + commit.Sha, comment); + + foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) + { + var newReaction = new NewReaction(reactionType); + + var reaction = await _github.Reaction.CommitComment.Create(_context.RepositoryOwner, _context.RepositoryName, result.Id, newReaction); + + await _github.Reaction.CommitComment.Delete(_context.RepositoryOwner, _context.RepositoryName, result.Id, reaction.Id); + } + + var finalComments = await _github.Reaction.CommitComment.GetAll(_context.RepositoryOwner, _context.RepositoryName, result.Id); + + Assert.Empty(finalComments); + } + + [IntegrationTest] + public async Task CanDeleteReactionWithRepositoryId() + { + var commit = await SetupCommitForRepository(_github); + + var comment = new NewCommitComment("test"); + + var result = await _github.Repository.Comment.Create(_context.RepositoryId, commit.Sha, comment); + + foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) + { + var newReaction = new NewReaction(reactionType); + + var reaction = await _github.Reaction.CommitComment.Create(_context.RepositoryId, result.Id, newReaction); + + await _github.Reaction.CommitComment.Delete(_context.RepositoryId, result.Id, reaction.Id); + } + + var finalComments = await _github.Reaction.CommitComment.GetAll(_context.RepositoryId, result.Id); + + Assert.Empty(finalComments); + } + public void Dispose() { _context.Dispose(); diff --git a/Octokit.Tests.Integration/Clients/IssueCommentReactionsClientTests.cs b/Octokit.Tests.Integration/Clients/IssueCommentReactionsClientTests.cs index 472218a0..50424130 100644 --- a/Octokit.Tests.Integration/Clients/IssueCommentReactionsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssueCommentReactionsClientTests.cs @@ -322,6 +322,55 @@ public class IssueCommentReactionsClientTests Assert.Equal(issueComment.User.Id, issueCommentReaction.User.Id); } + [IntegrationTest] + public async Task CanDeleteReaction() + { + var newIssue = new NewIssue("a test issue") { Body = "A new unassigned issue" }; + var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); + + Assert.NotNull(issue); + + var issueComment = await _issuesClient.Comment.Create(_context.RepositoryOwner, _context.RepositoryName, issue.Number, "A test comment"); + + foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) + { + var newReaction = new NewReaction(reactionType); + + var reaction = await _github.Reaction.IssueComment.Create(_context.RepositoryOwner, _context.RepositoryName, issueComment.Id, newReaction); + + await _github.Reaction.IssueComment.Delete(_context.RepositoryOwner, _context.RepositoryName, issueComment.Id, reaction.Id); + } + + var allReactions = await _github.Reaction.IssueComment.GetAll(_context.RepositoryOwner, _context.RepositoryName, issueComment.Id); + + Assert.Empty(allReactions); + } + + [IntegrationTest] + public async Task CanDeleteReactionWithRepositoryId() + { + var newIssue = new NewIssue("a test issue") { Body = "A new unassigned issue" }; + var issue = await _issuesClient.Create(_context.RepositoryId, newIssue); + + Assert.NotNull(issue); + + var issueComment = await _issuesClient.Comment.Create(_context.RepositoryId, issue.Number, "A test comment"); + + Assert.NotNull(issueComment); + + foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) + { + var newReaction = new NewReaction(reactionType); + + var reaction = await _github.Reaction.IssueComment.Create(_context.RepositoryId, issueComment.Id, newReaction); + await _github.Reaction.IssueComment.Delete(_context.RepositoryId, issueComment.Id, reaction.Id); + } + + var allReactions = await _github.Reaction.IssueComment.GetAll(_context.RepositoryId, issueComment.Id); + + Assert.Empty(allReactions); + } + public void Dispose() { _context.Dispose(); diff --git a/Octokit.Tests.Integration/Clients/IssueReactionsClientTests.cs b/Octokit.Tests.Integration/Clients/IssueReactionsClientTests.cs index 9a396e87..b38bee71 100644 --- a/Octokit.Tests.Integration/Clients/IssueReactionsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssueReactionsClientTests.cs @@ -286,6 +286,49 @@ public class IssueReactionsClientTests Assert.Equal(issue.User.Id, issueReaction.User.Id); } + [IntegrationTest] + public async Task CanDeleteReaction() + { + var newIssue = new NewIssue("a test issue") { Body = "A new unassigned issue" }; + var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); + + Assert.NotNull(issue); + + foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) + { + var newReaction = new NewReaction(reactionType); + + var reaction = await _github.Reaction.Issue.Create(_context.RepositoryOwner, _context.RepositoryName, issue.Number, newReaction); + await _github.Reaction.Issue.Delete(_context.RepositoryOwner, _context.RepositoryName, issue.Number, reaction.Id); + } + + var allReactions = await _github.Reaction.Issue.GetAll(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + + Assert.Empty(allReactions); + } + + [IntegrationTest] + public async Task CanDeleteReactionWithRepositoryId() + { + var newIssue = new NewIssue("a test issue") { Body = "A new unassigned issue" }; + var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); + + Assert.NotNull(issue); + + foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) + { + var newReaction = new NewReaction(reactionType); + + var reaction = await _github.Reaction.Issue.Create(_context.RepositoryOwner, _context.RepositoryName, issue.Number, newReaction); + await _github.Reaction.Issue.Delete(_context.RepositoryId, issue.Number, reaction.Id); + } + + var allReactions = await _github.Reaction.Issue.GetAll(_context.RepositoryId, issue.Number); + + Assert.Empty(allReactions); + + } + public void Dispose() { _context.Dispose(); diff --git a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs index 9558c1dd..3e051184 100644 --- a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs @@ -339,6 +339,60 @@ public class PullRequestReviewCommentReactionsClientTests : IDisposable Assert.Equal(commentFromGitHub.User.Id, pullRequestReviewCommentReaction.User.Id); } + [IntegrationTest] + public async Task CanDeleteReaction() + { + var pullRequest = await CreatePullRequest(_context); + + const string body = "A review comment message"; + const int position = 1; + + var createdComment = await CreateComment(body, position, pullRequest.Sha, pullRequest.Number); + + var commentFromGitHub = await _client.GetComment(Helper.UserName, _context.RepositoryName, createdComment.Id); + + AssertComment(commentFromGitHub, body, position); + + foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) + { + var newReaction = new NewReaction(reactionType); + + var reaction = await _github.Reaction.PullRequestReviewComment.Create(_context.RepositoryOwner, _context.RepositoryName, commentFromGitHub.Id, newReaction); + await _github.Reaction.PullRequestReviewComment.Delete(_context.RepositoryOwner, _context.RepositoryName, commentFromGitHub.Id, reaction.Id); + } + + var allReactions = await _github.Reaction.PullRequestReviewComment.GetAll(_context.RepositoryOwner, _context.RepositoryName, commentFromGitHub.Id); + + Assert.Empty(allReactions); + } + + [IntegrationTest] + public async Task CanDeleteReactionWithRepositoryId() + { + var pullRequest = await CreatePullRequest(_context); + + const string body = "A review comment message"; + const int position = 1; + + var createdComment = await CreateComment(body, position, pullRequest.Sha, pullRequest.Number); + + var commentFromGitHub = await _client.GetComment(_context.RepositoryId, createdComment.Id); + + AssertComment(commentFromGitHub, body, position); + + foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) + { + var newReaction = new NewReaction(reactionType); + + var reaction = await _github.Reaction.PullRequestReviewComment.Create(_context.RepositoryId, commentFromGitHub.Id, newReaction); + await _github.Reaction.PullRequestReviewComment.Delete(_context.RepositoryId, commentFromGitHub.Id, reaction.Id); + } + + var allReactions = await _github.Reaction.PullRequestReviewComment.GetAll(_context.RepositoryId, commentFromGitHub.Id); + + Assert.Empty(allReactions); + } + /// /// Creates the base state for testing (creates a repo, a commit in master, a branch, a commit in the branch and a pull request) /// @@ -349,7 +403,7 @@ public class PullRequestReviewCommentReactionsClientTests : IDisposable // Creating a commit in master - var createdCommitInMaster = await CreateCommit(repoName, "Hello World!", "README.md", "heads/master", "A master commit message"); + var createdCommitInMaster = await CreateCommit(repoName, "Hello World!", "README.md", "heads/main", "A master commit message"); // Creating a branch @@ -362,7 +416,7 @@ public class PullRequestReviewCommentReactionsClientTests : IDisposable // Creating a pull request - var pullRequest = new NewPullRequest("Nice title for the pull request", branchName, "master"); + var pullRequest = new NewPullRequest("Nice title for the pull request", branchName, "main"); var createdPullRequest = await _github.PullRequest.Create(Helper.UserName, repoName, pullRequest); var data = new PullRequestData diff --git a/Octokit/Clients/CommitCommentReactionsClient.cs b/Octokit/Clients/CommitCommentReactionsClient.cs index 674f1c60..320c35cd 100644 --- a/Octokit/Clients/CommitCommentReactionsClient.cs +++ b/Octokit/Clients/CommitCommentReactionsClient.cs @@ -116,5 +116,37 @@ namespace Octokit return ApiConnection.GetAll(ApiUrls.CommitCommentReactions(repositoryId, number), null, AcceptHeaders.ReactionsPreview, options); } + + /// + /// Deletes a reaction for a specified Commit Comment + /// + /// https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction + /// The owner of the repository + /// The name of the repository + /// The comment id + /// The reaction id + /// + [ManualRoute("DELETE", "/repos/{owner}/{repo}/comments/{comment_id}/reactions/{reaction_id}")] + public Task Delete(string owner, string name, int commentId, int reactionId) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return ApiConnection.Delete(ApiUrls.CommitCommentReaction(owner, name, commentId, reactionId)); + } + + /// + /// Deletes a reaction for a specified Commit Comment + /// + /// https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction + /// The owner of the repository + /// The comment id + /// The reaction id + /// + [ManualRoute("DELETE", "/repositories/{id}/comments/{comment_id}/reactions/{reaction_id}")] + public Task Delete(long repositoryId, int commentId, int reactionId) + { + return ApiConnection.Delete(ApiUrls.CommitCommentReaction(repositoryId, commentId, reactionId)); + } } } diff --git a/Octokit/Clients/ICommitCommentReactionsClient.cs b/Octokit/Clients/ICommitCommentReactionsClient.cs index c64c25fa..f35bb620 100644 --- a/Octokit/Clients/ICommitCommentReactionsClient.cs +++ b/Octokit/Clients/ICommitCommentReactionsClient.cs @@ -71,5 +71,26 @@ namespace Octokit /// Options for changing the API response /// Task> GetAll(long repositoryId, int number, ApiOptions options); + + /// + /// Deletes a reaction for a specified Commit Comment + /// + /// https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction + /// The owner of the repository + /// The name of the repository + /// The comment id + /// The reaction id + /// + Task Delete(string owner, string name, int commentId, int reactionId); + + /// + /// Deletes a reaction for a specified Commit Comment + /// + /// https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction + /// The owner of the repository + /// The comment id + /// The reaction id + /// + Task Delete(long repositoryId, int commentId, int reactionId); } } diff --git a/Octokit/Clients/IIssueCommentReactionsClient.cs b/Octokit/Clients/IIssueCommentReactionsClient.cs index 4fd60ba4..aafaa87e 100644 --- a/Octokit/Clients/IIssueCommentReactionsClient.cs +++ b/Octokit/Clients/IIssueCommentReactionsClient.cs @@ -65,5 +65,26 @@ namespace Octokit /// The comment id /// Options for changing the API response Task> GetAll(long repositoryId, int number, ApiOptions options); + + /// + /// Deletes a reaction for a specified Commit Comment + /// + /// https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction + /// The owner of the repository + /// The name of the repository + /// The comment id + /// The reaction id + /// + Task Delete(string owner, string name, int commentId, int reactionId); + + /// + /// Deletes a reaction for a specified Commit Comment + /// + /// https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction + /// The Id of the repository + /// The comment id + /// The reaction id + /// + Task Delete(long repositoryId, int commentId, int reactionId); } } diff --git a/Octokit/Clients/IIssueReactionsClient.cs b/Octokit/Clients/IIssueReactionsClient.cs index 0de3feff..bcd3a002 100644 --- a/Octokit/Clients/IIssueReactionsClient.cs +++ b/Octokit/Clients/IIssueReactionsClient.cs @@ -65,5 +65,26 @@ namespace Octokit /// The issue id /// The reaction to create Task Create(long repositoryId, int number, NewReaction reaction); + + /// + /// Deletes a reaction for a specified Issue + /// + /// https://docs.github.com/en/rest/reactions#delete-an-issue-reaction + /// The owner of the repository + /// The name of the repository + /// The issue number + /// The reaction id + /// + Task Delete(string owner, string name, int issueNumber, int reactionId); + + /// + /// Deletes a reaction for a specified Issue + /// + /// https://docs.github.com/en/rest/reactions#delete-an-issue-reaction + /// The owner of the repository + /// The issue number + /// The reaction id + /// + Task Delete(long repositoryId, int issueNumber, int reactionId); } } diff --git a/Octokit/Clients/IPullRequestReviewCommentReactionsClient.cs b/Octokit/Clients/IPullRequestReviewCommentReactionsClient.cs index 96a47395..128856fb 100644 --- a/Octokit/Clients/IPullRequestReviewCommentReactionsClient.cs +++ b/Octokit/Clients/IPullRequestReviewCommentReactionsClient.cs @@ -65,5 +65,26 @@ namespace Octokit /// The comment id /// The reaction to create Task Create(long repositoryId, int number, NewReaction reaction); + + /// + /// Deletes a reaction for a specified Pull Request comment + /// + /// https://docs.github.com/en/rest/reactions#delete-a-pull-request-comment-reaction + /// The owner of the repository + /// The name of the repository + /// The issue id + /// The reaction id + /// + Task Delete(string owner, string name, int commentId, int reactionId); + + /// + /// Deletes a reaction for a specified Pull Request comment + /// + /// https://docs.github.com/en/rest/reactions#delete-a-pull-request-comment-reaction + /// The owner of the repository + /// The issue id + /// The reaction id + /// + Task Delete(long repositoryId, int commentId, int reactionId); } } diff --git a/Octokit/Clients/IssueCommentReactionsClient.cs b/Octokit/Clients/IssueCommentReactionsClient.cs index f8293501..da889c8f 100644 --- a/Octokit/Clients/IssueCommentReactionsClient.cs +++ b/Octokit/Clients/IssueCommentReactionsClient.cs @@ -110,5 +110,37 @@ namespace Octokit return ApiConnection.GetAll(ApiUrls.IssueCommentReactions(repositoryId, number), null, AcceptHeaders.ReactionsPreview, options); } + + /// + /// Deletes a reaction for a specified Issue Comment + /// + /// https://developer.github.com/v3/reactions/#list-reactions-for-a-commit-comment + /// The owner of the repository + /// The name of the repository + /// The issue id + /// The reaction id + /// + [ManualRoute("DELETE", "/repos/{owner}/{repo}/issues/comments/{comment_id}/reactions/{reaction_id}")] + public Task Delete(string owner, string name, int commentId, int reactionId) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return ApiConnection.Delete(ApiUrls.IssueCommentReaction(owner, name, commentId, reactionId)); + } + + /// + /// Deletes a reaction for a specified Issue Comment + /// + /// https://developer.github.com/v3/reactions/#list-reactions-for-a-commit-comment + /// The owner of the repository + /// The issue id + /// The reaction id + /// + [ManualRoute("DELETE", "/repositories/{id}/issues/comments/{comment_id}/reactions/{reaction_id}")] + public Task Delete(long repositoryId, int commentId, int reactionId) + { + return ApiConnection.Delete(ApiUrls.IssueCommentReaction(repositoryId, commentId, reactionId)); + } } } diff --git a/Octokit/Clients/IssueReactionsClient.cs b/Octokit/Clients/IssueReactionsClient.cs index 53c970e0..c8d2a2ad 100644 --- a/Octokit/Clients/IssueReactionsClient.cs +++ b/Octokit/Clients/IssueReactionsClient.cs @@ -110,5 +110,37 @@ namespace Octokit return ApiConnection.Post(ApiUrls.IssueReactions(repositoryId, number), reaction, AcceptHeaders.ReactionsPreview); } + + /// + /// Deletes a reaction for a specified Issue + /// + /// https://docs.github.com/en/rest/reactions#delete-an-issue-reaction + /// The owner of the repository + /// The name of the repository + /// The issue id + /// The reaction id + /// + [ManualRoute("DELETE", "/repos/{owner}/{repo}/issues/{issue_number}/reactions/{reaction_id}")] + public Task Delete(string owner, string name, int issueNumber, int reactionId) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return ApiConnection.Delete(ApiUrls.IssueReaction(owner, name, issueNumber, reactionId)); + } + + /// + /// Deletes a reaction for a specified Issue + /// + /// https://docs.github.com/en/rest/reactions#delete-an-issue-reaction + /// The owner of the repository + /// The issue id + /// The reaction id + /// + [ManualRoute("DELETE", "/repositories/{id}/issues/{issue_number}/reactions/{reaction_id}")] + public Task Delete(long repositoryId, int issueNumber, int reactionId) + { + return ApiConnection.Delete(ApiUrls.IssueReaction(repositoryId, issueNumber, reactionId)); + } } } diff --git a/Octokit/Clients/PullRequestReviewCommentReactionsClient.cs b/Octokit/Clients/PullRequestReviewCommentReactionsClient.cs index 7acd3692..a76ef8c5 100644 --- a/Octokit/Clients/PullRequestReviewCommentReactionsClient.cs +++ b/Octokit/Clients/PullRequestReviewCommentReactionsClient.cs @@ -45,7 +45,7 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll(ApiUrls.PullRequestReviewCommentReaction(owner, name, number), null, AcceptHeaders.ReactionsPreview, options); + return ApiConnection.GetAll(ApiUrls.PullRequestReviewCommentReactions(owner, name, number), null, AcceptHeaders.ReactionsPreview, options); } /// @@ -73,7 +73,7 @@ namespace Octokit { Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll(ApiUrls.PullRequestReviewCommentReaction(repositoryId, number), null, AcceptHeaders.ReactionsPreview, options); + return ApiConnection.GetAll(ApiUrls.PullRequestReviewCommentReactions(repositoryId, number), null, AcceptHeaders.ReactionsPreview, options); } /// @@ -92,7 +92,7 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(reaction, nameof(reaction)); - return ApiConnection.Post(ApiUrls.PullRequestReviewCommentReaction(owner, name, number), reaction, AcceptHeaders.ReactionsPreview); + return ApiConnection.Post(ApiUrls.PullRequestReviewCommentReactions(owner, name, number), reaction, AcceptHeaders.ReactionsPreview); } /// @@ -108,7 +108,39 @@ namespace Octokit { Ensure.ArgumentNotNull(reaction, nameof(reaction)); - return ApiConnection.Post(ApiUrls.PullRequestReviewCommentReaction(repositoryId, number), reaction, AcceptHeaders.ReactionsPreview); + return ApiConnection.Post(ApiUrls.PullRequestReviewCommentReactions(repositoryId, number), reaction, AcceptHeaders.ReactionsPreview); + } + + /// + /// Deletes a reaction for a specified Pull Request comment + /// + /// https://docs.github.com/en/rest/reactions#delete-a-pull-request-comment-reaction + /// The owner of the repository + /// The name of the repository + /// The comment id + /// The reaction id + /// + [ManualRoute("DELETE", "/repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions/{reaction_id}")] + public Task Delete(string owner, string name, int commentId, int reactionId) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return ApiConnection.Delete(ApiUrls.PullRequestReviewCommentReaction(owner, name, commentId, reactionId)); + } + + /// + /// Deletes a reaction for a specified Pull Request comment + /// + /// https://docs.github.com/en/rest/reactions#delete-a-pull-request-comment-reaction + /// The owner of the repository + /// The comment id + /// The reaction id + /// + [ManualRoute("DELETE", "/repositories/{id}/pulls/comments/{comment_id}/reactions/{reaction_id}")] + public Task Delete(long repositoryId, int commentId, int reactionId) + { + return ApiConnection.Delete(ApiUrls.PullRequestReviewCommentReaction(repositoryId, commentId, reactionId)); } } } diff --git a/Octokit/Clients/ReactionsClient.cs b/Octokit/Clients/ReactionsClient.cs index 65747e5b..eabca26b 100644 --- a/Octokit/Clients/ReactionsClient.cs +++ b/Octokit/Clients/ReactionsClient.cs @@ -58,6 +58,7 @@ namespace Octokit /// [Preview("squirrel-girl")] [ManualRoute("DELETE", "/reactions/{reaction_id}")] + [Obsolete("This route no longer works and is replaced with individual routes in each client")] public Task Delete(int number) { return ApiConnection.Delete(ApiUrls.Reactions(number), new object(), AcceptHeaders.ReactionsPreview); diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 4d3a8332..df99a617 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -479,6 +479,29 @@ namespace Octokit return "repositories/{0}/issues/{1}/reactions".FormatUri(repositoryId, number); } + /// + /// Returns the for the reaction of a specified issue. + /// + /// The owner of the repository + /// The name of the repository + /// The issue number + /// + public static Uri IssueReaction(string owner, string name, int number, int reaction) + { + return "repos/{0}/{1}/issues/{2}/reactions/{3}".FormatUri(owner, name, number, reaction); + } + + /// + /// Returns the for the reaction of a specified issue. + /// + /// The Id of the repository + /// The issue number + /// + public static Uri IssueReaction(long repositoryId, int number, int reaction) + { + return "repositories/{0}/issues/{1}/reactions/{2}".FormatUri(repositoryId, number, reaction); + } + /// /// Returns the for the timeline of a specified issue. /// @@ -560,6 +583,29 @@ namespace Octokit return "repositories/{0}/issues/comments/{1}/reactions".FormatUri(repositoryId, number); } + /// + /// Returns the for the reaction of a specified issue comment. + /// + /// The owner of the repository + /// The name of the repository + /// The comment number + /// + public static Uri IssueCommentReaction(string owner, string name, int number, int reaction) + { + return "repos/{0}/{1}/issues/comments/{2}/reactions/{3}".FormatUri(owner, name, number, reaction); + } + + /// + /// Returns the for the reaction of a specified issue comment. + /// + /// The owner of the repository + /// The comment number + /// + public static Uri IssueCommentReaction(long repositoryId, int number, int reaction) + { + return "repositories/{0}/issues/comments/{1}/reactions/{2}".FormatUri(repositoryId, number, reaction); + } + /// /// Returns the for the specified comment. /// @@ -618,6 +664,31 @@ namespace Octokit return "repositories/{0}/comments/{1}/reactions".FormatUri(repositoryId, number); } + /// + /// Returns the for the reaction of a specified commit comment. + /// + /// The owner of the repository + /// The name of the repository + /// The comment number + /// The reaction number + /// + public static Uri CommitCommentReaction(string owner, string name, int number, int reaction) + { + return "repos/{0}/{1}/comments/{2}/reactions/{3}".FormatUri(owner, name, number, reaction); + } + + /// + /// Returns the for the reaction of a specified commit comment. + /// + /// The Id of the repository + /// The comment number + /// The reaction number + /// + public static Uri CommitCommentReaction(long repositoryId, int number, int reaction) + { + return "repositories/{0}/comments/{1}/reactions/{2}".FormatUri(repositoryId, number, reaction); + } + /// /// Returns the that returns all of the assignees to which issues may be assigned. /// @@ -1604,6 +1675,30 @@ namespace Octokit return "repositories/{0}/pulls/{1}/reviews/{2}".FormatUri(repositoryId, number, reviewId); } + /// + /// Returns the for the reactions of a specified pull request review comment. + /// + /// The owner of the repository + /// The name of the repository + /// The comment number + /// + public static Uri PullRequestReviewCommentReactions(string owner, string name, int number) + { + return "repos/{0}/{1}/pulls/comments/{2}/reactions".FormatUri(owner, name, number); + } + + /// + /// Returns the for the reactions of a specified pull request review comment. + /// + /// The Id of the repository + /// The comment number + /// + public static Uri PullRequestReviewCommentReactions(long repositoryId, int number) + { + return "repositories/{0}/pulls/comments/{1}/reactions".FormatUri(repositoryId, number); + } + + /// /// Returns the for the reaction of a specified pull request review comment. /// @@ -1611,9 +1706,9 @@ namespace Octokit /// The name of the repository /// The comment number /// - public static Uri PullRequestReviewCommentReaction(string owner, string name, int number) + public static Uri PullRequestReviewCommentReaction(string owner, string name, int number, int reaction) { - return "repos/{0}/{1}/pulls/comments/{2}/reactions".FormatUri(owner, name, number); + return "repos/{0}/{1}/pulls/comments/{2}/reactions/{3}".FormatUri(owner, name, number, reaction); } /// @@ -1622,9 +1717,9 @@ namespace Octokit /// The Id of the repository /// The comment number /// - public static Uri PullRequestReviewCommentReaction(long repositoryId, int number) + public static Uri PullRequestReviewCommentReaction(long repositoryId, int number, int reaction) { - return "repositories/{0}/pulls/comments/{1}/reactions".FormatUri(repositoryId, number); + return "repositories/{0}/pulls/comments/{1}/reactions/{2}".FormatUri(repositoryId, number, reaction); } ///