mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-19 21:55:12 +00:00
Add reactive notifications client
This commit is contained in:
37
Octokit.Reactive/Clients/ObservableNotificationsClient.cs
Normal file
37
Octokit.Reactive/Clients/ObservableNotificationsClient.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using Octokit.Reactive.Internal;
|
||||
|
||||
namespace Octokit.Reactive.Clients
|
||||
{
|
||||
public class ObservableNotificationsClient : IObservableNotificationsClient
|
||||
{
|
||||
readonly IConnection _connection;
|
||||
|
||||
public ObservableNotificationsClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
|
||||
_connection = client.Connection;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Notification"/>s for the current user.
|
||||
/// </summary>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>A <see cref="IObservable{Notification}"/> of <see cref="Notification"/>.</returns>
|
||||
public IObservable<Notification> GetAllForCurrent()
|
||||
{
|
||||
return _connection.GetAndFlattenAllPages<Notification>(ApiUrls.Notifications());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Notification"/>s for the current user specific to the specified repository.
|
||||
/// </summary>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>A <see cref="IObservable{Notification}"/> of <see cref="Notification"/>.</returns>
|
||||
public IObservable<Notification> GetAllForRepository(string owner, string name)
|
||||
{
|
||||
return _connection.GetAndFlattenAllPages<Notification>(ApiUrls.Notifications(owner, name));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user