using System;
using System.Reactive;
using System.Reactive.Threading.Tasks;
using Octokit.Reactive.Internal;
namespace Octokit.Reactive
{
///
/// A client for GitHub's Reactions API.
///
///
/// See the Reactions API documentation for more information.
///
public class ObservableIssueCommentReactionsClient : IObservableIssueCommentReactionsClient
{
readonly IIssueCommentReactionsClient _client;
readonly IConnection _connection;
public ObservableIssueCommentReactionsClient(IGitHubClient client)
{
Ensure.ArgumentNotNull(client, nameof(client));
_client = client.Reaction.IssueComment;
_connection = client.Connection;
}
///
/// Creates a reaction for a specified Issue Comment
///
/// https://developer.github.com/v3/reactions/#create-reaction-for-an-issue-comment
/// The owner of the repository
/// The name of the repository
/// The comment id
/// The reaction to create
public IObservable Create(string owner, string name, long commentId, NewReaction reaction)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(reaction, nameof(reaction));
return _client.Create(owner, name, commentId, reaction).ToObservable();
}
///
/// Creates a reaction for a specified Issue Comment
///
/// https://developer.github.com/v3/reactions/#create-reaction-for-an-issue-comment
/// The Id of the repository
/// The comment id
/// The reaction to create
public IObservable Create(long repositoryId, long commentId, NewReaction reaction)
{
Ensure.ArgumentNotNull(reaction, nameof(reaction));
return _client.Create(repositoryId, commentId, reaction).ToObservable();
}
///
/// List reactions for a specified Issue Comment
///
/// https://developer.github.com/v3/reactions/#list-reactions-for-an-issue-comment
/// The owner of the repository
/// The name of the repository
/// The comment id
public IObservable GetAll(string owner, string name, long commentId)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
return GetAll(owner, name, commentId, ApiOptions.None);
}
///
/// List reactions for a specified Issue Comment
///
/// https://developer.github.com/v3/reactions/#list-reactions-for-an-issue-comment
/// The owner of the repository
/// The name of the repository
/// The comment id
/// Options for changing the API response
public IObservable GetAll(string owner, string name, long commentId, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(options, nameof(options));
return _connection.GetAndFlattenAllPages(ApiUrls.IssueCommentReactions(owner, name, commentId), null, options);
}
///
/// List reactions for a specified Issue Comment
///
/// https://developer.github.com/v3/reactions/#list-reactions-for-an-issue-comment
/// The Id of the repository
/// The comment id
public IObservable GetAll(long repositoryId, long commentId)
{
return GetAll(repositoryId, commentId, ApiOptions.None);
}
///
/// List reactions for a specified Issue Comment
///
/// https://developer.github.com/v3/reactions/#list-reactions-for-an-issue-comment
/// The Id of the repository
/// The comment id
/// Options for changing the API response
public IObservable GetAll(long repositoryId, long commentId, ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));
return _connection.GetAndFlattenAllPages(ApiUrls.IssueCommentReactions(repositoryId, commentId), null, options);
}
///
/// Deletes a reaction for a specified Issue Comment
///
/// https://docs.github.com/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, long commentId, long 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/rest/reactions#delete-an-issue-comment-reaction
/// The Id of the repository
/// The comment id
/// The reaction id
///
public IObservable Delete(long repositoryId, long commentId, long reactionId)
{
Ensure.ArgumentNotNull(reactionId, nameof(reactionId));
return _client.Delete(repositoryId, commentId, reactionId).ToObservable();
}
}
}