mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-09 04:56:29 +00:00
Merge pull request #1372 from dampir/add-repo-id-watched-client
Add repositoryId overloads to methods on I(Observable)WatchedClient
This commit is contained in:
@@ -3,6 +3,12 @@ using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Watching API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/activity/watching/">Watching API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public interface IObservableWatchedClient
|
||||
{
|
||||
/// <summary>
|
||||
@@ -11,9 +17,15 @@ namespace Octokit.Reactive
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
/// <returns>A <see cref="IObservable{User}"/> of <see cref="User"/>s watching the passed repository</returns>
|
||||
IObservable<User> GetAllWatchers(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the watchers for the passed repository
|
||||
/// </summary>
|
||||
/// <param name="repositoryId">The ID of the repository</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
IObservable<User> GetAllWatchers(int repositoryId);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the watchers for the passed repository
|
||||
/// </summary>
|
||||
@@ -21,14 +33,20 @@ namespace Octokit.Reactive
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="options">Options for changing the API's response.</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
/// <returns>A <see cref="IObservable{User}"/> of <see cref="User"/>s watching the passed repository</returns>
|
||||
IObservable<User> GetAllWatchers(string owner, string name, ApiOptions options);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the watchers for the passed repository
|
||||
/// </summary>
|
||||
/// <param name="repositoryId">The ID of the repository</param>
|
||||
/// <param name="options">Options for changing the API's response.</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
IObservable<User> GetAllWatchers(int repositoryId, ApiOptions options);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the watched <see cref="Repository"/>(ies) for the current user
|
||||
/// </summary>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
/// <returns>A <see cref="IObservable{Repository}"/> of <see cref="Repository"/></returns>
|
||||
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
|
||||
IObservable<Repository> GetAllForCurrent();
|
||||
|
||||
@@ -37,7 +55,6 @@ namespace Octokit.Reactive
|
||||
/// </summary>
|
||||
/// <param name="options">Options for changing the API's response.</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
/// <returns>A <see cref="IObservable{Repository}"/> of <see cref="Repository"/></returns>
|
||||
IObservable<Repository> GetAllForCurrent(ApiOptions options);
|
||||
|
||||
/// <summary>
|
||||
@@ -45,7 +62,6 @@ namespace Octokit.Reactive
|
||||
/// </summary>
|
||||
/// <param name="user">The login of the user</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
/// <returns>A <see cref="IObservable{Repository}"/> watched by the specified user</returns>
|
||||
IObservable<Repository> GetAllForUser(string user);
|
||||
|
||||
/// <summary>
|
||||
@@ -54,7 +70,6 @@ namespace Octokit.Reactive
|
||||
/// <param name="user">The login of the user</param>
|
||||
/// <param name="options">Options for changing the API's response.</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
/// <returns>A <see cref="IObservable{Repository}"/> watched by the specified user</returns>
|
||||
IObservable<Repository> GetAllForUser(string user, ApiOptions options);
|
||||
|
||||
/// <summary>
|
||||
@@ -63,26 +78,45 @@ namespace Octokit.Reactive
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
/// <returns>A <c>bool</c> representing the success of the operation</returns>
|
||||
IObservable<bool> CheckWatched(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Check if a repository is watched by the current authenticated user
|
||||
/// </summary>
|
||||
/// <param name="repositoryId">The ID of the repository</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
IObservable<bool> CheckWatched(int repositoryId);
|
||||
|
||||
/// <summary>
|
||||
/// Stars a repository for the authenticated user.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository to star</param>
|
||||
/// <param name="name">The name of the repository to star</param>
|
||||
/// <param name="newSubscription">A <see cref="NewSubscription"/> instance describing the new subscription to create</param>
|
||||
/// <returns>A <c>bool</c> representing the success of starring</returns>
|
||||
IObservable<Subscription> WatchRepo(string owner, string name, NewSubscription newSubscription);
|
||||
|
||||
/// <summary>
|
||||
/// Stars a repository for the authenticated user.
|
||||
/// </summary>
|
||||
/// <param name="repositoryId">The ID of the repository</param>
|
||||
/// <param name="newSubscription">A <see cref="NewSubscription"/> instance describing the new subscription to create</param>
|
||||
IObservable<Subscription> WatchRepo(int repositoryId, NewSubscription newSubscription);
|
||||
|
||||
/// <summary>
|
||||
/// Unstars a repository for the authenticated user.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository to unstar</param>
|
||||
/// <param name="name">The name of the repository to unstar</param>
|
||||
/// <returns>A <c>bool</c> representing the success of the operation</returns>
|
||||
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Unwatch",
|
||||
Justification = "Unwatch is consistent with the GitHub website")]
|
||||
IObservable<bool> UnwatchRepo(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Unstars a repository for the authenticated user.
|
||||
/// </summary>
|
||||
/// <param name="repositoryId">The ID of the repository</param>
|
||||
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Unwatch",
|
||||
Justification = "Unwatch is consistent with the GitHub website")]
|
||||
IObservable<bool> UnwatchRepo(int repositoryId);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,12 @@ using Octokit.Reactive.Internal;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Watching API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/activity/watching/">Watching API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public class ObservableWatchedClient : IObservableWatchedClient
|
||||
{
|
||||
private readonly IWatchedClient _client;
|
||||
@@ -23,7 +29,6 @@ namespace Octokit.Reactive
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
/// <returns>A <see cref="IObservable{User}"/> of <see cref="User"/>s watching the passed repository</returns>
|
||||
public IObservable<User> GetAllWatchers(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
@@ -32,6 +37,16 @@ namespace Octokit.Reactive
|
||||
return GetAllWatchers(owner, name, ApiOptions.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the watchers for the passed repository
|
||||
/// </summary>
|
||||
/// <param name="repositoryId">The ID of the repository</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
public IObservable<User> GetAllWatchers(int repositoryId)
|
||||
{
|
||||
return GetAllWatchers(repositoryId, ApiOptions.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the watchers for the passed repository
|
||||
/// </summary>
|
||||
@@ -39,7 +54,6 @@ namespace Octokit.Reactive
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="options">Options for changing the API's response.</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
/// <returns>A <see cref="IObservable{User}"/> of <see cref="User"/>s watching the passed repository</returns>
|
||||
public IObservable<User> GetAllWatchers(string owner, string name, ApiOptions options)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
@@ -49,11 +63,23 @@ namespace Octokit.Reactive
|
||||
return _connection.GetAndFlattenAllPages<User>(ApiUrls.Watchers(owner, name), options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the watchers for the passed repository
|
||||
/// </summary>
|
||||
/// <param name="repositoryId">The ID of the repository</param>
|
||||
/// <param name="options">Options for changing the API's response.</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
public IObservable<User> GetAllWatchers(int repositoryId, ApiOptions options)
|
||||
{
|
||||
Ensure.ArgumentNotNull(options, "options");
|
||||
|
||||
return _connection.GetAndFlattenAllPages<User>(ApiUrls.Watchers(repositoryId), options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the watched <see cref="Repository"/>(ies) for the current user
|
||||
/// </summary>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
/// <returns>A <see cref="IObservable{Repository}"/> of <see cref="Repository"/></returns>
|
||||
public IObservable<Repository> GetAllForCurrent()
|
||||
{
|
||||
return GetAllForCurrent(ApiOptions.None);
|
||||
@@ -64,7 +90,6 @@ namespace Octokit.Reactive
|
||||
/// </summary>
|
||||
/// <param name="options">Options for changing the API's response.</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
/// <returns>A <see cref="IObservable{Repository}"/> of <see cref="Repository"/></returns>
|
||||
public IObservable<Repository> GetAllForCurrent(ApiOptions options)
|
||||
{
|
||||
Ensure.ArgumentNotNull(options, "options");
|
||||
@@ -77,7 +102,6 @@ namespace Octokit.Reactive
|
||||
/// </summary>
|
||||
/// <param name="user">The login of the user</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
/// <returns>A <see cref="IObservable{Repository}"/> watched by the specified user</returns>
|
||||
public IObservable<Repository> GetAllForUser(string user)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(user, "user");
|
||||
@@ -91,7 +115,6 @@ namespace Octokit.Reactive
|
||||
/// <param name="user">The login of the user</param>
|
||||
/// <param name="options">Options for changing the API's response.</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
/// <returns>A <see cref="IObservable{Repository}"/> watched by the specified user</returns>
|
||||
public IObservable<Repository> GetAllForUser(string user, ApiOptions options)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(user, "user");
|
||||
@@ -106,7 +129,6 @@ namespace Octokit.Reactive
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
/// <returns>A <c>bool</c> representing the success of the operation</returns>
|
||||
public IObservable<bool> CheckWatched(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
@@ -115,27 +137,48 @@ namespace Octokit.Reactive
|
||||
return _client.CheckWatched(owner, name).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if a repository is watched by the current authenticated user
|
||||
/// </summary>
|
||||
/// <param name="repositoryId">The ID of the repository</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
public IObservable<bool> CheckWatched(int repositoryId)
|
||||
{
|
||||
return _client.CheckWatched(repositoryId).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stars a repository for the authenticated user.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository to star</param>
|
||||
/// <param name="name">The name of the repository to star</param>
|
||||
/// <param name="newSubscription">A <see cref="NewSubscription"/> instance describing the new subscription to create</param>
|
||||
/// <returns>A <c>bool</c> representing the success of starring</returns>
|
||||
public IObservable<Subscription> WatchRepo(string owner, string name, NewSubscription newSubscription)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNull(newSubscription, "newSubscription");
|
||||
|
||||
return _client.WatchRepo(owner, name, newSubscription).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stars a repository for the authenticated user.
|
||||
/// </summary>
|
||||
/// <param name="repositoryId">The ID of the repository</param>
|
||||
/// <param name="newSubscription">A <see cref="NewSubscription"/> instance describing the new subscription to create</param>
|
||||
public IObservable<Subscription> WatchRepo(int repositoryId, NewSubscription newSubscription)
|
||||
{
|
||||
Ensure.ArgumentNotNull(newSubscription, "newSubscription");
|
||||
|
||||
return _client.WatchRepo(repositoryId, newSubscription).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unstars a repository for the authenticated user.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository to unstar</param>
|
||||
/// <param name="name">The name of the repository to unstar</param>
|
||||
/// <returns>A <c>bool</c> representing the success of the operation</returns>
|
||||
public IObservable<bool> UnwatchRepo(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
@@ -143,5 +186,14 @@ namespace Octokit.Reactive
|
||||
|
||||
return _client.UnwatchRepo(owner, name).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unstars a repository for the authenticated user.
|
||||
/// </summary>
|
||||
/// <param name="repositoryId">The ID of the repository</param>
|
||||
public IObservable<bool> UnwatchRepo(int repositoryId)
|
||||
{
|
||||
return _client.UnwatchRepo(repositoryId).ToObservable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user