Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add repositoryId overloads to methods on I(Observable)RepositoryCommentsClient #1344

Merged
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 83 additions & 1 deletion Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

namespace Octokit.Reactive
{
/// <summary>
/// A 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>
public interface IObservableRepositoryCommentsClient
{
/// <summary>
Expand All @@ -15,9 +21,20 @@ public interface IObservableRepositoryCommentsClient
/// <param name="number">The comment id</param>
/// <returns></returns>
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get",
Justification = "Method makes a network request")]
Justification = "Method makes a network request")]
IObservable<CommitComment> Get(string owner, string name, int number);

/// <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="repositoryId">The ID of the repository</param>
/// <param name="number">The comment id</param>
/// <returns></returns>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies, I should have been clearer - the whole <returns></returns> element can be removed from these docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shiftkey done 👍

[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get",
Justification = "Method makes a network request")]
IObservable<CommitComment> Get(int repositoryId, int number);

/// <summary>
/// Gets Commit Comments for a repository.
/// </summary>
Expand All @@ -27,6 +44,14 @@ public interface IObservableRepositoryCommentsClient
/// <returns></returns>
IObservable<CommitComment> GetAllForRepository(string owner, string name);

/// <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="repositoryId">The ID of the repository</param>
/// <returns></returns>
IObservable<CommitComment> GetAllForRepository(int repositoryId);

/// <summary>
/// Gets Commit Comments for a repository.
/// </summary>
Expand All @@ -37,6 +62,15 @@ public interface IObservableRepositoryCommentsClient
/// <returns></returns>
IObservable<CommitComment> GetAllForRepository(string owner, string name, ApiOptions options);

/// <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="repositoryId">The ID of the repository</param>
/// <param name="options">Options to change the API response</param>
/// <returns></returns>
IObservable<CommitComment> GetAllForRepository(int repositoryId, ApiOptions options);

/// <summary>
/// Gets Commit Comments for a specified Commit.
/// </summary>
Expand All @@ -47,6 +81,15 @@ public interface IObservableRepositoryCommentsClient
/// <returns></returns>
IObservable<CommitComment> GetAllForCommit(string owner, string name, string sha);

/// <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="repositoryId">The ID of the repository</param>
/// <param name="sha">The sha of the commit</param>
/// <returns></returns>
IObservable<CommitComment> GetAllForCommit(int repositoryId, string sha);

/// <summary>
/// Gets Commit Comments for a specified Commit.
/// </summary>
Expand All @@ -58,6 +101,16 @@ public interface IObservableRepositoryCommentsClient
/// <returns></returns>
IObservable<CommitComment> GetAllForCommit(string owner, string name, string sha, ApiOptions options);

/// <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="repositoryId">The ID of the repository</param>
/// <param name="sha">The sha of the commit</param>
/// <param name="options">Options to change the API response</param>
/// <returns></returns>
IObservable<CommitComment> GetAllForCommit(int repositoryId, string sha, ApiOptions options);

/// <summary>
/// Creates a new Commit Comment for a specified Commit.
/// </summary>
Expand All @@ -69,6 +122,16 @@ public interface IObservableRepositoryCommentsClient
/// <returns></returns>
IObservable<CommitComment> Create(string owner, string name, string sha, NewCommitComment newCommitComment);

/// <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="repositoryId">The ID 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(int repositoryId, string sha, NewCommitComment newCommitComment);

/// <summary>
/// Updates a specified Commit Comment.
/// </summary>
Expand All @@ -80,6 +143,16 @@ public interface IObservableRepositoryCommentsClient
/// <returns></returns>
IObservable<CommitComment> Update(string owner, string name, int number, string commentUpdate);

/// <summary>
/// Updates a specified Commit Comment.
/// </summary>
/// <remarks>http://developer.github.com/v3/repos/comments/#update-a-commit-comment</remarks>
/// <param name="repositoryId">The ID of the repository</param>
/// <param name="number">The comment number</param>
/// <param name="commentUpdate">The modified comment</param>
/// <returns></returns>
IObservable<CommitComment> Update(int repositoryId, int number, string commentUpdate);

/// <summary>
/// Deletes the specified Commit Comment
/// </summary>
Expand All @@ -89,5 +162,14 @@ public interface IObservableRepositoryCommentsClient
/// <param name="number">The comment id</param>
/// <returns></returns>
IObservable<Unit> Delete(string owner, string name, int number);

/// <summary>
/// Deletes the specified Commit Comment
/// </summary>
/// <remarks>http://developer.github.com/v3/repos/comments/#delete-a-commit-comment</remarks>
/// <param name="repositoryId">The ID of the repository</param>
/// <param name="number">The comment id</param>
/// <returns></returns>
IObservable<Unit> Delete(int repositoryId, int number);
}
}
130 changes: 123 additions & 7 deletions Octokit.Reactive/Clients/ObservableRepositoryCommentsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@

namespace Octokit.Reactive
{
/// <summary>
/// A 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>
public class ObservableRepositoryCommentsClient : IObservableRepositoryCommentsClient
{
readonly IRepositoryCommentsClient _client;
readonly IConnection _connection;

public ObservableRepositoryCommentsClient(IGitHubClient client)
{
Ensure.ArgumentNotNull(client, "client");
Expand All @@ -21,10 +27,10 @@ public ObservableRepositoryCommentsClient(IGitHubClient client)
/// <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>
/// <remarks>http://developer.github.com/v3/repos/comments/#get-a-single-commit-comment</remarks>
/// <returns></returns>
public IObservable<CommitComment> Get(string owner, string name, int number)
{
Expand All @@ -34,12 +40,24 @@ public IObservable<CommitComment> Get(string owner, string name, int number)
return _client.Get(owner, name, number).ToObservable();
}

/// <summary>
/// Gets a single Repository Comment by number.
/// </summary>
/// <param name="repositoryId">The ID of the repository</param>
/// <param name="number">The comment id</param>
/// <remarks>http://developer.github.com/v3/repos/comments/#get-a-single-commit-comment</remarks>
/// <returns></returns>
public IObservable<CommitComment> Get(int repositoryId, int number)
{
return _client.Get(repositoryId, 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>
/// <remarks>http://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository</remarks>
/// <returns></returns>
public IObservable<CommitComment> GetAllForRepository(string owner, string name)
{
Expand All @@ -52,10 +70,21 @@ public IObservable<CommitComment> GetAllForRepository(string owner, string name)
/// <summary>
/// Gets Commit Comments for a repository.
/// </summary>
/// <param name="repositoryId">The ID of the repository</param>
/// <remarks>http://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository</remarks>
/// <returns></returns>
public IObservable<CommitComment> GetAllForRepository(int repositoryId)
{
return GetAllForRepository(repositoryId, ApiOptions.None);
}

/// <summary>
/// Gets Commit Comments for a repository.
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="options">Options to change the API response</param>
/// <remarks>http://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository</remarks>
/// <returns></returns>
public IObservable<CommitComment> GetAllForRepository(string owner, string name, ApiOptions options)
{
Expand All @@ -66,13 +95,27 @@ public IObservable<CommitComment> GetAllForRepository(string owner, string name,
return _connection.GetAndFlattenAllPages<CommitComment>(ApiUrls.CommitComments(owner, name), options);
}

/// <summary>
/// Gets Commit Comments for a repository.
/// </summary>
/// <param name="repositoryId">The ID of the repository</param>
/// <param name="options">Options to change the API response</param>
/// <remarks>http://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository</remarks>
/// <returns></returns>
public IObservable<CommitComment> GetAllForRepository(int repositoryId, ApiOptions options)
{
Ensure.ArgumentNotNull(options, "options");

return _connection.GetAndFlattenAllPages<CommitComment>(ApiUrls.CommitComments(repositoryId), options);
}

/// <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="sha">The sha of the commit</param>
/// <remarks>http://developer.github.com/v3/repos/comments/#list-comments-for-a-single-commit</remarks>
/// <returns></returns>
public IObservable<CommitComment> GetAllForCommit(string owner, string name, string sha)
{
Expand All @@ -86,11 +129,25 @@ public IObservable<CommitComment> GetAllForCommit(string owner, string name, str
/// <summary>
/// Gets Commit Comments for a specified Commit.
/// </summary>
/// <param name="repositoryId">The ID of the repository</param>
/// <param name="sha">The sha of the commit</param>
/// <remarks>http://developer.github.com/v3/repos/comments/#list-comments-for-a-single-commit</remarks>
/// <returns></returns>
public IObservable<CommitComment> GetAllForCommit(int repositoryId, string sha)
{
Ensure.ArgumentNotNullOrEmptyString(sha, "sha");

return GetAllForCommit(repositoryId, sha, ApiOptions.None);
}

/// <summary>
/// Gets Commit Comments for a specified Commit.
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="sha">The sha of the commit</param>
/// <param name="options">Options to change the API response</param>
/// <remarks>http://developer.github.com/v3/repos/comments/#list-comments-for-a-single-commit</remarks>
/// <returns></returns>
public IObservable<CommitComment> GetAllForCommit(string owner, string name, string sha, ApiOptions options)
{
Expand All @@ -102,14 +159,30 @@ public IObservable<CommitComment> GetAllForCommit(string owner, string name, str
return _connection.GetAndFlattenAllPages<CommitComment>(ApiUrls.CommitComments(owner, name, sha), options);
}

/// <summary>
/// Gets Commit Comments for a specified Commit.
/// </summary>
/// <param name="repositoryId">The ID of the repository</param>
/// <param name="sha">The sha of the commit</param>
/// <param name="options">Options to change the API response</param>
/// <remarks>http://developer.github.com/v3/repos/comments/#list-comments-for-a-single-commit</remarks>
/// <returns></returns>
public IObservable<CommitComment> GetAllForCommit(int repositoryId, string sha, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(sha, "sha");
Ensure.ArgumentNotNull(options, "options");

return _connection.GetAndFlattenAllPages<CommitComment>(ApiUrls.CommitComments(repositoryId, sha), options);
}

/// <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>
/// <remarks>http://developer.github.com/v3/repos/comments/#create-a-commit-comment</remarks>
/// <returns></returns>
public IObservable<CommitComment> Create(string owner, string name, string sha, NewCommitComment newCommitComment)
{
Expand All @@ -121,14 +194,30 @@ public IObservable<CommitComment> Create(string owner, string name, string sha,
return _client.Create(owner, name, sha, newCommitComment).ToObservable();
}

/// <summary>
/// Creates a new Commit Comment for a specified Commit.
/// </summary>
/// <param name="repositoryId">The ID 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>
/// <remarks>http://developer.github.com/v3/repos/comments/#create-a-commit-comment</remarks>
/// <returns></returns>
public IObservable<CommitComment> Create(int repositoryId, string sha, NewCommitComment newCommitComment)
{
Ensure.ArgumentNotNullOrEmptyString(sha, "sha");
Ensure.ArgumentNotNull(newCommitComment, "newCommitComment");

return _client.Create(repositoryId, 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>
/// <remarks>http://developer.github.com/v3/repos/comments/#update-a-commit-comment</remarks>
/// <returns></returns>
public IObservable<CommitComment> Update(string owner, string name, int number, string commentUpdate)
{
Expand All @@ -139,13 +228,28 @@ public IObservable<CommitComment> Update(string owner, string name, int number,
return _client.Update(owner, name, number, commentUpdate).ToObservable();
}

/// <summary>
/// Updates a specified Commit Comment.
/// </summary>
/// <param name="repositoryId">The ID of the repository</param>
/// <param name="number">The comment number</param>
/// <param name="commentUpdate">The modified comment</param>
/// <remarks>http://developer.github.com/v3/repos/comments/#update-a-commit-comment</remarks>
/// <returns></returns>
public IObservable<CommitComment> Update(int repositoryId, int number, string commentUpdate)
{
Ensure.ArgumentNotNull(commentUpdate, "commentUpdate");

return _client.Update(repositoryId, 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>
/// <remarks>http://developer.github.com/v3/repos/comments/#delete-a-commit-comment</remarks>
/// <returns></returns>
public IObservable<Unit> Delete(string owner, string name, int number)
{
Expand All @@ -154,5 +258,17 @@ public IObservable<Unit> Delete(string owner, string name, int number)

return _client.Delete(owner, name, number).ToObservable();
}

/// <summary>
/// Deletes the specified Commit Comment
/// </summary>
/// <param name="repositoryId">The ID of the repository</param>
/// <param name="number">The comment id</param>
/// <remarks>http://developer.github.com/v3/repos/comments/#delete-a-commit-comment</remarks>
/// <returns></returns>
public IObservable<Unit> Delete(int repositoryId, int number)
{
return _client.Delete(repositoryId, number).ToObservable();
}
}
}
Loading