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, "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 number)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return GetAllForIssue(owner, name, number, 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(int repositoryId, int number)
{
return GetAllForIssue(repositoryId, number, 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 number, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(options, "options");
return _connection.GetAndFlattenAllPages(ApiUrls.IssuesEvents(owner, name, number), 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(int repositoryId, int number, ApiOptions options)
{
Ensure.ArgumentNotNull(options, "options");
return _connection.GetAndFlattenAllPages(ApiUrls.IssuesEvents(repositoryId, number), 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, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "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(int 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, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(options, "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(int repositoryId, ApiOptions options)
{
Ensure.ArgumentNotNull(options, "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, int number)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return _client.Get(owner, name, number).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(int repositoryId, int number)
{
return _client.Get(repositoryId, number).ToObservable();
}
}
}