using System; using System.Reactive.Threading.Tasks; using Octokit.Reactive.Internal; namespace Octokit.Reactive { public class ObservableCommitStatusClient : IObservableCommitStatusClient { readonly ICommitStatusClient _client; readonly IConnection _connection; public ObservableCommitStatusClient(IGitHubClient client) { Ensure.ArgumentNotNull(client, "client"); _client = client.Repository.CommitStatus; _connection = client.Connection; } /// /// Retrieves commit statuses for the specified reference. A reference can be a commit SHA, a branch name, or /// a tag name. /// /// Only users with pull access can see this. /// The owner of the repository /// The name of the repository /// The reference (SHA, branch name, or tag name) to list commits for /// public IObservable GetAll(string owner, string name, string reference) { return _connection.GetAndFlattenAllPages(ApiUrls.CommitStatuses(owner, name, reference)); } /// /// Retrieves a combined view of statuses for the specified reference. A reference can be a commit SHA, a branch name, or /// a tag name. /// /// Only users with pull access can see this. /// The owner of the repository /// The name of the repository /// The reference (SHA, branch name, or tag name) to list commits for /// public IObservable GetCombined(string owner, string name, string reference) { return _client.GetCombined(owner, name, reference).ToObservable(); } /// /// Creates a commit status for the specified ref. /// /// The owner of the repository /// The name of the repository /// The reference (SHA, branch name, or tag name) to list commits for /// The commit status to create /// public IObservable Create(string owner, string name, string reference, NewCommitStatus commitStatus) { return _client.Create(owner, name, reference, commitStatus).ToObservable(); } } }