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, "client");
_client = client.PullRequest.Comment;
_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, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "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(int 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, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(options, "options");
return _connection.GetAndFlattenAllPages(ApiUrls.PullRequestReviewComments(owner, name, number), 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(int repositoryId, int number, ApiOptions options)
{
Ensure.ArgumentNotNull(options, "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, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "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(int 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, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(options, "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(int repositoryId, ApiOptions options)
{
Ensure.ArgumentNotNull(options, "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, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(request, "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(int repositoryId, PullRequestReviewCommentRequest request)
{
Ensure.ArgumentNotNull(request, "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, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(request, "request");
Ensure.ArgumentNotNull(options, "options");
return _connection.GetAndFlattenAllPages(ApiUrls.PullRequestReviewCommentsRepository(owner, name), request.ToParametersDictionary(),
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(int repositoryId, PullRequestReviewCommentRequest request, ApiOptions options)
{
Ensure.ArgumentNotNull(request, "request");
Ensure.ArgumentNotNull(options, "options");
return _connection.GetAndFlattenAllPages(ApiUrls.PullRequestReviewCommentsRepository(repositoryId), request.ToParametersDictionary(),
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, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "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(int 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, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(comment, "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(int repositoryId, int number, PullRequestReviewCommentCreate comment)
{
Ensure.ArgumentNotNull(comment, "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, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(comment, "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(int repositoryId, int number, PullRequestReviewCommentReplyCreate comment)
{
Ensure.ArgumentNotNull(comment, "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, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(comment, "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(int repositoryId, int number, PullRequestReviewCommentEdit comment)
{
Ensure.ArgumentNotNull(comment, "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, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "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(int repositoryId, int number)
{
return _client.Delete(repositoryId, number).ToObservable();
}
}
}