using System;
using System.Reactive.Threading.Tasks;
using Octokit.Reactive.Internal;
namespace Octokit.Reactive
{
public class ObservableRepositoryForksClient : IObservableRepositoryForksClient
{
readonly IRepositoryForksClient _client;
readonly IConnection _connection;
///
/// Initializes a new GitHub Repos Fork API client.
///
///
public ObservableRepositoryForksClient(IGitHubClient client)
{
Ensure.ArgumentNotNull(client, "client");
_client = client.Repository.Forks;
_connection = client.Connection;
}
///
/// Gets the list of forks defined for a repository
///
/// See API documentation for more information.
///
public IObservable GetAll(string owner, string repositoryName, RepositoryForksListRequest request)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
return request == null
? _connection.GetAndFlattenAllPages(ApiUrls.RepositoryForks(owner, repositoryName))
: _connection.GetAndFlattenAllPages(ApiUrls.RepositoryForks(owner, repositoryName), request.ToParametersDictionary());
}
///
/// Creates a fork for a repository. Specify organization in the fork parameter to create for an organization.
///
/// See API documentation for more information.
///
public IObservable Create(string owner, string repositoryName, NewRepositoryFork fork)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
Ensure.ArgumentNotNull(fork, "fork");
return _client.Create(owner, repositoryName, fork).ToObservable();
}
}
}