using System;
using Octokit.Reactive.Internal;
namespace Octokit.Reactive
{
public class ObservableEventsClient : IObservableEventsClient
{
readonly IConnection _connection;
public ObservableEventsClient(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 login 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 login 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 login 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 login 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 login 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));
}
}
}