diff --git a/Octokit.Reactive/Clients/IObservableIssuesEventsClient.cs b/Octokit.Reactive/Clients/IObservableIssuesEventsClient.cs new file mode 100644 index 00000000..58269a62 --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableIssuesEventsClient.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Octokit.Reactive.Clients +{ + public interface IObservableIssuesEventsClient + { + /// + /// 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 + /// + IObservable GetForIssue(string owner, string name, int number); + + /// + /// 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 + /// + IObservable GetForRepository(string owner, string name); + + /// + /// 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 + /// + [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", + Justification = "Method makes a network request")] + IObservable Get(string owner, string name, int number); + } +} diff --git a/Octokit.Reactive/Clients/ObservableIssuesEventsClient.cs b/Octokit.Reactive/Clients/ObservableIssuesEventsClient.cs new file mode 100644 index 00000000..50e54300 --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableIssuesEventsClient.cs @@ -0,0 +1,68 @@ +using System; +using System.Reactive; +using System.Reactive.Threading.Tasks; +using Octokit.Reactive.Internal; + +namespace Octokit.Reactive.Clients +{ + public class ObservableIssuesEventsClient : IObservableIssuesEventsClient + { + readonly IIssuesEventsClient _client; + readonly IConnection _connection; + + public ObservableIssuesEventsClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, "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 GetForIssue(string owner, string name, int number) + { + return _connection.GetAndFlattenAllPages(ApiUrls.IssuesEvents(owner, name, number)); + } + + /// + /// 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 GetForRepository(string owner, string name) + { + return _connection.GetAndFlattenAllPages(ApiUrls.IssuesEvents(owner, name)); + } + + /// + /// 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, int number) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return _client.Get(owner, name, number).ToObservable(); + } + } +} \ No newline at end of file diff --git a/Octokit.Reactive/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj index 4375f3f6..30ebff74 100644 --- a/Octokit.Reactive/Octokit.Reactive.csproj +++ b/Octokit.Reactive/Octokit.Reactive.csproj @@ -71,6 +71,8 @@ Properties\SolutionInfo.cs + +