using System; using System.Reactive.Threading.Tasks; using Octokit.Reactive.Internal; namespace Octokit.Reactive { /// /// A client for GitHub's Issue Events API. /// /// /// See the Issue Events API documentation for more information. /// public class ObservableIssuesEventsClient : IObservableIssuesEventsClient { readonly IIssuesEventsClient _client; readonly IConnection _connection; public ObservableIssuesEventsClient(IGitHubClient client) { Ensure.ArgumentNotNull(client, nameof(client)); _client = client.Issue.Events; _connection = client.Connection; } /// /// Gets all events for the issue. /// /// /// http://developer.github.com/v3/issues/events/#list-events-for-an-issue /// /// The owner of the repository /// The name of the repository /// The issue number public IObservable GetAllForIssue(string owner, string name, int issueNumber) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); return GetAllForIssue(owner, name, issueNumber, ApiOptions.None); } /// /// Gets all events for the issue. /// /// /// http://developer.github.com/v3/issues/events/#list-events-for-an-issue /// /// The Id of the repository /// The issue number public IObservable GetAllForIssue(long repositoryId, int issueNumber) { return GetAllForIssue(repositoryId, issueNumber, ApiOptions.None); } /// /// Gets all events for the issue. /// /// /// http://developer.github.com/v3/issues/events/#list-events-for-an-issue /// /// The owner of the repository /// The name of the repository /// The issue number /// Options for changing the API response public IObservable GetAllForIssue(string owner, string name, int issueNumber, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); return _connection.GetAndFlattenAllPages(ApiUrls.IssuesEvents(owner, name, issueNumber), options); } /// /// Gets all events for the issue. /// /// /// http://developer.github.com/v3/issues/events/#list-events-for-an-issue /// /// The Id of the repository /// The issue number /// Options for changing the API response public IObservable GetAllForIssue(long repositoryId, int issueNumber, ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); return _connection.GetAndFlattenAllPages(ApiUrls.IssuesEvents(repositoryId, issueNumber), options); } /// /// Gets all events for the repository. /// /// /// http://developer.github.com/v3/issues/events/#list-events-for-a-repository /// /// The owner of the repository /// The name of the repository public IObservable GetAllForRepository(string owner, string name) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); return GetAllForRepository(owner, name, ApiOptions.None); } /// /// Gets all events for the repository. /// /// /// http://developer.github.com/v3/issues/events/#list-events-for-a-repository /// /// The Id of the repository public IObservable GetAllForRepository(long repositoryId) { return GetAllForRepository(repositoryId, ApiOptions.None); } /// /// Gets all events for the repository. /// /// /// http://developer.github.com/v3/issues/events/#list-events-for-a-repository /// /// The owner of the repository /// The name of the repository /// Options for changing the API response public IObservable GetAllForRepository(string owner, string name, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); return _connection.GetAndFlattenAllPages(ApiUrls.IssuesEvents(owner, name), options); } /// /// Gets all events for the repository. /// /// /// http://developer.github.com/v3/issues/events/#list-events-for-a-repository /// /// The Id of the repository /// Options for changing the API response public IObservable GetAllForRepository(long repositoryId, ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); return _connection.GetAndFlattenAllPages(ApiUrls.IssuesEvents(repositoryId), options); } /// /// Gets a single event /// /// /// http://developer.github.com/v3/issues/events/#get-a-single-event /// /// The owner of the repository /// The name of the repository /// The event id public IObservable Get(string owner, string name, long eventId) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); return _client.Get(owner, name, eventId).ToObservable(); } /// /// Gets a single event /// /// /// http://developer.github.com/v3/issues/events/#get-a-single-event /// /// The Id of the repository /// The event id public IObservable Get(long repositoryId, long eventId) { return _client.Get(repositoryId, eventId).ToObservable(); } } }