added new overloads

This commit is contained in:
aedampir@gmail.com
2016-06-15 18:03:10 +07:00
parent edddbedf56
commit 1e36a4e3c3
4 changed files with 118 additions and 28 deletions

View File

@@ -10,6 +10,25 @@ namespace Octokit.Reactive
/// </remarks> /// </remarks>
public interface IObservableIssueReactionsClient public interface IObservableIssueReactionsClient
{ {
/// <summary>
/// List reactions for a specified Issue.
/// </summary>
/// <remarks>https://developer.github.com/v3/reactions/#list-reactions-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 id</param>
/// <returns>An <see cref="IObservable{T}"/> representing <see cref="Reaction"/>s for a specified issue.</returns>
IObservable<Reaction> GetAll(string owner, string name, int number);
/// <summary>
/// List reactions for a specified Issue.
/// </summary>
/// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue</remarks>
/// <param name="repositoryId">The ID of the repository</param>
/// <param name="number">The issue id</param>
/// <returns>An <see cref="IObservable{T}"/> representing <see cref="Reaction"/>s for a specified issue.</returns>
IObservable<Reaction> GetAll(int repositoryId, int number);
/// <summary> /// <summary>
/// Creates a reaction for a specified Issue. /// Creates a reaction for a specified Issue.
/// </summary> /// </summary>
@@ -22,13 +41,13 @@ namespace Octokit.Reactive
IObservable<Reaction> Create(string owner, string name, int number, NewReaction reaction); IObservable<Reaction> Create(string owner, string name, int number, NewReaction reaction);
/// <summary> /// <summary>
/// List reactions for a specified Issue. /// Creates a reaction for a specified Issue.
/// </summary> /// </summary>
/// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue</remarks> /// <remarks>https://developer.github.com/v3/reactions/#create-reaction-for-an-issue</remarks>
/// <param name="owner">The owner of the repository</param> /// <param name="repositoryId">The ID of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="number">The issue id</param> /// <param name="number">The issue id</param>
/// <returns>An <see cref="IObservable{T}"/> representing <see cref="Reaction"/>s for a specified issue.</returns> /// <param name="reaction">The reaction to create </param>
IObservable<Reaction> GetAll(string owner, string name, int number); /// <returns>An <see cref="IObservable{T}"/> representing created <see cref="Reaction"/> for a specified issue.</returns>
IObservable<Reaction> Create(int repositoryId, int number, NewReaction reaction);
} }
} }

View File

@@ -23,6 +23,34 @@ namespace Octokit.Reactive
_connection = client.Connection; _connection = client.Connection;
} }
/// <summary>
/// List reactions for a specified Issue
/// </summary>
/// <remarks>https://developer.github.com/v3/reactions/#list-reactions-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 id</param>
/// <returns>An <see cref="IObservable{T}"/> representing <see cref="Reaction"/>s for a specified issue.</returns>
public IObservable<Reaction> GetAll(string owner, string name, int number)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return _connection.GetAndFlattenAllPages<Reaction>(ApiUrls.IssueReactions(owner, name, number), null, AcceptHeaders.ReactionsPreview);
}
/// <summary>
/// List reactions for a specified Issue.
/// </summary>
/// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue</remarks>
/// <param name="repositoryId">The ID of the repository</param>
/// <param name="number">The issue id</param>
/// <returns>An <see cref="IObservable{T}"/> representing <see cref="Reaction"/>s for a specified issue.</returns>
public IObservable<Reaction> GetAll(int repositoryId, int number)
{
return _connection.GetAndFlattenAllPages<Reaction>(ApiUrls.IssueReactions(repositoryId, number), null, AcceptHeaders.ReactionsPreview);
}
/// <summary> /// <summary>
/// Creates a reaction for a specified Issue /// Creates a reaction for a specified Issue
/// </summary> /// </summary>
@@ -42,19 +70,16 @@ namespace Octokit.Reactive
} }
/// <summary> /// <summary>
/// List reactions for a specified Issue /// Creates a reaction for a specified Issue.
/// </summary> /// </summary>
/// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue</remarks> /// <remarks>https://developer.github.com/v3/reactions/#create-reaction-for-an-issue</remarks>
/// <param name="owner">The owner of the repository</param> /// <param name="repositoryId">The ID of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="number">The issue id</param> /// <param name="number">The issue id</param>
/// <returns>An <see cref="IObservable{T}"/> representing <see cref="Reaction"/>s for a specified issue.</returns> /// <param name="reaction">The reaction to create </param>
public IObservable<Reaction> GetAll(string owner, string name, int number) /// <returns>An <see cref="IObservable{T}"/> representing created <see cref="Reaction"/> for a specified issue.</returns>
public IObservable<Reaction> Create(int repositoryId, int number, NewReaction reaction)
{ {
Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); return _client.Create(repositoryId, number, reaction).ToObservable();
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return _connection.GetAndFlattenAllPages<Reaction>(ApiUrls.IssueReactions(owner, name, number), null, AcceptHeaders.ReactionsPreview);
} }
} }
} }

View File

@@ -21,6 +21,15 @@ namespace Octokit
/// <returns>A <see cref="Task{T}"/> of <see cref="IReadOnlyList{Reactions}"/> representing <see cref="Reaction"/>s for a specified issue.</returns> /// <returns>A <see cref="Task{T}"/> of <see cref="IReadOnlyList{Reactions}"/> representing <see cref="Reaction"/>s for a specified issue.</returns>
Task<IReadOnlyList<Reaction>> GetAll(string owner, string name, int number); Task<IReadOnlyList<Reaction>> GetAll(string owner, string name, int number);
/// <summary>
/// Get all reactions for a specified Issue
/// </summary>
/// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue</remarks>
/// <param name="repositoryId">The ID of the repository</param>
/// <param name="number">The issue id</param>
/// <returns>A <see cref="Task{T}"/> of <see cref="IReadOnlyList{Reactions}"/> representing <see cref="Reaction"/>s for a specified issue.</returns>
Task<IReadOnlyList<Reaction>> GetAll(int repositoryId, int number);
/// <summary> /// <summary>
/// Creates a reaction for a specified Issue /// Creates a reaction for a specified Issue
/// </summary> /// </summary>
@@ -31,5 +40,15 @@ namespace Octokit
/// <param name="reaction">The reaction to create</param> /// <param name="reaction">The reaction to create</param>
/// <returns>A <see cref="Task{Reaction}"/> representing created <see cref="Reaction"/> for a specified issue.</returns> /// <returns>A <see cref="Task{Reaction}"/> representing created <see cref="Reaction"/> for a specified issue.</returns>
Task<Reaction> Create(string owner, string name, int number, NewReaction reaction); Task<Reaction> Create(string owner, string name, int number, NewReaction reaction);
/// <summary>
/// Creates a reaction for a specified Issue
/// </summary>
/// <remarks>https://developer.github.com/v3/reactions/#create-reaction-for-an-issue</remarks>
/// <param name="repositoryId">The ID of the repository</param>
/// <param name="number">The issue id</param>
/// <param name="reaction">The reaction to create</param>
/// <returns>A <see cref="Task{Reaction}"/> representing created <see cref="Reaction"/> for a specified issue.</returns>
Task<Reaction> Create(int repositoryId, int number, NewReaction reaction);
} }
} }

View File

@@ -16,6 +16,34 @@ namespace Octokit
{ {
} }
/// <summary>
/// Get all reactions for a specified Issue
/// </summary>
/// <remarks>https://developer.github.com/v3/reactions/#list-reactions-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 id</param>
/// <returns>A <see cref="Task{T}"/> of <see cref="IReadOnlyList{Reactions}"/> representing <see cref="Reaction"/>s for a specified issue.</returns>
public Task<IReadOnlyList<Reaction>> GetAll(string owner, string name, int number)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return ApiConnection.GetAll<Reaction>(ApiUrls.IssueReactions(owner, name, number), AcceptHeaders.ReactionsPreview);
}
/// <summary>
/// Get all reactions for a specified Issue
/// </summary>
/// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue</remarks>
/// <param name="repositoryId">The ID of the repository</param>
/// <param name="number">The issue id</param>
/// <returns>A <see cref="Task{T}"/> of <see cref="IReadOnlyList{Reactions}"/> representing <see cref="Reaction"/>s for a specified issue.</returns>
public Task<IReadOnlyList<Reaction>> GetAll(int repositoryId, int number)
{
return ApiConnection.GetAll<Reaction>(ApiUrls.IssueReactions(repositoryId, number), AcceptHeaders.ReactionsPreview);
}
/// <summary> /// <summary>
/// Creates a reaction for a specified Issue /// Creates a reaction for a specified Issue
/// </summary> /// </summary>
@@ -35,19 +63,18 @@ namespace Octokit
} }
/// <summary> /// <summary>
/// Get all reactions for a specified Issue /// Creates a reaction for a specified Issue
/// </summary> /// </summary>
/// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue</remarks> /// <remarks>https://developer.github.com/v3/reactions/#create-reaction-for-an-issue</remarks>
/// <param name="owner">The owner of the repository</param> /// <param name="repositoryId">The ID of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="number">The issue id</param> /// <param name="number">The issue id</param>
/// <returns>A <see cref="Task{T}"/> of <see cref="IReadOnlyList{Reactions}"/> representing <see cref="Reaction"/>s for a specified issue.</returns> /// <param name="reaction">The reaction to create</param>
public Task<IReadOnlyList<Reaction>> GetAll(string owner, string name, int number) /// <returns>A <see cref="Task{Reaction}"/> representing created <see cref="Reaction"/> for a specified issue.</returns>
public Task<Reaction> Create(int repositoryId, int number, NewReaction reaction)
{ {
Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNull(reaction, "reaction");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return ApiConnection.GetAll<Reaction>(ApiUrls.IssueReactions(owner, name, number), AcceptHeaders.ReactionsPreview); return ApiConnection.Post<Reaction>(ApiUrls.IssueReactions(repositoryId, number), reaction, AcceptHeaders.ReactionsPreview);
} }
} }
} }