Files
octokit.net/Octokit/Clients/IssueReactionsClient.cs
aedampir@gmail.com 26ba6ddf25 burned <retunrs> tags
2016-07-06 02:38:05 +07:00

77 lines
3.4 KiB
C#

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)
: base(apiConnection)
{
}
/// <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-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>
public Task<Reaction> Create(string owner, string name, int number, NewReaction reaction)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(reaction, "reaction");
return ApiConnection.Post<Reaction>(ApiUrls.IssueReactions(owner, name, number), reaction, AcceptHeaders.ReactionsPreview);
}
/// <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>
public Task<Reaction> Create(int repositoryId, int number, NewReaction reaction)
{
Ensure.ArgumentNotNull(reaction, "reaction");
return ApiConnection.Post<Reaction>(ApiUrls.IssueReactions(repositoryId, number), reaction, AcceptHeaders.ReactionsPreview);
}
}
}