using System;
using Octokit.Reactive.Internal;
namespace Octokit.Reactive
{
///
/// A client for GitHub's Activity Events API.
///
///
/// See the Activity Events API documentation for more information
///
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
///
public IObservable GetAll()
{
return GetAll(ApiOptions.None);
}
///
/// Gets all the public events
///
///
/// http://developer.github.com/v3/activity/events/#list-public-events
///
/// Options for changing the API response
public IObservable GetAll(ApiOptions options)
{
Ensure.ArgumentNotNull(options, "options");
return _connection.GetAndFlattenAllPages(ApiUrls.Events(), options);
}
///
/// 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
public IObservable GetAllForRepository(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return GetAllForRepository(owner, name, ApiOptions.None);
}
///
/// Gets all the events for a given repository
///
///
/// http://developer.github.com/v3/activity/events/#list-issue-events-for-a-repository
///
/// The ID of the repository
public IObservable GetAllForRepository(int repositoryId)
{
return GetAllForRepository(repositoryId, ApiOptions.None);
}
///
/// 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
/// Options for changing the API response
public IObservable GetAllForRepository(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(options, "options");
return _connection.GetAndFlattenAllPages(ApiUrls.Events(owner, name), options);
}
///
/// Gets all the events for a given repository
///
///
/// http://developer.github.com/v3/activity/events/#list-issue-events-for-a-repository
///
/// The ID of the repository
/// Options for changing the API response
public IObservable GetAllForRepository(int repositoryId, ApiOptions options)
{
Ensure.ArgumentNotNull(options, "options");
return _connection.GetAndFlattenAllPages(ApiUrls.Events(repositoryId), options);
}
///
/// 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
public IObservable GetAllIssuesForRepository(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return GetAllIssuesForRepository(owner, name, ApiOptions.None);
}
///
/// Gets all the issue events for a given repository
///
///
/// http://developer.github.com/v3/activity/events/#list-issue-events-for-a-repository
///
/// The ID of the repository
public IObservable GetAllIssuesForRepository(int repositoryId)
{
return GetAllIssuesForRepository(repositoryId, ApiOptions.None);
}
///
/// 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
/// Options for changing the API response
public IObservable GetAllIssuesForRepository(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(options, "options");
return _connection.GetAndFlattenAllPages(ApiUrls.IssuesEvents(owner, name), options);
}
///
/// Gets all the issue events for a given repository
///
///
/// http://developer.github.com/v3/activity/events/#list-issue-events-for-a-repository
///
/// The ID of the repository
/// Options for changing the API response
public IObservable GetAllIssuesForRepository(int repositoryId, ApiOptions options)
{
Ensure.ArgumentNotNull(options, "options");
return _connection.GetAndFlattenAllPages(ApiUrls.IssuesEvents(repositoryId), options);
}
///
/// 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
public IObservable GetAllForRepositoryNetwork(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return GetAllForRepositoryNetwork(owner, name, ApiOptions.None);
}
///
/// 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
/// Options for changing the API response
public IObservable GetAllForRepositoryNetwork(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(options, "options");
return _connection.GetAndFlattenAllPages(ApiUrls.NetworkEvents(owner, name), options);
}
///
/// 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
public IObservable GetAllForOrganization(string organization)
{
Ensure.ArgumentNotNullOrEmptyString(organization, "organization");
return GetAllForOrganization(organization, ApiOptions.None);
}
///
/// 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
/// Options for changing the API response
public IObservable GetAllForOrganization(string organization, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(organization, "organization");
Ensure.ArgumentNotNull(options, "options");
return _connection.GetAndFlattenAllPages(ApiUrls.OrganizationEvents(organization), options);
}
///
/// 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
public IObservable GetAllUserReceived(string user)
{
Ensure.ArgumentNotNullOrEmptyString(user, "user");
return GetAllUserReceived(user, ApiOptions.None);
}
///
/// 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
/// Options for changing the API response
public IObservable GetAllUserReceived(string user, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(user, "user");
Ensure.ArgumentNotNull(options, "options");
return _connection.GetAndFlattenAllPages(ApiUrls.ReceivedEvents(user), options);
}
///
/// 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
public IObservable GetAllUserReceivedPublic(string user)
{
Ensure.ArgumentNotNullOrEmptyString(user, "user");
return GetAllUserReceivedPublic(user, ApiOptions.None);
}
///
/// 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
/// Options for changing the API response
public IObservable GetAllUserReceivedPublic(string user, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(user, "user");
Ensure.ArgumentNotNull(options, "options");
return _connection.GetAndFlattenAllPages(ApiUrls.ReceivedEvents(user, true), options);
}
///
/// 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
public IObservable GetAllUserPerformed(string user)
{
Ensure.ArgumentNotNullOrEmptyString(user, "user");
return GetAllUserPerformed(user, ApiOptions.None);
}
///
/// 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
/// Options for changing the API response
public IObservable GetAllUserPerformed(string user, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(user, "user");
Ensure.ArgumentNotNull(options, "options");
return _connection.GetAndFlattenAllPages(ApiUrls.PerformedEvents(user), options);
}
///
/// 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
public IObservable GetAllUserPerformedPublic(string user)
{
Ensure.ArgumentNotNullOrEmptyString(user, "user");
return GetAllUserPerformedPublic(user, ApiOptions.None);
}
///
/// 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
/// Options for changing the API response
public IObservable GetAllUserPerformedPublic(string user, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(user, "user");
Ensure.ArgumentNotNull(options, "options");
return _connection.GetAndFlattenAllPages(ApiUrls.PerformedEvents(user, true), options);
}
///
/// 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
public IObservable GetAllForAnOrganization(string user, string organization)
{
Ensure.ArgumentNotNullOrEmptyString(user, "user");
Ensure.ArgumentNotNullOrEmptyString(organization, "organization");
return GetAllForAnOrganization(user, organization, ApiOptions.None);
}
///
/// 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
/// Options for changing the API response
public IObservable GetAllForAnOrganization(string user, string organization, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(user, "user");
Ensure.ArgumentNotNullOrEmptyString(organization, "organization");
Ensure.ArgumentNotNull(options, "options");
return _connection.GetAndFlattenAllPages(ApiUrls.OrganizationEvents(user, organization),options);
}
}
}