mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-20 14:15:12 +00:00
Implement IObservableIssuesEventsClient
This commit is contained in:
49
Octokit.Reactive/Clients/IObservableIssuesEventsClient.cs
Normal file
49
Octokit.Reactive/Clients/IObservableIssuesEventsClient.cs
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Octokit.Reactive.Clients
|
||||||
|
{
|
||||||
|
public interface IObservableIssuesEventsClient
|
||||||
|
{
|
||||||
|
/// <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="number">The issue number</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
IObservable<EventInfo> GetForIssue(string owner, string name, int number);
|
||||||
|
|
||||||
|
/// <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>
|
||||||
|
/// <returns></returns>
|
||||||
|
IObservable<IssueEvent> GetForRepository(string owner, string name);
|
||||||
|
|
||||||
|
/// <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="number">The event id</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get",
|
||||||
|
Justification = "Method makes a network request")]
|
||||||
|
IObservable<IssueEvent> Get(string owner, string name, int number);
|
||||||
|
}
|
||||||
|
}
|
||||||
68
Octokit.Reactive/Clients/ObservableIssuesEventsClient.cs
Normal file
68
Octokit.Reactive/Clients/ObservableIssuesEventsClient.cs
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
using System;
|
||||||
|
using System.Reactive;
|
||||||
|
using System.Reactive.Threading.Tasks;
|
||||||
|
using Octokit.Reactive.Internal;
|
||||||
|
|
||||||
|
namespace Octokit.Reactive.Clients
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <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="number">The issue number</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public IObservable<EventInfo> GetForIssue(string owner, string name, int number)
|
||||||
|
{
|
||||||
|
return _connection.GetAndFlattenAllPages<EventInfo>(ApiUrls.IssuesEvents(owner, name, number));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <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>
|
||||||
|
/// <returns></returns>
|
||||||
|
public IObservable<IssueEvent> GetForRepository(string owner, string name)
|
||||||
|
{
|
||||||
|
return _connection.GetAndFlattenAllPages<IssueEvent>(ApiUrls.IssuesEvents(owner, name));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <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="number">The event id</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public IObservable<IssueEvent> Get(string owner, string name, int number)
|
||||||
|
{
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||||
|
|
||||||
|
return _client.Get(owner, name, number).ToObservable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -71,6 +71,8 @@
|
|||||||
<Compile Include="..\SolutionInfo.cs">
|
<Compile Include="..\SolutionInfo.cs">
|
||||||
<Link>Properties\SolutionInfo.cs</Link>
|
<Link>Properties\SolutionInfo.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Clients\ObservableIssuesEventsClient.cs" />
|
||||||
|
<Compile Include="Clients\IObservableIssuesEventsClient.cs" />
|
||||||
<Compile Include="Clients\IObservableIssuesClient.cs" />
|
<Compile Include="Clients\IObservableIssuesClient.cs" />
|
||||||
<Compile Include="Clients\IObservableMilestonesClient.cs" />
|
<Compile Include="Clients\IObservableMilestonesClient.cs" />
|
||||||
<Compile Include="Clients\ObservableIssuesClient.cs" />
|
<Compile Include="Clients\ObservableIssuesClient.cs" />
|
||||||
|
|||||||
Reference in New Issue
Block a user