diff --git a/Octokit.Reactive/Clients/IObservableActivityClient.cs b/Octokit.Reactive/Clients/IObservableActivityClient.cs new file mode 100644 index 00000000..e371e8da --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableActivityClient.cs @@ -0,0 +1,99 @@ +using System; + +namespace Octokit.Reactive +{ + public interface IObservableActivityClient + { + /// + /// Gets all the public events + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events + /// + /// All the public s for the particular user. + IObservable GetAll(); + + /// + /// Gets all the events for a given repository + /// + /// + /// http://developer.github.com/v3/activity/events/#list-issue-events-for-a-repository + /// + /// The owner of the repository + /// The name of the repository + /// All the s for the particular repository. + IObservable GetAllForRepository(string owner, string name); + + /// + /// Gets all the events for a given repository network + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-for-a-network-of-repositories + /// + /// The owner of the repository + /// The name of the repository + /// All the s for the particular repository network. + IObservable GetAllForRepositoryNetwork(string owner, string name); + + /// + /// Gets all the events for a given organization + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-for-an-organization + /// + /// The name of the organization + /// All the s for the particular organization. + IObservable GetAllForOrganization(string organization); + + /// + /// Gets all the events that have been received by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-events-that-a-user-has-received + /// + /// The name of the user + /// All the s that a particular user has received. + IObservable GetUserReceived(string user); + + /// + /// Gets all the events that have been received by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-that-a-user-has-received + /// + /// The name of the user + /// All the s that a particular user has received. + IObservable GetUserReceivedPublic(string user); + + /// + /// Gets all the events that have been performed by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-events-performed-by-a-user + /// + /// The name of the user + /// All the s that a particular user has performed. + IObservable GetUserPerformed(string user); + + /// + /// Gets all the public events that have been performed by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-performed-by-a-user + /// + /// The name of the user + /// All the public s that a particular user has performed. + IObservable GetUserPerformedPublic(string user); + + /// + /// Gets all the events that are associated with an organization. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-events-for-an-organization + /// + /// The name of the user + /// The name of the organization + /// All the public s that are associated with an organization. + IObservable GetForAnOrganization(string user, string organization); + } +} \ No newline at end of file diff --git a/Octokit.Reactive/Clients/ObservableActivityClient.cs b/Octokit.Reactive/Clients/ObservableActivityClient.cs new file mode 100644 index 00000000..50cba6dd --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableActivityClient.cs @@ -0,0 +1,155 @@ +using System; +using Octokit.Reactive.Internal; + +namespace Octokit.Reactive +{ + public class ObservableActivityClient : IObservableActivityClient + { + IConnection _connection; + + public ObservableActivityClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, "client"); + + _connection = client.Connection; + } + + /// + /// Gets all the public events + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events + /// + /// All the public s for the particular user. + public IObservable GetAll() + { + return _connection.GetAndFlattenAllPages(ApiUrls.Events()); + } + + /// + /// Gets all the events for a given repository + /// + /// + /// http://developer.github.com/v3/activity/events/#list-issue-events-for-a-repository + /// + /// The owner of the repository + /// The name of the repository + /// All the s for the particular repository. + public IObservable GetAllForRepository(string owner, string name) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return _connection.GetAndFlattenAllPages(ApiUrls.IssuesEvents(owner, name)); + } + + /// + /// Gets all the events for a given repository network + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-for-a-network-of-repositories + /// + /// The owner of the repository + /// The name of the repository + /// All the s for the particular repository network. + public IObservable GetAllForRepositoryNetwork(string owner, string name) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return _connection.GetAndFlattenAllPages(ApiUrls.NetworkEvents(owner, name)); + } + + /// + /// Gets all the events for a given organization + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-for-an-organization + /// + /// The name of the organization + /// All the s for the particular organization. + public IObservable GetAllForOrganization(string organization) + { + Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); + + return _connection.GetAndFlattenAllPages(ApiUrls.OrganizationEvents(organization)); + } + + /// + /// Gets all the events that have been received by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-events-that-a-user-has-received + /// + /// The name of the user + /// All the s that a particular user has received. + public IObservable GetUserReceived(string user) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + + return _connection.GetAndFlattenAllPages(ApiUrls.ReceivedEvents(user)); + } + + /// + /// Gets all the events that have been received by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-that-a-user-has-received + /// + /// The name of the user + /// All the s that a particular user has received. + public IObservable GetUserReceivedPublic(string user) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + + return _connection.GetAndFlattenAllPages(ApiUrls.ReceivedEvents(user, true)); + } + + /// + /// Gets all the events that have been performed by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-events-performed-by-a-user + /// + /// The name of the user + /// All the s that a particular user has performed. + public IObservable GetUserPerformed(string user) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + + return _connection.GetAndFlattenAllPages(ApiUrls.PerformedEvents(user)); + } + + /// + /// Gets all the public events that have been performed by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-performed-by-a-user + /// + /// The name of the user + /// All the public s that a particular user has performed. + public IObservable GetUserPerformedPublic(string user) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + + return _connection.GetAndFlattenAllPages(ApiUrls.PerformedEvents(user, true)); + } + + /// + /// Gets all the events that are associated with an organization. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-events-for-an-organization + /// + /// The name of the user + /// The name of the organization + /// All the public s that are associated with an organization. + public IObservable GetForAnOrganization(string user, string organization) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); + + return _connection.GetAndFlattenAllPages(ApiUrls.OrganizationEvents(user, organization)); + } + } +} diff --git a/Octokit.Reactive/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj index 4a5d62a0..fe96d9ba 100644 --- a/Octokit.Reactive/Octokit.Reactive.csproj +++ b/Octokit.Reactive/Octokit.Reactive.csproj @@ -73,6 +73,8 @@ Properties\SolutionInfo.cs + + @@ -135,4 +137,4 @@ --> - + \ No newline at end of file diff --git a/Octokit.Tests/Clients/ActivitiesClientTests.cs b/Octokit.Tests/Clients/ActivitiesClientTests.cs index 09ad9341..d16b74a5 100644 --- a/Octokit.Tests/Clients/ActivitiesClientTests.cs +++ b/Octokit.Tests/Clients/ActivitiesClientTests.cs @@ -1,6 +1,4 @@ - - -using System; +using System; using System.Threading.Tasks; using NSubstitute; using Octokit.Tests.Helpers; diff --git a/Octokit/Clients/ActivitiesClient.cs b/Octokit/Clients/ActivitiesClient.cs index e7e109b9..56a999f4 100644 --- a/Octokit/Clients/ActivitiesClient.cs +++ b/Octokit/Clients/ActivitiesClient.cs @@ -1,5 +1,4 @@ - -using System.Collections.Generic; +using System.Collections.Generic; using System.Threading.Tasks; namespace Octokit diff --git a/Octokit/Models/Response/Activity.cs b/Octokit/Models/Response/Activity.cs index 5b7477dc..62808b8f 100644 --- a/Octokit/Models/Response/Activity.cs +++ b/Octokit/Models/Response/Activity.cs @@ -14,7 +14,7 @@ namespace Octokit /// Whether the activity event is public or not. /// public bool Public { get; set; } - + /// /// The repository associated with the activity event. ///