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)WatchedClient #1372

Merged
Merged
Show file tree
Hide file tree
Changes from 7 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
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
language: csharp
mono:
- 4.2.3

sudo: false # use the new container-based Travis infrastructure
os:
Expand Down
66 changes: 57 additions & 9 deletions Octokit.Reactive/Clients/IObservableWatchedClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@

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>
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we removing the return description? If that's a direction we want to take, might as well remove the entire /// <returns></returns> line.

Copy link
Contributor Author

@alexander-efremov alexander-efremov Jun 23, 2016

Choose a reason for hiding this comment

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

@haacked We've discussed this here with @shiftkey. And yep, I'll remove /// <returns></returns> in next commits when other things will be reviewed 👍

Expand All @@ -11,24 +17,41 @@ public interface IObservableWatchedClient
/// <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>
/// <returns></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>
/// <returns></returns>
IObservable<User> GetAllWatchers(int repositoryId);

/// <summary>
/// Retrieves all of the watchers for the passed repository
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <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>
/// <returns></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>
/// <returns></returns>
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>
/// <returns></returns>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
IObservable<Repository> GetAllForCurrent();

Expand All @@ -37,15 +60,15 @@ public interface IObservableWatchedClient
/// </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>
/// <returns></returns>
IObservable<Repository> GetAllForCurrent(ApiOptions options);

/// <summary>
/// Retrieves all of the <see cref="Repository"/>(ies) watched by the specified user
/// </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>
/// <returns></returns>
IObservable<Repository> GetAllForUser(string user);

/// <summary>
Expand All @@ -54,7 +77,7 @@ public interface IObservableWatchedClient
/// <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>
/// <returns></returns>
IObservable<Repository> GetAllForUser(string user, ApiOptions options);

/// <summary>
Expand All @@ -63,26 +86,51 @@ public interface IObservableWatchedClient
/// <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>
/// <returns></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>
/// <returns></returns>
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>
/// <returns></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>
/// <returns></returns>
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>
/// <returns></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>
/// <returns></returns>
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Unwatch",
Justification = "Unwatch is consistent with the GitHub website")]
IObservable<bool> UnwatchRepo(int repositoryId);
}
}
84 changes: 75 additions & 9 deletions Octokit.Reactive/Clients/ObservableWatchedClient.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 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;
Expand All @@ -23,7 +29,7 @@ public ObservableWatchedClient(IGitHubClient client)
/// <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>
/// <returns></returns>
public IObservable<User> GetAllWatchers(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Expand All @@ -32,14 +38,25 @@ public IObservable<User> GetAllWatchers(string owner, string name)
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>
/// <returns></returns>
public IObservable<User> GetAllWatchers(int repositoryId)
{
return GetAllWatchers(repositoryId, ApiOptions.None);
}

/// <summary>
/// Retrieves all of the watchers for the passed repository
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <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>
/// <returns></returns>
public IObservable<User> GetAllWatchers(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Expand All @@ -49,11 +66,25 @@ public IObservable<User> GetAllWatchers(string owner, string name, ApiOptions op
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>
/// <returns></returns>
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>
/// <returns></returns>
public IObservable<Repository> GetAllForCurrent()
{
return GetAllForCurrent(ApiOptions.None);
Expand All @@ -64,7 +95,7 @@ public IObservable<Repository> GetAllForCurrent()
/// </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>
/// <returns></returns>
public IObservable<Repository> GetAllForCurrent(ApiOptions options)
{
Ensure.ArgumentNotNull(options, "options");
Expand All @@ -77,7 +108,7 @@ public IObservable<Repository> GetAllForCurrent(ApiOptions options)
/// </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>
/// <returns></returns>
public IObservable<Repository> GetAllForUser(string user)
{
Ensure.ArgumentNotNullOrEmptyString(user, "user");
Expand All @@ -91,7 +122,7 @@ public IObservable<Repository> GetAllForUser(string user)
/// <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>
/// <returns></returns>
public IObservable<Repository> GetAllForUser(string user, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(user, "user");
Expand All @@ -106,7 +137,7 @@ public IObservable<Repository> GetAllForUser(string user, ApiOptions options)
/// <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>
/// <returns></returns>
public IObservable<bool> CheckWatched(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Expand All @@ -115,33 +146,68 @@ public IObservable<bool> CheckWatched(string owner, string name)
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>
/// <returns></returns>
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>
/// <returns></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>
/// <returns></returns>
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>
/// <returns></returns>
public IObservable<bool> UnwatchRepo(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");

return _client.UnwatchRepo(owner, name).ToObservable();
}

/// <summary>
/// Unstars a repository for the authenticated user.
/// </summary>
/// <param name="repositoryId">The ID of the repository</param>
/// <returns></returns>
public IObservable<bool> UnwatchRepo(int repositoryId)
{
return _client.UnwatchRepo(repositoryId).ToObservable();
}
}
}
Loading