using System.Collections.Generic;
using System.Threading.Tasks;
namespace Octokit
{
///
/// A client for GitHub's Reactions API.
///
///
/// See the Reactions API documentation for more information.
///
public class IssueReactionsClient : ApiClient, IIssueReactionsClient
{
public IssueReactionsClient(IApiConnection apiConnection)
: base(apiConnection)
{
}
///
/// Get all reactions for a specified Issue
///
/// https://developer.github.com/v3/reactions/#list-reactions-for-an-issue
/// The owner of the repository
/// The name of the repository
/// The issue id
[ManualRoute("GET", "/repos/{owner}/{repo}/issues/{issue_number}/reactions")]
public Task> GetAll(string owner, string name, int number)
{
return GetAll(owner, name, number, ApiOptions.None);
}
///
/// Get all reactions for a specified Issue
///
/// https://developer.github.com/v3/reactions/#list-reactions-for-an-issue
/// The owner of the repository
/// The name of the repository
/// The issue id
/// Options for changing the API response
[ManualRoute("GET", "/repos/{owner}/{repo}/issues/{issue_number}/reactions")]
public Task> GetAll(string owner, string name, int number, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(options, nameof(options));
return ApiConnection.GetAll(ApiUrls.IssueReactions(owner, name, number), null, options);
}
///
/// Get all reactions for a specified Issue
///
/// https://developer.github.com/v3/reactions/#list-reactions-for-an-issue
/// The Id of the repository
/// The issue id
[ManualRoute("GET", "/repositories/{id}/issues/{number}/reactions")]
public Task> GetAll(long repositoryId, int number)
{
return GetAll(repositoryId, number, ApiOptions.None);
}
///
/// Get all reactions for a specified Issue
///
/// https://developer.github.com/v3/reactions/#list-reactions-for-an-issue
/// The Id of the repository
/// The issue id
/// Options for changing the API response
[ManualRoute("GET", "/repositories/{id}/issues/{number}/reactions")]
public Task> GetAll(long repositoryId, int number, ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));
return ApiConnection.GetAll(ApiUrls.IssueReactions(repositoryId, number), null, options);
}
///
/// Creates a reaction for a specified Issue
///
/// https://developer.github.com/v3/reactions/#create-reaction-for-an-issue
/// The owner of the repository
/// The name of the repository
/// The issue id
/// The reaction to create
[ManualRoute("POST", "/repos/{owner}/{repo}/issues/{issue_number}/reactions")]
public Task Create(string owner, string name, int number, NewReaction reaction)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(reaction, nameof(reaction));
return ApiConnection.Post(ApiUrls.IssueReactions(owner, name, number), reaction);
}
///
/// Creates a reaction for a specified Issue
///
/// https://developer.github.com/v3/reactions/#create-reaction-for-an-issue
/// The Id of the repository
/// The issue id
/// The reaction to create
[ManualRoute("POST", "/repositories/{id}/issues/{number}/reactions")]
public Task Create(long repositoryId, int number, NewReaction reaction)
{
Ensure.ArgumentNotNull(reaction, nameof(reaction));
return ApiConnection.Post(ApiUrls.IssueReactions(repositoryId, number), reaction);
}
///
/// Deletes a reaction for a specified Issue
///
/// https://docs.github.com/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, long 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/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, long reactionId)
{
return ApiConnection.Delete(ApiUrls.IssueReaction(repositoryId, issueNumber, reactionId));
}
}
}