using System;
using System.Collections.Generic;
using System.Reactive.Threading.Tasks;
namespace Octokit.Reactive.Clients
{
public class ObservableRepositoriesClient : IObservableRepositoriesClient
{
readonly IRepositoriesClient _client;
public ObservableRepositoriesClient(IRepositoriesClient client)
{
Ensure.ArgumentNotNull(client, "client");
_client = client;
}
///
/// Creates a new repository for the current user.
///
/// A instance describing the new repository to create
/// An instance for the created repository
public IObservable Create(NewRepository newRepository)
{
Ensure.ArgumentNotNull(newRepository, "newRepository");
if (string.IsNullOrEmpty(newRepository.Name))
throw new ArgumentException("The new repository's name must not be null.");
return _client.Create(newRepository).ToObservable();
}
public IObservable Get(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return _client.Get(owner, name).ToObservable();
}
public IObservable> GetAllForCurrent()
{
return _client.GetAllForCurrent().ToObservable();
}
public IObservable> GetAllForUser(string login)
{
Ensure.ArgumentNotNullOrEmptyString(login, "login");
return _client.GetAllForUser(login).ToObservable();
}
public IObservable> GetAllForOrg(string organization)
{
Ensure.ArgumentNotNullOrEmptyString(organization, "organization");
return _client.GetAllForOrg(organization).ToObservable();
}
public IObservable GetReadme(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return _client.GetReadme(owner, name).ToObservable();
}
}
}