mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-18 05:05:14 +00:00
* reworks all number parameter names to represent what they actually are. Refactors some types to be the appropriate types based on OpenAPI and docs. * updates interfaces and implementations for id naming * updates reactive to match sync SDKs
183 lines
7.5 KiB
C#
183 lines
7.5 KiB
C#
using System;
|
|
using System.Reactive.Threading.Tasks;
|
|
using Octokit.Reactive.Internal;
|
|
|
|
namespace Octokit.Reactive
|
|
{
|
|
/// <summary>
|
|
/// A client for GitHub's Issue Events API.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// See the <a href="http://developer.github.com/v3/issues/events/">Issue Events API documentation</a> for more information.
|
|
/// </remarks>
|
|
public class ObservableIssuesEventsClient : IObservableIssuesEventsClient
|
|
{
|
|
readonly IIssuesEventsClient _client;
|
|
readonly IConnection _connection;
|
|
|
|
public ObservableIssuesEventsClient(IGitHubClient client)
|
|
{
|
|
Ensure.ArgumentNotNull(client, nameof(client));
|
|
|
|
_client = client.Issue.Events;
|
|
_connection = client.Connection;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets all events for the issue.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// http://developer.github.com/v3/issues/events/#list-events-for-an-issue
|
|
/// </remarks>
|
|
/// <param name="owner">The owner of the repository</param>
|
|
/// <param name="name">The name of the repository</param>
|
|
/// <param name="issueNumber">The issue number</param>
|
|
public IObservable<IssueEvent> GetAllForIssue(string owner, string name, int issueNumber)
|
|
{
|
|
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
|
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
|
|
|
return GetAllForIssue(owner, name, issueNumber, ApiOptions.None);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets all events for the issue.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// http://developer.github.com/v3/issues/events/#list-events-for-an-issue
|
|
/// </remarks>
|
|
/// <param name="repositoryId">The Id of the repository</param>
|
|
/// <param name="issueNumber">The issue number</param>
|
|
public IObservable<IssueEvent> GetAllForIssue(long repositoryId, int issueNumber)
|
|
{
|
|
return GetAllForIssue(repositoryId, issueNumber, ApiOptions.None);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets all events for the issue.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// http://developer.github.com/v3/issues/events/#list-events-for-an-issue
|
|
/// </remarks>
|
|
/// <param name="owner">The owner of the repository</param>
|
|
/// <param name="name">The name of the repository</param>
|
|
/// <param name="issueNumber">The issue number</param>
|
|
/// <param name="options">Options for changing the API response</param>
|
|
public IObservable<IssueEvent> GetAllForIssue(string owner, string name, int issueNumber, ApiOptions options)
|
|
{
|
|
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
|
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
|
Ensure.ArgumentNotNull(options, nameof(options));
|
|
|
|
return _connection.GetAndFlattenAllPages<IssueEvent>(ApiUrls.IssuesEvents(owner, name, issueNumber), options);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets all events for the issue.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// http://developer.github.com/v3/issues/events/#list-events-for-an-issue
|
|
/// </remarks>
|
|
/// <param name="repositoryId">The Id of the repository</param>
|
|
/// <param name="issueNumber">The issue number</param>
|
|
/// <param name="options">Options for changing the API response</param>
|
|
public IObservable<IssueEvent> GetAllForIssue(long repositoryId, int issueNumber, ApiOptions options)
|
|
{
|
|
Ensure.ArgumentNotNull(options, nameof(options));
|
|
|
|
return _connection.GetAndFlattenAllPages<IssueEvent>(ApiUrls.IssuesEvents(repositoryId, issueNumber), options);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets all events for the repository.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// http://developer.github.com/v3/issues/events/#list-events-for-a-repository
|
|
/// </remarks>
|
|
/// <param name="owner">The owner of the repository</param>
|
|
/// <param name="name">The name of the repository</param>
|
|
public IObservable<IssueEvent> GetAllForRepository(string owner, string name)
|
|
{
|
|
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
|
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
|
|
|
return GetAllForRepository(owner, name, ApiOptions.None);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets all events for the repository.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// http://developer.github.com/v3/issues/events/#list-events-for-a-repository
|
|
/// </remarks>
|
|
/// <param name="repositoryId">The Id of the repository</param>
|
|
public IObservable<IssueEvent> GetAllForRepository(long repositoryId)
|
|
{
|
|
return GetAllForRepository(repositoryId, ApiOptions.None);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets all events for the repository.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// http://developer.github.com/v3/issues/events/#list-events-for-a-repository
|
|
/// </remarks>
|
|
/// <param name="owner">The owner of the repository</param>
|
|
/// <param name="name">The name of the repository</param>
|
|
/// <param name="options">Options for changing the API response</param>
|
|
public IObservable<IssueEvent> GetAllForRepository(string owner, string name, ApiOptions options)
|
|
{
|
|
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
|
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
|
Ensure.ArgumentNotNull(options, nameof(options));
|
|
|
|
return _connection.GetAndFlattenAllPages<IssueEvent>(ApiUrls.IssuesEvents(owner, name), options);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets all events for the repository.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// http://developer.github.com/v3/issues/events/#list-events-for-a-repository
|
|
/// </remarks>
|
|
/// <param name="repositoryId">The Id of the repository</param>
|
|
/// <param name="options">Options for changing the API response</param>
|
|
public IObservable<IssueEvent> GetAllForRepository(long repositoryId, ApiOptions options)
|
|
{
|
|
Ensure.ArgumentNotNull(options, nameof(options));
|
|
|
|
return _connection.GetAndFlattenAllPages<IssueEvent>(ApiUrls.IssuesEvents(repositoryId), options);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets a single event
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// http://developer.github.com/v3/issues/events/#get-a-single-event
|
|
/// </remarks>
|
|
/// <param name="owner">The owner of the repository</param>
|
|
/// <param name="name">The name of the repository</param>
|
|
/// <param name="eventId">The event id</param>
|
|
public IObservable<IssueEvent> Get(string owner, string name, long eventId)
|
|
{
|
|
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
|
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
|
|
|
return _client.Get(owner, name, eventId).ToObservable();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets a single event
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// http://developer.github.com/v3/issues/events/#get-a-single-event
|
|
/// </remarks>
|
|
/// <param name="repositoryId">The Id of the repository</param>
|
|
/// <param name="eventId">The event id</param>
|
|
public IObservable<IssueEvent> Get(long repositoryId, long eventId)
|
|
{
|
|
return _client.Get(repositoryId, eventId).ToObservable();
|
|
}
|
|
}
|
|
}
|