From 8d2c2c58957a9c3a9dcd72073db99424d84f3b03 Mon Sep 17 00:00:00 2001 From: pltaylor Date: Mon, 4 Nov 2013 09:08:47 -0500 Subject: [PATCH] Create ObservableIssueCommentsClient --- .../Clients/ObservableIssueCommentsClient.cs | 108 ++++++++++++++++++ Octokit.Reactive/Octokit.Reactive.csproj | 1 + Octokit/Clients/IssueCommentsClient.cs | 1 - 3 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 Octokit.Reactive/Clients/ObservableIssueCommentsClient.cs diff --git a/Octokit.Reactive/Clients/ObservableIssueCommentsClient.cs b/Octokit.Reactive/Clients/ObservableIssueCommentsClient.cs new file mode 100644 index 00000000..d780f81b --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableIssueCommentsClient.cs @@ -0,0 +1,108 @@ +using System; + +namespace Octokit.Reactive.Clients +{ + class ObservableIssueCommentsClient : IObservableIssueCommentsClient + { + readonly IConnection _connection; + + public ObservableIssueCommentsClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, "client"); + + _connection = client.Connection; + } + /// + /// Gets a single Issue Comment by number. + /// + /// + /// http://developer.github.com/v3/issues/comments/#get-a-single-comment + /// + /// The owner of the repository + /// The name of the repository + /// The issue comment number + /// The s for the specified Issue Comment. + public IObservable Get(string owner, string name, int number) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return _connection.Get(ApiUrls.IssueComment(owner, name, number)); + } + + /// + /// Gets a list of the Issue Comments in a specified repository. + /// + /// + /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository + /// + /// The owner of the repository + /// The name of the repository + /// The list of s for the specified Repository. + public IObservable> GetForRepository(string owner, string name) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return _connection.GetAll(ApiUrls.IssueComments(owner, name)); + } + + /// + /// Gets a list of the Issue Comments for a specified issue. + /// + /// + /// http://developer.github.com/v3/issues/comments/#list-comments-on-an-issue + /// + /// The owner of the repository + /// The name of the repository + /// The issue number + /// The list of s for the specified Issue. + public IObservable> GetForIssue(string owner, string name, int number) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return _connection.GetAll(ApiUrls.IssueComments(owner, name, number)); + } + + /// + /// Creates a new Issue Comment in the specified Issue + /// + /// + /// http://developer.github.com/v3/issues/comments/#create-a-comment + /// + /// The owner of the repository + /// The name of the repository + /// The issue number + /// The text of the new comment + /// The s for that was just created. + public IObservable Create(string owner, string name, int number, string newComment) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(newComment, "newComment"); + + return _connection.Post(ApiUrls.IssueComments(owner, name, number), newComment); + } + + /// + /// Updates a specified Issue Comment + /// + /// + /// http://developer.github.com/v3/issues/comments/#edit-a-comment + /// + /// The owner of the repository + /// The name of the repository + /// The issue number + /// The text of the updated comment + /// The s for that was just updated. + public IObservable Update(string owner, string name, int number, string commentUpdate) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(commentUpdate, "commentUpdate"); + + return _connection.Patch(ApiUrls.IssueComment(owner, name, number), commentUpdate); + } + } +} diff --git a/Octokit.Reactive/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj index 3f4aa361..218e0754 100644 --- a/Octokit.Reactive/Octokit.Reactive.csproj +++ b/Octokit.Reactive/Octokit.Reactive.csproj @@ -84,6 +84,7 @@ + diff --git a/Octokit/Clients/IssueCommentsClient.cs b/Octokit/Clients/IssueCommentsClient.cs index 228210d1..895a0d8e 100644 --- a/Octokit/Clients/IssueCommentsClient.cs +++ b/Octokit/Clients/IssueCommentsClient.cs @@ -56,7 +56,6 @@ namespace Octokit /// The list of s for the specified Issue. public Task> GetForIssue(string owner, string name, int number) { - Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name");