Add ApiOptions overload to Reactive Teams client.

This commit is contained in:
Devesh Khandelwal
2016-03-23 14:57:50 +05:30
parent 084c513e06
commit 486e315c02
3 changed files with 105 additions and 6 deletions
@@ -27,10 +27,20 @@ namespace Octokit.Reactive
/// <summary>
/// Returns all <see cref="Team" />s for the current org.
/// </summary>
/// <param name="org">Organization to list all teams of.</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>A list of the orgs's teams <see cref="Team"/>s.</returns>
IObservable<Team> GetAll(string org);
/// <summary>
/// Returns all <see cref="Team" />s for the current org.
/// </summary>
/// <param name="org">Organization to list all teams of.</param>
/// <param name="options">Options to change API behaviour.</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>A list of the orgs's teams <see cref="Team"/>s.</returns>
IObservable<Team> GetAll(string org, ApiOptions options);
/// <summary>
/// Returns all <see cref="Team" />s for the current user.
/// </summary>
@@ -39,17 +49,38 @@ namespace Octokit.Reactive
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
IObservable<Team> GetAllForCurrent();
/// <summary>
/// Returns all <see cref="Team" />s for the current user.
/// </summary>
/// <param name="options">Options to change API behaviour.</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>A list of the user's <see cref="Team"/>s.</returns>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
IObservable<Team> GetAllForCurrent(ApiOptions options);
/// <summary>
/// Returns all members of the given team.
/// </summary>
/// <param name="id">The team identifier</param>
/// <remarks>
/// https://developer.github.com/v3/orgs/teams/#list-team-members
/// </remarks>
/// <param name="id">The team identifier</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>A list of the team's member <see cref="User"/>s.</returns>
IObservable<User> GetAllMembers(int id);
/// <summary>
/// Returns all members of the given team.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/orgs/teams/#list-team-members
/// </remarks>
/// <param name="id">The team identifier</param>
/// <param name="options">Options to change API behaviour.</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>A list of the team's member <see cref="User"/>s.</returns>
IObservable<User> GetAllMembers(int id, ApiOptions options);
/// <summary>
/// Returns newly created <see cref="Team" /> for the current org.
/// </summary>
@@ -116,10 +147,20 @@ namespace Octokit.Reactive
/// <summary>
/// Returns all team's repositories.
/// </summary>
/// <param name="id">Team Id.</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>The team's repositories</returns>
IObservable<Repository> GetAllRepositories(int id);
/// <summary>
/// Returns all team's repositories.
/// </summary>
/// <param name="id">Team Id.</param>
/// <param name="options">Options to change API behaviour.</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>The team's repositories</returns>
IObservable<Repository> GetAllRepositories(int id, ApiOptions options);
/// <summary>
/// Remove a repository from the team
/// </summary>
@@ -46,9 +46,23 @@ namespace Octokit.Reactive
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>A list of the orgs's teams <see cref="Team"/>s.</returns>
public IObservable<Team> GetAll(string org)
{
return GetAll(org, ApiOptions.None);
}
/// <summary>
/// Returns all <see cref="Team" />s for the current org.
/// </summary>
/// <param name="org">Organization to list all teams of.</param>
/// <param name="options">Options to change API behaviour.</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>A list of the orgs's teams <see cref="Team"/>s.</returns>
public IObservable<Team> GetAll(string org, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(org, "org");
return _connection.GetAndFlattenAllPages<Team>(ApiUrls.OrganizationTeams(org));
Ensure.ArgumentNotNull(options, "options");
return _connection.GetAndFlattenAllPages<Team>(ApiUrls.OrganizationTeams(org), options);
}
/// <summary>
@@ -58,7 +72,20 @@ namespace Octokit.Reactive
/// <returns>A list of the user's <see cref="Team"/>s.</returns>
public IObservable<Team> GetAllForCurrent()
{
return _connection.GetAndFlattenAllPages<Team>(ApiUrls.UserTeams());
return GetAllForCurrent(ApiOptions.None);
}
/// <summary>
/// Returns all <see cref="Team" />s for the current user.
/// </summary>
/// <param name="options">Options to change API behaviour.</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>A list of the user's <see cref="Team"/>s.</returns>
public IObservable<Team> GetAllForCurrent(ApiOptions options)
{
Ensure.ArgumentNotNull(options, "options");
return _connection.GetAndFlattenAllPages<Team>(ApiUrls.UserTeams(), options);
}
/// <summary>
@@ -72,7 +99,24 @@ namespace Octokit.Reactive
/// <returns>A list of the team's member <see cref="User"/>s.</returns>
public IObservable<User> GetAllMembers(int id)
{
return _connection.GetAndFlattenAllPages<User>(ApiUrls.TeamMembers(id));
return GetAllMembers(id, ApiOptions.None);
}
/// <summary>
/// Returns all members of the given team.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/orgs/teams/#list-team-members
/// </remarks>
/// <param name="id">The team identifier</param>
/// <param name="options">Options to change API behaviour.</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>A list of the team's member <see cref="User"/>s.</returns>
public IObservable<User> GetAllMembers(int id, ApiOptions options)
{
Ensure.ArgumentNotNull(options, "options");
return _connection.GetAndFlattenAllPages<User>(ApiUrls.TeamMembers(id), options);
}
/// <summary>
@@ -166,7 +210,21 @@ namespace Octokit.Reactive
/// <returns>The team's repositories</returns>
public IObservable<Repository> GetAllRepositories(int id)
{
return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.TeamRepositories(id));
return GetAllRepositories(id, ApiOptions.None);
}
/// <summary>
/// Returns all team's repositories.
/// </summary>
/// <param name="id">Team Id.</param>
/// <param name="options">Options to change API behaviour.</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>The team's repositories</returns>
public IObservable<Repository> GetAllRepositories(int id, ApiOptions options)
{
Ensure.ArgumentNotNull(options, "options");
return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.TeamRepositories(id), options);
}
/// <summary>
@@ -26,7 +26,7 @@ public class ObservableTeamsClientTests
var client = new ObservableTeamsClient(github);
var member = await client.GetAllMembers(team.Id);
var member = await client.GetAllMembers(team.Id, ApiOptions.None);
Assert.Equal(Helper.UserName, member.Login);
}