using Octokit.Reactive.Internal; using System; using System.Diagnostics.CodeAnalysis; using System.Reactive.Threading.Tasks; namespace Octokit.Reactive { public class ObservableRepositoryPagesClient : IObservableRepositoryPagesClient { readonly IRepositoryPagesClient _client; readonly IConnection _connection; public ObservableRepositoryPagesClient(IGitHubClient client) { Ensure.ArgumentNotNull(client, "client"); _client = client.Repository.Page; _connection = client.Connection; } /// /// Gets the page metadata for a given repository /// /// The owner of the repository /// The name of the repository /// /// See the API documentation for more information. /// /// [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] public IObservable Get(string owner, string repositoryName) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); return _client.Get(owner, repositoryName).ToObservable(); } /// /// Gets all build metadata for a given repository /// /// The owner of the repository /// The name of the repository /// /// See the API documentation for more information. /// /// public IObservable GetAll(string owner, string repositoryName) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); return _connection.GetAndFlattenAllPages(ApiUrls.RepositoryPageBuilds(owner, repositoryName)); } /// /// Gets the build metadata for the last build for a given repository /// /// The owner of the repository /// The name of the repository /// /// See the API documentation for more information. /// /// public IObservable GetLatest(string owner, string repositoryName) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); return _client.GetLatest(owner, repositoryName).ToObservable(); } } }