Files
octokit.net/Octokit.Reactive/Clients/ObservableUserEmailsClient.cs
Peter MacNaughton 133298789f Adding IObservableUserEmailsClient and...
default implementation. Still needs delete method which is skipped
because it's a HTTP DELETE. There's currently nothing in the
ApiConnection to handle this scenario and it's a rather unorthodox thing
to support.
delete.
2014-02-08 12:48:53 -07:00

32 lines
878 B
C#

using Octokit.Reactive.Internal;
using System;
using System.Reactive.Linq;
using System.Reactive.Threading.Tasks;
namespace Octokit.Reactive
{
public class ObservableUserEmailsClient : IObservableUserEmailsClient
{
readonly IUserEmailsClient _client;
readonly IConnection _connection;
public ObservableUserEmailsClient(IGitHubClient client)
{
Ensure.ArgumentNotNull(client, "client");
_client = client.User.Email;
_connection = client.Connection;
}
public IObservable<EmailAddress> GetAll()
{
return _connection.GetAndFlattenAllPages<EmailAddress>(ApiUrls.Emails());
}
public IObservable<string> Add(params string[] emailAddresses)
{
return _client.Add(emailAddresses).ToObservable().SelectMany(a => a);
}
}
}