using System;
using System.Reactive;
using System.Reactive.Threading.Tasks;
using Octokit.Reactive.Internal;
namespace Octokit.Reactive
{
///
/// A client for GitHub's Pull Request Review Comments API.
///
///
/// See the Review Comments API documentation for more information.
///
public class ObservablePullRequestReviewCommentsClient : IObservablePullRequestReviewCommentsClient
{
readonly IPullRequestReviewCommentsClient _client;
readonly IConnection _connection;
public ObservablePullRequestReviewCommentsClient(IGitHubClient client)
{
Ensure.ArgumentNotNull(client, nameof(client));
_client = client.PullRequest.ReviewComment;
_connection = client.Connection;
}
///
/// Gets review comments for a specified pull request.
///
/// http://developer.github.com/v3/pulls/comments/#list-comments-on-a-pull-request
/// The owner of the repository
/// The name of the repository
/// The pull request number
public IObservable GetAll(string owner, string name, int number)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
return GetAll(owner, name, number, ApiOptions.None);
}
///
/// Gets review comments for a specified pull request.
///
/// http://developer.github.com/v3/pulls/comments/#list-comments-on-a-pull-request
/// The Id of the repository
/// The pull request number
public IObservable GetAll(long repositoryId, int number)
{
return GetAll(repositoryId, number, ApiOptions.None);
}
///
/// Gets review comments for a specified pull request.
///
/// http://developer.github.com/v3/pulls/comments/#list-comments-on-a-pull-request
/// The owner of the repository
/// The name of the repository
/// The pull request number
/// Options for changing the API response
public IObservable 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 _connection.GetAndFlattenAllPages(ApiUrls.PullRequestReviewComments(owner, name, number), null, AcceptHeaders.ReactionsPreview, options);
}
///
/// Gets review comments for a specified pull request.
///
/// http://developer.github.com/v3/pulls/comments/#list-comments-on-a-pull-request
/// The Id of the repository
/// The pull request number
/// Options for changing the API response
public IObservable GetAll(long repositoryId, int number, ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));
return _connection.GetAndFlattenAllPages(ApiUrls.PullRequestReviewComments(repositoryId, number), options);
}
///
/// Gets a list of the pull request review comments in a specified repository.
///
/// http://developer.github.com/v3/pulls/comments/#list-comments-in-a-repository
/// The owner of the repository
/// The name of the repository
public IObservable GetAllForRepository(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
return GetAllForRepository(owner, name, new PullRequestReviewCommentRequest(), ApiOptions.None);
}
///
/// Gets a list of the pull request review comments in a specified repository.
///
/// http://developer.github.com/v3/pulls/comments/#list-comments-in-a-repository
/// The Id of the repository
public IObservable GetAllForRepository(long repositoryId)
{
return GetAllForRepository(repositoryId, new PullRequestReviewCommentRequest(), ApiOptions.None);
}
///
/// Gets a list of the pull request review comments in a specified repository.
///
/// http://developer.github.com/v3/pulls/comments/#list-comments-in-a-repository
/// The owner of the repository
/// The name of the repository
/// Options for changing the API response
public IObservable GetAllForRepository(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(options, nameof(options));
return GetAllForRepository(owner, name, new PullRequestReviewCommentRequest(), options);
}
///
/// Gets a list of the pull request review comments in a specified repository.
///
/// http://developer.github.com/v3/pulls/comments/#list-comments-in-a-repository
/// The Id of the repository
/// Options for changing the API response
public IObservable GetAllForRepository(long repositoryId, ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));
return GetAllForRepository(repositoryId, new PullRequestReviewCommentRequest(), options);
}
///
/// Gets a list of the pull request review comments in a specified repository.
///
/// http://developer.github.com/v3/pulls/comments/#list-comments-in-a-repository
/// The owner of the repository
/// The name of the repository
/// The sorting parameters
public IObservable GetAllForRepository(string owner, string name, PullRequestReviewCommentRequest request)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(request, nameof(request));
return GetAllForRepository(owner, name, request, ApiOptions.None);
}
///
/// Gets a list of the pull request review comments in a specified repository.
///
/// http://developer.github.com/v3/pulls/comments/#list-comments-in-a-repository
/// The Id of the repository
/// The sorting parameters
public IObservable GetAllForRepository(long repositoryId, PullRequestReviewCommentRequest request)
{
Ensure.ArgumentNotNull(request, nameof(request));
return GetAllForRepository(repositoryId, request, ApiOptions.None);
}
///
/// Gets a list of the pull request review comments in a specified repository.
///
/// http://developer.github.com/v3/pulls/comments/#list-comments-in-a-repository
/// The owner of the repository
/// The name of the repository
/// The sorting parameters
/// Options for changing the API response
public IObservable GetAllForRepository(string owner, string name, PullRequestReviewCommentRequest request, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(request, nameof(request));
Ensure.ArgumentNotNull(options, nameof(options));
return _connection.GetAndFlattenAllPages(ApiUrls.PullRequestReviewCommentsRepository(owner, name), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview,
options);
}
///
/// Gets a list of the pull request review comments in a specified repository.
///
/// http://developer.github.com/v3/pulls/comments/#list-comments-in-a-repository
/// The Id of the repository
/// The sorting parameters
/// Options for changing the API response
public IObservable GetAllForRepository(long repositoryId, PullRequestReviewCommentRequest request, ApiOptions options)
{
Ensure.ArgumentNotNull(request, nameof(request));
Ensure.ArgumentNotNull(options, nameof(options));
return _connection.GetAndFlattenAllPages(
ApiUrls.PullRequestReviewCommentsRepository(repositoryId),
request.ToParametersDictionary(),
AcceptHeaders.ReactionsPreview,
options);
}
///
/// Gets a single pull request review comment by number.
///
/// http://developer.github.com/v3/pulls/comments/#get-a-single-comment
/// The owner of the repository
/// The name of the repository
/// The pull request review comment number
public IObservable GetComment(string owner, string name, int number)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
return _client.GetComment(owner, name, number).ToObservable();
}
///
/// Gets a single pull request review comment by number.
///
/// http://developer.github.com/v3/pulls/comments/#get-a-single-comment
/// The Id of the repository
/// The pull request review comment number
public IObservable GetComment(long repositoryId, int number)
{
return _client.GetComment(repositoryId, number).ToObservable();
}
///
/// Creates a comment on a pull request review.
///
/// http://developer.github.com/v3/pulls/comments/#create-a-comment
/// The owner of the repository
/// The name of the repository
/// The Pull Request number
/// The comment
public IObservable Create(string owner, string name, int number, PullRequestReviewCommentCreate comment)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(comment, nameof(comment));
return _client.Create(owner, name, number, comment).ToObservable();
}
///
/// Creates a comment on a pull request review.
///
/// http://developer.github.com/v3/pulls/comments/#create-a-comment
/// The Id of the repository
/// The Pull Request number
/// The comment
public IObservable Create(long repositoryId, int number, PullRequestReviewCommentCreate comment)
{
Ensure.ArgumentNotNull(comment, nameof(comment));
return _client.Create(repositoryId, number, comment).ToObservable();
}
///
/// Creates a comment on a pull request review as a reply to another comment.
///
/// http://developer.github.com/v3/pulls/comments/#create-a-comment
/// The owner of the repository
/// The name of the repository
/// The pull request number
/// The comment
public IObservable CreateReply(string owner, string name, int number, PullRequestReviewCommentReplyCreate comment)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(comment, nameof(comment));
return _client.CreateReply(owner, name, number, comment).ToObservable();
}
///
/// Creates a comment on a pull request review as a reply to another comment.
///
/// http://developer.github.com/v3/pulls/comments/#create-a-comment
/// The Id of the repository
/// The pull request number
/// The comment
public IObservable CreateReply(long repositoryId, int number, PullRequestReviewCommentReplyCreate comment)
{
Ensure.ArgumentNotNull(comment, nameof(comment));
return _client.CreateReply(repositoryId, number, comment).ToObservable();
}
///
/// Edits a comment on a pull request review.
///
/// http://developer.github.com/v3/pulls/comments/#edit-a-comment
/// The owner of the repository
/// The name of the repository
/// The pull request review comment number
/// The edited comment
public IObservable Edit(string owner, string name, int number, PullRequestReviewCommentEdit comment)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(comment, nameof(comment));
return _client.Edit(owner, name, number, comment).ToObservable();
}
///
/// Edits a comment on a pull request review.
///
/// http://developer.github.com/v3/pulls/comments/#edit-a-comment
/// The Id of the repository
/// The pull request review comment number
/// The edited comment
public IObservable Edit(long repositoryId, int number, PullRequestReviewCommentEdit comment)
{
Ensure.ArgumentNotNull(comment, nameof(comment));
return _client.Edit(repositoryId, number, comment).ToObservable();
}
///
/// Deletes a comment on a pull request review.
///
/// http://developer.github.com/v3/pulls/comments/#delete-a-comment
/// The owner of the repository
/// The name of the repository
/// The pull request review comment number
public IObservable Delete(string owner, string name, int number)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
return _client.Delete(owner, name, number).ToObservable();
}
///
/// Deletes a comment on a pull request review.
///
/// http://developer.github.com/v3/pulls/comments/#delete-a-comment
/// The Id of the repository
/// The pull request review comment number
public IObservable Delete(long repositoryId, int number)
{
return _client.Delete(repositoryId, number).ToObservable();
}
}
}