using System; 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 ObservableCommitCommentReactionsClient : IObservableCommitCommentReactionsClient { readonly ICommitCommentReactionsClient _client; readonly IConnection _connection; public ObservableCommitCommentReactionsClient(IGitHubClient client) { Ensure.ArgumentNotNull(client, "client"); _client = client.Reaction.CommitComment; _connection = client.Connection; } /// /// Creates a reaction for a specified Commit Comment /// /// https://developer.github.com/v3/reactions/#create-reaction-for-a-commit-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, int number, NewReaction reaction) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(reaction, "reaction"); return _client.Create(owner, name, number, reaction).ToObservable(); } /// /// Creates a reaction for a specified Commit Comment /// /// https://developer.github.com/v3/reactions/#create-reaction-for-a-commit-comment /// The ID of the repository /// The comment id /// The reaction to create /// public IObservable Create(int repositoryId, int number, NewReaction reaction) { Ensure.ArgumentNotNull(reaction, "reaction"); return _client.Create(repositoryId, number, reaction).ToObservable(); } /// /// List reactions for a specified Commit Comment /// /// https://developer.github.com/v3/reactions/#list-reactions-for-a-commit-comment /// The owner of the repository /// The name of the repository /// The comment id /// public IObservable GetAll(string owner, string name, int number) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); return _connection.GetAndFlattenAllPages(ApiUrls.CommitCommentReactions(owner, name, number), null, AcceptHeaders.ReactionsPreview); } /// /// List reactions for a specified Commit Comment /// /// https://developer.github.com/v3/reactions/#list-reactions-for-a-commit-comment /// The owner of the repository /// The comment id /// public IObservable GetAll(int repositoryId, int number) { return _connection.GetAndFlattenAllPages(ApiUrls.CommitCommentReactions(repositoryId, number), null, AcceptHeaders.ReactionsPreview); } } }