Add IObservableRepositoryCommentsClient as well as an implementation

This commit is contained in:
Will Froese
2014-02-27 22:04:26 -05:00
parent be24239564
commit 082658083c
12 changed files with 232 additions and 2 deletions
@@ -116,6 +116,14 @@ namespace Octokit.Reactive
///</remarks>
IObservableStatisticsClient Statistics { get; }
/// <summary>
/// Client for GitHub's Repository Comments API.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/comments/">Repository Comments API documentation</a> for more information.
/// </remarks>
IObservableRepositoryCommentsClient RepositoryComments { get; }
/// <summary>
/// Gets all the branches for the specified repository.
/// </summary>
@@ -0,0 +1,72 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Reactive;
namespace Octokit.Reactive
{
public interface IObservableRepositoryCommentsClient
{
/// <summary>
/// Gets a single Repository Comment by number.
/// </summary>
/// <remarks>http://developer.github.com/v3/repos/comments/#get-a-single-commit-comment</remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="number">The comment id</param>
/// <returns></returns>
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get",
Justification = "Method makes a network request")]
IObservable<CommitComment> Get(string owner, string name, int number);
/// <summary>
/// Gets Commit Comments for a repository.
/// </summary>
/// <remarks>http://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository</remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <returns></returns>
IObservable<CommitComment> GetForRepository(string owner, string name);
/// <summary>
/// Gets Commit Comments for a specified Commit.
/// </summary>
/// <remarks>http://developer.github.com/v3/repos/comments/#list-comments-for-a-single-commit</remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="number">The sha of the commit</param>
/// <returns></returns>
IObservable<CommitComment> GetForCommit(string owner, string name, string sha);
/// <summary>
/// Creates a new Commit Comment for a specified Commit.
/// </summary>
/// <remarks>http://developer.github.com/v3/repos/comments/#create-a-commit-comment</remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="sha">The sha reference of commit</param>
/// <param name="newCommitComment">The new comment to add to the commit</param>
/// <returns></returns>
IObservable<CommitComment> Create(string owner, string name, string sha, NewCommitComment newCommitComment);
/// <summary>
/// Updates a specified Commit Comment.
/// </summary>
/// <remarks>http://developer.github.com/v3/repos/comments/#update-a-commit-comment</remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="number">The comment number</param>
/// <param name="commentUpdate">The modified comment</param>
/// <returns></returns>
IObservable<CommitComment> Update(string owner, string name, int number, string commentUpdate);
/// <summary>
/// Deletes the specified Commit Comment
/// </summary>
/// <remarks>http://developer.github.com/v3/repos/comments/#delete-a-commit-comment</remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="number">The comment id</param>
/// <returns></returns>
IObservable<Unit> Delete(string owner, string name, int number);
}
}
@@ -24,6 +24,7 @@ namespace Octokit.Reactive
Deployment = new ObservableDeploymentsClient(client);
Statistics = new ObservableStatisticsClient(client);
PullRequest = new ObservablePullRequestsClient(client);
RepositoryComments = new ObservableRepositoryCommentsClient(client);
}
/// <summary>
@@ -180,6 +181,8 @@ namespace Octokit.Reactive
///</remarks>
public IObservableStatisticsClient Statistics { get; private set; }
public IObservableRepositoryCommentsClient RepositoryComments { get; private set; }
/// <summary>
/// Gets all the branches for the specified repository.
/// </summary>
@@ -0,0 +1,122 @@
using System;
using System.Reactive;
using System.Reactive.Threading.Tasks;
using Octokit.Reactive.Internal;
namespace Octokit.Reactive
{
public class ObservableRepositoryCommentsClient : IObservableRepositoryCommentsClient
{
readonly IRepositoryCommentsClient _client;
readonly IConnection _connection;
public ObservableRepositoryCommentsClient(IGitHubClient client)
{
Ensure.ArgumentNotNull(client, "client");
_client = client.Repository.RepositoryComments;
_connection = client.Connection;
}
/// <summary>
/// Gets a single Repository Comment by number.
/// </summary>
/// <remarks>http://developer.github.com/v3/repos/comments/#get-a-single-commit-comment</remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="number">The comment id</param>
/// <returns></returns>
public IObservable<CommitComment> Get(string owner, string name, int number)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return _client.Get(owner, name, number).ToObservable();
}
/// <summary>
/// Gets Commit Comments for a repository.
/// </summary>
/// <remarks>http://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository</remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <returns></returns>
public IObservable<CommitComment> GetForRepository(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return _connection.GetAndFlattenAllPages<CommitComment>(ApiUrls.CommitComments(owner, name));
}
/// <summary>
/// Gets Commit Comments for a specified Commit.
/// </summary>
/// <remarks>http://developer.github.com/v3/repos/comments/#list-comments-for-a-single-commit</remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="number">The sha of the commit</param>
/// <returns></returns>
public IObservable<CommitComment> GetForCommit(string owner, string name, string sha)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNullOrEmptyString(sha, "sha");
return _connection.GetAndFlattenAllPages<CommitComment>(ApiUrls.CommitComments(owner, name, sha));
}
/// <summary>
/// Creates a new Commit Comment for a specified Commit.
/// </summary>
/// <remarks>http://developer.github.com/v3/repos/comments/#create-a-commit-comment</remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="sha">The sha reference of commit</param>
/// <param name="newCommitComment">The new comment to add to the commit</param>
/// <returns></returns>
public IObservable<CommitComment> Create(string owner, string name, string sha, NewCommitComment newCommitComment)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNullOrEmptyString(sha, "sha");
Ensure.ArgumentNotNull(newCommitComment, "newCommitComment");
return _client.Create(owner, name, sha, newCommitComment).ToObservable();
}
/// <summary>
/// Updates a specified Commit Comment.
/// </summary>
/// <remarks>http://developer.github.com/v3/repos/comments/#update-a-commit-comment</remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="number">The comment number</param>
/// <param name="commentUpdate">The modified comment</param>
/// <returns></returns>
public IObservable<CommitComment> Update(string owner, string name, int number, string commentUpdate)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(commentUpdate, "commentUpdate");
return _client.Update(owner, name, number, commentUpdate).ToObservable();
}
/// <summary>
/// Deletes the specified Commit Comment
/// </summary>
/// <remarks>http://developer.github.com/v3/repos/comments/#delete-a-commit-comment</remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="number">The comment id</param>
/// <returns></returns>
public IObservable<Unit> Delete(string owner, string name, int number)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return _client.Delete(owner, name, number).ToObservable();
}
}
}
@@ -139,6 +139,8 @@
<Compile Include="Clients\IObservableTeamsClient.cs" />
<Compile Include="Clients\ObservableTeamsClient.cs" />
<Compile Include="Clients\ObservableIssuesLabelsClient.cs" />
<Compile Include="Clients\IObservableRepositoryCommentsClient.cs" />
<Compile Include="Clients\ObservableRepositoryCommentsClient.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
@@ -148,6 +148,8 @@
<Compile Include="Clients\IObservableTeamsClient.cs" />
<Compile Include="Clients\ObservableTeamsClient.cs" />
<Compile Include="Clients\ObservableIssuesLabelsClient.cs" />
<Compile Include="Clients\IObservableRepositoryCommentsClient.cs" />
<Compile Include="Clients\ObservableRepositoryCommentsClient.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
<ItemGroup>
@@ -143,6 +143,8 @@
<Compile Include="Clients\IObservableTeamsClient.cs" />
<Compile Include="Clients\ObservableTeamsClient.cs" />
<Compile Include="Clients\ObservableIssuesLabelsClient.cs" />
<Compile Include="Clients\IObservableRepositoryCommentsClient.cs" />
<Compile Include="Clients\ObservableRepositoryCommentsClient.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
+2
View File
@@ -73,6 +73,8 @@
<Compile Include="..\SolutionInfo.cs">
<Link>Properties\SolutionInfo.cs</Link>
</Compile>
<Compile Include="Clients\ObservableRepositoryCommentsClient.cs" />
<Compile Include="Clients\IObservableRepositoryCommentsClient.cs" />
<Compile Include="Clients\IObservableDeploymentsClient.cs" />
<Compile Include="Clients\IObservableDeploymentStatusClient.cs" />
<Compile Include="Clients\IObservableFeedsClient.cs" />
+8
View File
@@ -22,6 +22,14 @@ namespace Octokit
/// </remarks>
IPullRequestsClient PullRequest { get; }
/// <summary>
/// Client for managing commit comments in a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/comments/">Repository Comments API documentation</a> for more information.
/// </remarks>
IRepositoryCommentsClient RepositoryComments { get; }
/// <summary>
/// Creates a new repository for the current user.
/// </summary>
+1 -1
View File
@@ -44,7 +44,7 @@ namespace Octokit
Task<IReadOnlyList<CommitComment>> GetForCommit(string owner, string name, string sha);
/// <summary>
/// Creates a new Commit Comment for a specified Issue.
/// Creates a new Commit Comment for a specified Commit.
/// </summary>
/// <remarks>http://developer.github.com/v3/repos/comments/#create-a-commit-comment</remarks>
/// <param name="owner">The owner of the repository</param>
+9
View File
@@ -27,6 +27,7 @@ namespace Octokit
Statistics = new StatisticsClient(apiConnection);
Deployment = new DeploymentsClient(apiConnection);
PullRequest = new PullRequestsClient(apiConnection);
RepositoryComments = new RepositoryCommentsClient(apiConnection);
}
/// <summary>
@@ -286,6 +287,14 @@ namespace Octokit
/// </remarks>
public IPullRequestsClient PullRequest { get; private set; }
/// <summary>
/// Client for managing commit comments in a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/comments/">Repository Comments API documentation</a> for more information.
/// </remarks>
public IRepositoryCommentsClient RepositoryComments { get; private set; }
/// <summary>
/// Gets all the branches for the specified repository.
/// </summary>
+1 -1
View File
@@ -70,7 +70,7 @@ namespace Octokit
}
/// <summary>
/// Creates a new Commit Comment for a specified Issue.
/// Creates a new Commit Comment for a specified Commit.
/// </summary>
/// <remarks>http://developer.github.com/v3/repos/comments/#create-a-commit-comment</remarks>
/// <param name="owner">The owner of the repository</param>