mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-06 20:13:40 +00:00
Merge pull request #1384 from dampir/add-repo-id-issue-reactions-client
Add repositoryId overloads to methods on I(Observable)IssueReactionsClient
This commit is contained in:
@@ -2,8 +2,31 @@
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Reactions API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/reactions/">Reactions API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public interface IObservableIssueReactionsClient
|
||||
{
|
||||
/// <summary>
|
||||
/// List reactions for a specified Issue.
|
||||
/// </summary>
|
||||
/// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue</remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="number">The issue id</param>
|
||||
IObservable<Reaction> GetAll(string owner, string name, int number);
|
||||
|
||||
/// <summary>
|
||||
/// List reactions for a specified Issue.
|
||||
/// </summary>
|
||||
/// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue</remarks>
|
||||
/// <param name="repositoryId">The ID of the repository</param>
|
||||
/// <param name="number">The issue id</param>
|
||||
IObservable<Reaction> GetAll(int repositoryId, int number);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a reaction for a specified Issue.
|
||||
/// </summary>
|
||||
@@ -12,17 +35,15 @@ namespace Octokit.Reactive
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="number">The issue id</param>
|
||||
/// <param name="reaction">The reaction to create </param>
|
||||
/// <returns></returns>
|
||||
IObservable<Reaction> Create(string owner, string name, int number, NewReaction reaction);
|
||||
|
||||
/// <summary>
|
||||
/// List reactions for a specified Issue.
|
||||
/// Creates a reaction for a specified Issue.
|
||||
/// </summary>
|
||||
/// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue</remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="number">The issue id</param>
|
||||
/// <returns></returns>
|
||||
IObservable<Reaction> GetAll(string owner, string name, int number);
|
||||
/// <remarks>https://developer.github.com/v3/reactions/#create-reaction-for-an-issue</remarks>
|
||||
/// <param name="repositoryId">The ID of the repository</param>
|
||||
/// <param name="number">The issue id</param>
|
||||
/// <param name="reaction">The reaction to create </param>
|
||||
IObservable<Reaction> Create(int repositoryId, int number, NewReaction reaction);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
using Octokit.Reactive.Internal;
|
||||
using System;
|
||||
using System;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
using Octokit.Reactive.Internal;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Reactions API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/reactions/">Reactions API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public class ObservableIssueReactionsClient : IObservableIssueReactionsClient
|
||||
{
|
||||
readonly IIssueReactionsClient _client;
|
||||
@@ -17,6 +23,32 @@ namespace Octokit.Reactive
|
||||
_connection = client.Connection;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List reactions for a specified Issue
|
||||
/// </summary>
|
||||
/// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue</remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="number">The issue id</param>
|
||||
public IObservable<Reaction> GetAll(string owner, string name, int number)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return _connection.GetAndFlattenAllPages<Reaction>(ApiUrls.IssueReactions(owner, name, number), null, AcceptHeaders.ReactionsPreview);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List reactions for a specified Issue.
|
||||
/// </summary>
|
||||
/// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue</remarks>
|
||||
/// <param name="repositoryId">The ID of the repository</param>
|
||||
/// <param name="number">The issue id</param>
|
||||
public IObservable<Reaction> GetAll(int repositoryId, int number)
|
||||
{
|
||||
return _connection.GetAndFlattenAllPages<Reaction>(ApiUrls.IssueReactions(repositoryId, number), null, AcceptHeaders.ReactionsPreview);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a reaction for a specified Issue
|
||||
/// </summary>
|
||||
@@ -25,7 +57,6 @@ namespace Octokit.Reactive
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="number">The issue id</param>
|
||||
/// <param name="reaction">The reaction to create</param>
|
||||
/// <returns></returns>
|
||||
public IObservable<Reaction> Create(string owner, string name, int number, NewReaction reaction)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
@@ -36,19 +67,17 @@ namespace Octokit.Reactive
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List reactions for a specified Issue
|
||||
/// Creates a reaction for a specified Issue.
|
||||
/// </summary>
|
||||
/// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue</remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="number">The issue id</param>
|
||||
/// <returns></returns>
|
||||
public IObservable<Reaction> GetAll(string owner, string name, int number)
|
||||
/// <remarks>https://developer.github.com/v3/reactions/#create-reaction-for-an-issue</remarks>
|
||||
/// <param name="repositoryId">The ID of the repository</param>
|
||||
/// <param name="number">The issue id</param>
|
||||
/// <param name="reaction">The reaction to create </param>
|
||||
public IObservable<Reaction> Create(int repositoryId, int number, NewReaction reaction)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNull(reaction, "reaction");
|
||||
|
||||
return _connection.GetAndFlattenAllPages<Reaction>(ApiUrls.IssueReactions(owner, name, number), null, AcceptHeaders.ReactionsPreview);
|
||||
return _client.Create(repositoryId, number, reaction).ToObservable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using Octokit;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit;
|
||||
using Octokit.Tests.Integration;
|
||||
using Octokit.Tests.Integration.Helpers;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
public class IssueReactionsClientTests
|
||||
@@ -16,11 +16,49 @@ public class IssueReactionsClientTests
|
||||
public TheCreateReactionMethod()
|
||||
{
|
||||
_github = Helper.GetAuthenticatedClient();
|
||||
var repoName = Helper.MakeNameWithTimestamp("public-repo");
|
||||
|
||||
_issuesClient = _github.Issue;
|
||||
|
||||
var repoName = Helper.MakeNameWithTimestamp("public-repo");
|
||||
_context = _github.CreateRepositoryContext(new NewRepository(repoName)).Result;
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanListReactions()
|
||||
{
|
||||
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 issueReaction = await _github.Reaction.Issue.Create(_context.RepositoryOwner, _context.RepositoryName, issue.Number, new NewReaction(ReactionType.Heart));
|
||||
|
||||
var issueReactions = await _github.Reaction.Issue.GetAll(_context.RepositoryOwner, _context.RepositoryName, issue.Number);
|
||||
|
||||
Assert.NotEmpty(issueReactions);
|
||||
|
||||
Assert.Equal(issueReaction.Id, issueReactions[0].Id);
|
||||
Assert.Equal(issueReaction.Content, issueReactions[0].Content);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanListReactionsWithRepositoryId()
|
||||
{
|
||||
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 issueReaction = await _github.Reaction.Issue.Create(_context.RepositoryOwner, _context.RepositoryName, issue.Number, new NewReaction(ReactionType.Heart));
|
||||
|
||||
var issueReactions = await _github.Reaction.Issue.GetAll(_context.Repository.Id, issue.Number);
|
||||
|
||||
Assert.NotEmpty(issueReactions);
|
||||
|
||||
Assert.Equal(issueReaction.Id, issueReactions[0].Id);
|
||||
Assert.Equal(issueReaction.Content, issueReactions[0].Content);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanCreateReaction()
|
||||
{
|
||||
@@ -41,10 +79,28 @@ public class IssueReactionsClientTests
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanCreateReactionWithRepositoryId()
|
||||
{
|
||||
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 issueReaction = await _github.Reaction.Issue.Create(_context.Repository.Id, issue.Number, new NewReaction(ReactionType.Heart));
|
||||
|
||||
Assert.NotNull(issueReaction);
|
||||
|
||||
Assert.IsType<Reaction>(issueReaction);
|
||||
|
||||
Assert.Equal(ReactionType.Heart, issueReaction.Content);
|
||||
|
||||
Assert.Equal(issue.User.Id, issueReaction.User.Id);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_context.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using NSubstitute;
|
||||
using System;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using NSubstitute;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Clients
|
||||
@@ -22,24 +22,35 @@ namespace Octokit.Tests.Clients
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ReactionsClient(connection);
|
||||
var client = new IssueReactionsClient(connection);
|
||||
|
||||
client.Issue.GetAll("fake", "repo", 42);
|
||||
await client.GetAll("fake", "repo", 42);
|
||||
|
||||
connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/reactions"), "application/vnd.github.squirrel-girl-preview");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresArgumentsNotNull()
|
||||
public async Task RequestsCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssueReactionsClient(connection);
|
||||
|
||||
await client.GetAll(1, 42);
|
||||
|
||||
connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/reactions"), "application/vnd.github.squirrel-girl-preview");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ReactionsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Issue.Create(null, "name", 1, new NewReaction(ReactionType.Heart)));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Issue.Create("", "name", 1, new NewReaction(ReactionType.Heart)));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Issue.Create("owner", null, 1, new NewReaction(ReactionType.Heart)));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Issue.Create("owner", "", 1, new NewReaction(ReactionType.Heart)));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Issue.Create("owner", "name", 1, null));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Issue.GetAll(null, "name", 1));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Issue.GetAll("owner", null, 1));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Issue.GetAll("", "name", 1));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Issue.GetAll("owner", "", 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,12 +61,41 @@ namespace Octokit.Tests.Clients
|
||||
{
|
||||
NewReaction newReaction = new NewReaction(ReactionType.Heart);
|
||||
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssueReactionsClient(connection);
|
||||
|
||||
client.Create("fake", "repo", 1, newReaction);
|
||||
|
||||
connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/1/reactions"), newReaction, "application/vnd.github.squirrel-girl-preview");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RequestsCorrectUrlWithRepositoryId()
|
||||
{
|
||||
NewReaction newReaction = new NewReaction(ReactionType.Heart);
|
||||
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssueReactionsClient(connection);
|
||||
|
||||
client.Create(1, 1, newReaction);
|
||||
|
||||
connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/1/reactions"), newReaction, "application/vnd.github.squirrel-girl-preview");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ReactionsClient(connection);
|
||||
|
||||
client.Issue.Create("fake", "repo", 1, newReaction);
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Issue.Create(null, "name", 1, new NewReaction(ReactionType.Heart)));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Issue.Create("owner", null, 1, new NewReaction(ReactionType.Heart)));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Issue.Create("owner", "name", 1, null));
|
||||
|
||||
connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/1/reactions"), Arg.Any<object>(), "application/vnd.github.squirrel-girl-preview");
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Issue.Create(1, 1, null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Issue.Create("", "name", 1, new NewReaction(ReactionType.Heart)));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Issue.Create("owner", "", 1, new NewReaction(ReactionType.Heart)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using NSubstitute;
|
||||
using System;
|
||||
using NSubstitute;
|
||||
using Octokit.Reactive;
|
||||
using System;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Reactive
|
||||
@@ -18,33 +18,37 @@ namespace Octokit.Tests.Reactive
|
||||
|
||||
public class TheGetAllMethod
|
||||
{
|
||||
private readonly IGitHubClient _githubClient;
|
||||
private readonly IObservableReactionsClient _client;
|
||||
private const string owner = "owner";
|
||||
private const string name = "name";
|
||||
|
||||
public TheGetAllMethod()
|
||||
{
|
||||
_githubClient = Substitute.For<IGitHubClient>();
|
||||
_client = new ObservableReactionsClient(_githubClient);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RequestsCorrectUrl()
|
||||
{
|
||||
_client.Issue.GetAll("fake", "repo", 42);
|
||||
_githubClient.Received().Reaction.Issue.GetAll("fake", "repo", 42);
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableIssueReactionsClient(gitHubClient);
|
||||
|
||||
client.GetAll("fake", "repo", 42);
|
||||
gitHubClient.Received().Reaction.Issue.GetAll("fake", "repo", 42);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnsuresArgumentsNotNull()
|
||||
public void RequestsCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableIssueReactionsClient(gitHubClient);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => _client.Issue.Create(null, "name", 1, new NewReaction(ReactionType.Heart)));
|
||||
Assert.Throws<ArgumentException>(() => _client.Issue.Create("", "name", 1, new NewReaction(ReactionType.Heart)));
|
||||
Assert.Throws<ArgumentNullException>(() => _client.Issue.Create("owner", null, 1, new NewReaction(ReactionType.Heart)));
|
||||
Assert.Throws<ArgumentException>(() => _client.Issue.Create("owner", "", 1, new NewReaction(ReactionType.Heart)));
|
||||
Assert.Throws<ArgumentNullException>(() => _client.Issue.Create("owner", "name", 1, null));
|
||||
client.GetAll(1, 42);
|
||||
gitHubClient.Received().Reaction.Issue.GetAll(1, 42);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnsuresNonNullArguments()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableIssueReactionsClient(gitHubClient);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAll(null, "name", 1));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAll("owner", null, 1));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.GetAll("", "name", 1));
|
||||
Assert.Throws<ArgumentException>(() => client.GetAll("owner", "", 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,8 +62,37 @@ namespace Octokit.Tests.Reactive
|
||||
var newReaction = new NewReaction(ReactionType.Confused);
|
||||
|
||||
client.Issue.Create("fake", "repo", 1, newReaction);
|
||||
|
||||
githubClient.Received().Reaction.Issue.Create("fake", "repo", 1, newReaction);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RequestsCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var githubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableReactionsClient(githubClient);
|
||||
var newReaction = new NewReaction(ReactionType.Confused);
|
||||
|
||||
client.Issue.Create(1, 1, newReaction);
|
||||
|
||||
githubClient.Received().Reaction.Issue.Create(1, 1, newReaction);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnsuresNonNullArguments()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableIssueReactionsClient(gitHubClient);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.Create(null, "name", 1, new NewReaction(ReactionType.Heart)));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Create("owner", null, 1, new NewReaction(ReactionType.Heart)));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Create("owner", "name", 1, null));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.Create(1, 1, null));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.Create("", "name", 1, new NewReaction(ReactionType.Heart)));
|
||||
Assert.Throws<ArgumentException>(() => client.Create("owner", "", 1, new NewReaction(ReactionType.Heart)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,12 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Reactions API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/reactions/">Reactions API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public interface IIssueReactionsClient
|
||||
{
|
||||
/// <summary>
|
||||
@@ -12,9 +18,16 @@ namespace Octokit
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="number">The issue id</param>
|
||||
/// <returns></returns>
|
||||
Task<IReadOnlyList<Reaction>> GetAll(string owner, string name, int number);
|
||||
|
||||
/// <summary>
|
||||
/// Get all reactions for a specified Issue
|
||||
/// </summary>
|
||||
/// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue</remarks>
|
||||
/// <param name="repositoryId">The ID of the repository</param>
|
||||
/// <param name="number">The issue id</param>
|
||||
Task<IReadOnlyList<Reaction>> GetAll(int repositoryId, int number);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a reaction for a specified Issue
|
||||
/// </summary>
|
||||
@@ -23,7 +36,15 @@ namespace Octokit
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="number">The issue id</param>
|
||||
/// <param name="reaction">The reaction to create</param>
|
||||
/// <returns></returns>
|
||||
Task<Reaction> Create(string owner, string name, int number, NewReaction reaction);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a reaction for a specified Issue
|
||||
/// </summary>
|
||||
/// <remarks>https://developer.github.com/v3/reactions/#create-reaction-for-an-issue</remarks>
|
||||
/// <param name="repositoryId">The ID of the repository</param>
|
||||
/// <param name="number">The issue id</param>
|
||||
/// <param name="reaction">The reaction to create</param>
|
||||
Task<Reaction> Create(int repositoryId, int number, NewReaction reaction);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Reactions API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/reactions/">Reactions API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public class IssueReactionsClient : ApiClient, IIssueReactionsClient
|
||||
{
|
||||
public IssueReactionsClient(IApiConnection apiConnection)
|
||||
@@ -11,15 +16,40 @@ namespace Octokit
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all reactions for a specified Issue
|
||||
/// </summary>
|
||||
/// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue</remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="number">The issue id</param>
|
||||
public Task<IReadOnlyList<Reaction>> GetAll(string owner, string name, int number)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return ApiConnection.GetAll<Reaction>(ApiUrls.IssueReactions(owner, name, number), AcceptHeaders.ReactionsPreview);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all reactions for a specified Issue
|
||||
/// </summary>
|
||||
/// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue</remarks>
|
||||
/// <param name="repositoryId">The ID of the repository</param>
|
||||
/// <param name="number">The issue id</param>
|
||||
public Task<IReadOnlyList<Reaction>> GetAll(int repositoryId, int number)
|
||||
{
|
||||
return ApiConnection.GetAll<Reaction>(ApiUrls.IssueReactions(repositoryId, number), AcceptHeaders.ReactionsPreview);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a reaction for a specified Issue
|
||||
/// </summary>
|
||||
/// <remarks>https://developer.github.com/v3/reactions/#create-reactions-for-an-issue</remarks>
|
||||
/// <remarks>https://developer.github.com/v3/reactions/#create-reaction-for-an-issue</remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="number">The issue id</param>
|
||||
/// <param name="reaction">The reaction to create</param>
|
||||
/// <returns></returns>
|
||||
public Task<Reaction> Create(string owner, string name, int number, NewReaction reaction)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
@@ -30,19 +60,17 @@ namespace Octokit
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all reactions for a specified Issue
|
||||
/// Creates a reaction for a specified Issue
|
||||
/// </summary>
|
||||
/// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue</remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="number">The issue id</param>
|
||||
/// <returns></returns>
|
||||
public Task<IReadOnlyList<Reaction>> GetAll(string owner, string name, int number)
|
||||
/// <remarks>https://developer.github.com/v3/reactions/#create-reaction-for-an-issue</remarks>
|
||||
/// <param name="repositoryId">The ID of the repository</param>
|
||||
/// <param name="number">The issue id</param>
|
||||
/// <param name="reaction">The reaction to create</param>
|
||||
public Task<Reaction> Create(int repositoryId, int number, NewReaction reaction)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNull(reaction, "reaction");
|
||||
|
||||
return ApiConnection.GetAll<Reaction>(ApiUrls.IssueReactions(owner, name, number), AcceptHeaders.ReactionsPreview);
|
||||
return ApiConnection.Post<Reaction>(ApiUrls.IssueReactions(repositoryId, number), reaction, AcceptHeaders.ReactionsPreview);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,6 +330,17 @@ namespace Octokit
|
||||
return "repos/{0}/{1}/issues/{2}/reactions".FormatUri(owner, name, number);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> for the reaction of a specified issue.
|
||||
/// </summary>
|
||||
/// <param name="repositoryId">The ID of the repository</param>
|
||||
/// <param name="number">The issue number</param>
|
||||
/// <returns></returns>
|
||||
public static Uri IssueReactions(int repositoryId, int number)
|
||||
{
|
||||
return "repositories/{0}/issues/{1}/reactions".FormatUri(repositoryId, number);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> for the comments for all issues in a specific repo.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user