diff --git a/Octokit.Reactive/Clients/IObservableTeamsClient.cs b/Octokit.Reactive/Clients/IObservableTeamsClient.cs
index e6671028de..dc17b6f416 100644
--- a/Octokit.Reactive/Clients/IObservableTeamsClient.cs
+++ b/Octokit.Reactive/Clients/IObservableTeamsClient.cs
@@ -27,10 +27,20 @@ public interface IObservableTeamsClient
///
/// Returns all s for the current org.
///
+ /// Organization to list all teams of.
/// Thrown when a general API error occurs.
/// A list of the orgs's teams s.
IObservable GetAll(string org);
+ ///
+ /// Returns all s for the current org.
+ ///
+ /// Organization to list all teams of.
+ /// Options to change API behaviour.
+ /// Thrown when a general API error occurs.
+ /// A list of the orgs's teams s.
+ IObservable GetAll(string org, ApiOptions options);
+
///
/// Returns all s for the current user.
///
@@ -39,17 +49,38 @@ public interface IObservableTeamsClient
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
IObservable GetAllForCurrent();
+ ///
+ /// Returns all s for the current user.
+ ///
+ /// Options to change API behaviour.
+ /// Thrown when a general API error occurs.
+ /// A list of the user's s.
+ [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
+ IObservable GetAllForCurrent(ApiOptions options);
+
///
/// Returns all members of the given team.
///
- /// The team identifier
///
/// https://developer.github.com/v3/orgs/teams/#list-team-members
///
+ /// The team identifier
/// Thrown when a general API error occurs.
/// A list of the team's member s.
IObservable GetAllMembers(int id);
+ ///
+ /// Returns all members of the given team.
+ ///
+ ///
+ /// https://developer.github.com/v3/orgs/teams/#list-team-members
+ ///
+ /// The team identifier
+ /// Options to change API behaviour.
+ /// Thrown when a general API error occurs.
+ /// A list of the team's member s.
+ IObservable GetAllMembers(int id, ApiOptions options);
+
///
/// Returns newly created for the current org.
///
@@ -116,10 +147,20 @@ public interface IObservableTeamsClient
///
/// Returns all team's repositories.
///
+ /// Team Id.
/// Thrown when a general API error occurs.
/// The team's repositories
IObservable GetAllRepositories(int id);
+ ///
+ /// Returns all team's repositories.
+ ///
+ /// Team Id.
+ /// Options to change API behaviour.
+ /// Thrown when a general API error occurs.
+ /// The team's repositories
+ IObservable GetAllRepositories(int id, ApiOptions options);
+
///
/// Remove a repository from the team
///
diff --git a/Octokit.Reactive/Clients/ObservableTeamsClient.cs b/Octokit.Reactive/Clients/ObservableTeamsClient.cs
index c4d449858d..1711f78c6f 100644
--- a/Octokit.Reactive/Clients/ObservableTeamsClient.cs
+++ b/Octokit.Reactive/Clients/ObservableTeamsClient.cs
@@ -48,7 +48,23 @@ public IObservable Get(int id)
public IObservable GetAll(string org)
{
Ensure.ArgumentNotNullOrEmptyString(org, "org");
- return _connection.GetAndFlattenAllPages(ApiUrls.OrganizationTeams(org));
+
+ return GetAll(org, ApiOptions.None);
+ }
+
+ ///
+ /// Returns all s for the current org.
+ ///
+ /// Organization to list all teams of.
+ /// Options to change API behaviour.
+ /// Thrown when a general API error occurs.
+ /// A list of the orgs's teams s.
+ public IObservable GetAll(string org, ApiOptions options)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(org, "org");
+ Ensure.ArgumentNotNull(options, "options");
+
+ return _connection.GetAndFlattenAllPages(ApiUrls.OrganizationTeams(org), options);
}
///
@@ -58,7 +74,20 @@ public IObservable GetAll(string org)
/// A list of the user's s.
public IObservable GetAllForCurrent()
{
- return _connection.GetAndFlattenAllPages(ApiUrls.UserTeams());
+ return GetAllForCurrent(ApiOptions.None);
+ }
+
+ ///
+ /// Returns all s for the current user.
+ ///
+ /// Options to change API behaviour.
+ /// Thrown when a general API error occurs.
+ /// A list of the user's s.
+ public IObservable GetAllForCurrent(ApiOptions options)
+ {
+ Ensure.ArgumentNotNull(options, "options");
+
+ return _connection.GetAndFlattenAllPages(ApiUrls.UserTeams(), options);
}
///
@@ -72,7 +101,24 @@ public IObservable GetAllForCurrent()
/// A list of the team's member s.
public IObservable GetAllMembers(int id)
{
- return _connection.GetAndFlattenAllPages(ApiUrls.TeamMembers(id));
+ return GetAllMembers(id, ApiOptions.None);
+ }
+
+ ///
+ /// Returns all members of the given team.
+ ///
+ ///
+ /// https://developer.github.com/v3/orgs/teams/#list-team-members
+ ///
+ /// The team identifier
+ /// Options to change API behaviour.
+ /// Thrown when a general API error occurs.
+ /// A list of the team's member s.
+ public IObservable GetAllMembers(int id, ApiOptions options)
+ {
+ Ensure.ArgumentNotNull(options, "options");
+
+ return _connection.GetAndFlattenAllPages(ApiUrls.TeamMembers(id), options);
}
///
@@ -82,6 +128,9 @@ public IObservable GetAllMembers(int id)
/// Newly created
public IObservable Create(string org, NewTeam team)
{
+ Ensure.ArgumentNotNullOrEmptyString(org, "org");
+ Ensure.ArgumentNotNull(team, "team");
+
return _client.Create(org, team).ToObservable();
}
@@ -92,6 +141,8 @@ public IObservable Create(string org, NewTeam team)
/// Updated
public IObservable Update(int id, UpdateTeam team)
{
+ Ensure.ArgumentNotNull(team, "team");
+
return _client.Update(id, team).ToObservable();
}
@@ -117,6 +168,8 @@ public IObservable Delete(int id)
/// A result indicating the membership status
public IObservable AddMembership(int id, string login)
{
+ Ensure.ArgumentNotNullOrEmptyString(login, "login");
+
return _client.AddMembership(id, login).ToObservable();
}
@@ -131,6 +184,8 @@ public IObservable AddMembership(int id, string login)
/// if the user was removed from the team; otherwise.
public IObservable RemoveMembership(int id, string login)
{
+ Ensure.ArgumentNotNullOrEmptyString(login, "login");
+
return _client.RemoveMembership(id, login).ToObservable();
}
@@ -144,6 +199,8 @@ public IObservable RemoveMembership(int id, string login)
[Obsolete("Use GetMembership(id, login) to detect pending memberships")]
public IObservable IsMember(int id, string login)
{
+ Ensure.ArgumentNotNullOrEmptyString(login, "login");
+
return _client.IsMember(id, login).ToObservable();
}
@@ -156,6 +213,8 @@ public IObservable IsMember(int id, string login)
/// A result indicating the membership status
public IObservable GetMembership(int id, string login)
{
+ Ensure.ArgumentNotNullOrEmptyString(login, "login");
+
return _client.GetMembership(id, login).ToObservable();
}
@@ -166,7 +225,21 @@ public IObservable GetMembership(int id, string login)
/// The team's repositories
public IObservable GetAllRepositories(int id)
{
- return _connection.GetAndFlattenAllPages(ApiUrls.TeamRepositories(id));
+ return GetAllRepositories(id, ApiOptions.None);
+ }
+
+ ///
+ /// Returns all team's repositories.
+ ///
+ /// Team Id.
+ /// Options to change API behaviour.
+ /// Thrown when a general API error occurs.
+ /// The team's repositories
+ public IObservable GetAllRepositories(int id, ApiOptions options)
+ {
+ Ensure.ArgumentNotNull(options, "options");
+
+ return _connection.GetAndFlattenAllPages(ApiUrls.TeamRepositories(id), options);
}
///
@@ -182,6 +255,9 @@ public IObservable GetAllRepositories(int id)
/// if the repository was added to the team; otherwise.
public IObservable AddRepository(int id, string organization, string repoName)
{
+ Ensure.ArgumentNotNullOrEmptyString(organization, "organization");
+ Ensure.ArgumentNotNullOrEmptyString(repoName, "repoName");
+
return _client.AddRepository(id, organization, repoName).ToObservable();
}
@@ -193,6 +269,9 @@ public IObservable AddRepository(int id, string organization, string repoN
///
public IObservable RemoveRepository(int id, string organization, string repoName)
{
+ Ensure.ArgumentNotNullOrEmptyString(organization, "organization");
+ Ensure.ArgumentNotNullOrEmptyString(repoName, "repoName");
+
return _client.RemoveRepository(id, organization, repoName).ToObservable();
}
@@ -208,6 +287,8 @@ public IObservable RemoveRepository(int id, string organization, string re
/// if the repository is managed by the given team; otherwise.
public IObservable IsRepositoryManagedByTeam(int id, string owner, string repo)
{
+ Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
+ Ensure.ArgumentNotNullOrEmptyString(repo, "repo");
return _client.IsRepositoryManagedByTeam(id, owner, repo).ToObservable();
}
}
diff --git a/Octokit.Tests.Integration/Clients/TeamsClientTests.cs b/Octokit.Tests.Integration/Clients/TeamsClientTests.cs
index 1e653c79ac..a80a6da040 100644
--- a/Octokit.Tests.Integration/Clients/TeamsClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/TeamsClientTests.cs
@@ -48,7 +48,7 @@ public async Task SucceedsWhenAuthenticated()
public class TheGetAllForCurrentMethod
{
[IntegrationTest]
- public async Task GetsIsMemberWhenAuthenticated()
+ public async Task GetsAllForCurrentWhenAuthenticated()
{
var github = Helper.GetAuthenticatedClient();
var teams = await github.Organization.Team.GetAllForCurrent();
diff --git a/Octokit.Tests.Integration/Reactive/ObservableTeamsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableTeamsClientTests.cs
index bf8dc203f3..d6743e8cdb 100644
--- a/Octokit.Tests.Integration/Reactive/ObservableTeamsClientTests.cs
+++ b/Octokit.Tests.Integration/Reactive/ObservableTeamsClientTests.cs
@@ -10,13 +10,13 @@ public class ObservableTeamsClientTests
{
public class TheGetMembersMethod
{
- readonly Team team;
+ readonly Team _team;
public TheGetMembersMethod()
{
var github = Helper.GetAuthenticatedClient();
- team = github.Organization.Team.GetAll(Helper.Organization).Result.First();
+ _team = github.Organization.Team.GetAll(Helper.Organization).Result.First();
}
[OrganizationTest]
@@ -26,7 +26,7 @@ public async Task GetsAllMembersWhenAuthenticated()
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);
}
diff --git a/Octokit.Tests/Clients/TeamsClientTests.cs b/Octokit.Tests/Clients/TeamsClientTests.cs
index c7722ac452..6305dd0dfc 100644
--- a/Octokit.Tests/Clients/TeamsClientTests.cs
+++ b/Octokit.Tests/Clients/TeamsClientTests.cs
@@ -45,7 +45,9 @@ public void RequestsTheCorrectUrl()
client.GetAll("orgName");
- connection.Received().GetAll(Arg.Is(u => u.ToString() == "orgs/orgName/teams"));
+ connection.Received().GetAll(
+ Arg.Is(u => u.ToString() == "orgs/orgName/teams"),
+ Args.ApiOptions);
}
[Fact]
@@ -54,6 +56,7 @@ public async Task EnsuresNonNullArguments()
var teams = new TeamsClient(Substitute.For());
await Assert.ThrowsAsync(() => teams.GetAll(null));
+ await Assert.ThrowsAsync(() => teams.GetAll("orgName", null));
}
}
@@ -67,7 +70,9 @@ public void RequestsTheCorrectUrl()
client.GetAllMembers(1);
- connection.Received().GetAll(Arg.Is(u => u.ToString() == "teams/1/members"));
+ connection.Received().GetAll(
+ Arg.Is(u => u.ToString() == "teams/1/members"),
+ Args.ApiOptions);
}
}
@@ -188,7 +193,9 @@ public void RequestsTheCorrectUrl()
client.GetAllForCurrent();
- connection.Received().GetAll(Arg.Is(u => u.ToString() == "user/teams"));
+ connection.Received().GetAll(
+ Arg.Is(u => u.ToString() == "user/teams"),
+ Args.ApiOptions);
}
}
@@ -243,13 +250,12 @@ public void RequestsTheCorrectUrl()
{
var connection = Substitute.For();
var client = new TeamsClient(connection);
- client.GetAllRepositories(1);
-
- connection.Received().GetAll(Arg.Is(u => u.ToString() == "teams/1/repos"));
client.GetAllRepositories(1);
- connection.Received().GetAll(Arg.Is(u => u.ToString() == "teams/1/repos"));
+ connection.Received().GetAll(
+ Arg.Is(u => u.ToString() == "teams/1/repos"),
+ Args.ApiOptions);
}
}
diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj
index e93524cfaa..8aee294e26 100644
--- a/Octokit.Tests/Octokit.Tests.csproj
+++ b/Octokit.Tests/Octokit.Tests.csproj
@@ -220,6 +220,7 @@
+
diff --git a/Octokit.Tests/Reactive/ObservableTeamsClientTests.cs b/Octokit.Tests/Reactive/ObservableTeamsClientTests.cs
new file mode 100644
index 0000000000..eebd3491c5
--- /dev/null
+++ b/Octokit.Tests/Reactive/ObservableTeamsClientTests.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Reactive.Threading.Tasks;
+using System.Threading.Tasks;
+using NSubstitute;
+using Octokit.Reactive;
+using Xunit;
+
+namespace Octokit.Tests.Reactive
+{
+ public class ObservableTeamsClientTests
+ {
+ public class TheCreateMethod
+ {
+ [Fact]
+ public void PostsToCorrectUrl()
+ {
+ var team = new NewTeam("avengers");
+ var github = Substitute.For();
+ var client = new ObservableTeamsClient(github);
+
+ client.Create("shield", team);
+
+ github.Organization.Team.Received().Create("shield", team);
+ }
+
+ [Fact]
+ public void EnsuresNotNullAndNonEmptyArguments()
+ {
+ var github = Substitute.For();
+ var client = new ObservableTeamsClient(github);
+
+ Assert.ThrowsAsync(() => client.Create("shield", null).ToTask());
+ Assert.ThrowsAsync(() => client.Create(null, new NewTeam("avengers")).ToTask());
+ Assert.ThrowsAsync(() => client.Create("", new NewTeam("avengers")).ToTask());
+ }
+ }
+
+ public class TheCtor
+ {
+ [Fact]
+ public void EnsuresNotNullGitHubClient()
+ {
+ Assert.Throws(() => new ObservableTeamsClient(null));
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Octokit/Clients/ITeamsClient.cs b/Octokit/Clients/ITeamsClient.cs
index 453427680c..ec832db373 100644
--- a/Octokit/Clients/ITeamsClient.cs
+++ b/Octokit/Clients/ITeamsClient.cs
@@ -30,10 +30,20 @@ public interface ITeamsClient
///
/// Returns all s for the current org.
///
+ /// Organization for which to list all teams.
/// Thrown when a general API error occurs.
/// A list of the orgs's teams s.
Task> GetAll(string org);
+ ///
+ /// Returns all s for the current org.
+ ///
+ /// Organization for which to list all teams.
+ /// Options to change API behaviour.
+ /// Thrown when a general API error occurs.
+ /// A list of the orgs's teams s.
+ Task> GetAll(string org, ApiOptions options);
+
///
/// Returns all s for the current user.
///
@@ -42,6 +52,15 @@ public interface ITeamsClient
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
Task> GetAllForCurrent();
+ ///
+ /// Returns all s for the current user.
+ ///
+ /// Options to change API behaviour.
+ /// Thrown when a general API error occurs.
+ /// A list of the user's s.
+ [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
+ Task> GetAllForCurrent(ApiOptions options);
+
///
/// Returns all members of the given team.
///
@@ -52,6 +71,17 @@ public interface ITeamsClient
/// A list of the team's member s.
Task> GetAllMembers(int id);
+ ///
+ /// Returns all members of the given team.
+ ///
+ /// The team identifier
+ /// Options to change API behaviour.
+ ///
+ /// https://developer.github.com/v3/orgs/teams/#list-team-members
+ ///
+ /// A list of the team's member s.
+ Task> GetAllMembers(int id, ApiOptions options);
+
///
/// Returns newly created for the current org.
///
@@ -118,10 +148,20 @@ public interface ITeamsClient
///
/// Returns all team's repositories.
///
+ /// Team Id to list repos.
/// Thrown when a general API error occurs.
/// The team's repositories
Task> GetAllRepositories(int id);
+ ///
+ /// Returns all team's repositories.
+ ///
+ /// Team Id to list repos.
+ /// Options to change API behaviour.
+ /// Thrown when a general API error occurs.
+ /// The team's repositories
+ Task> GetAllRepositories(int id, ApiOptions options);
+
///
/// Add a repository to the team
///
diff --git a/Octokit/Clients/TeamsClient.cs b/Octokit/Clients/TeamsClient.cs
index 4cdf2d2785..67376b423a 100644
--- a/Octokit/Clients/TeamsClient.cs
+++ b/Octokit/Clients/TeamsClient.cs
@@ -42,14 +42,28 @@ public Task Get(int id)
///
/// Returns all s for the current org.
///
+ /// Organization to list teams of.
/// Thrown when a general API error occurs.
/// A list of the orgs's teams s.
public Task> GetAll(string org)
+ {
+ return GetAll(org, ApiOptions.None);
+ }
+
+ ///
+ /// Returns all s for the current org.
+ ///
+ /// Organization to list teams of.
+ /// Options to change API behaviour.
+ /// Thrown when a general API error occurs.
+ /// A list of the orgs's teams s.
+ public Task> GetAll(string org, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(org, "org");
+ Ensure.ArgumentNotNull(options, "options");
var endpoint = ApiUrls.OrganizationTeams(org);
- return ApiConnection.GetAll(endpoint);
+ return ApiConnection.GetAll(endpoint, options);
}
///
@@ -59,8 +73,22 @@ public Task> GetAll(string org)
/// A list of the user's s.
public Task> GetAllForCurrent()
{
+ return GetAllForCurrent(ApiOptions.None);
+ }
+
+ ///
+ /// Returns all s for the current user.
+ ///
+ /// Options to change API behaviour.
+ /// Thrown when a general API error occurs.
+ /// A list of the user's s.
+ public Task> GetAllForCurrent(ApiOptions options)
+ {
+ Ensure.ArgumentNotNull(options, "options");
+
var endpoint = ApiUrls.UserTeams();
- return ApiConnection.GetAll(endpoint);
+
+ return ApiConnection.GetAll(endpoint, options);
}
///
@@ -73,9 +101,25 @@ public Task> GetAllForCurrent()
/// A list of the team's member s.
public Task> GetAllMembers(int id)
{
+ return GetAllMembers(id, ApiOptions.None);
+ }
+
+ ///
+ /// Returns all members of the given team.
+ ///
+ ///
+ /// https://developer.github.com/v3/orgs/teams/#list-team-members
+ ///
+ /// The team identifier
+ /// Options to change API behaviour.
+ /// A list of the team's member s.
+ public Task> GetAllMembers(int id, ApiOptions options)
+ {
+ Ensure.ArgumentNotNull(options, "options");
+
var endpoint = ApiUrls.TeamMembers(id);
- return ApiConnection.GetAll(endpoint);
+ return ApiConnection.GetAll(endpoint, options);
}
///
@@ -236,13 +280,28 @@ public async Task IsMember(int id, string login)
///
/// Returns all team's repositories.
///
+ /// Team Id.
/// Thrown when a general API error occurs.
/// The team's repositories
public Task> GetAllRepositories(int id)
{
+ return GetAllRepositories(id, ApiOptions.None);
+ }
+
+ ///
+ /// Returns all team's repositories.
+ ///
+ /// Team Id.
+ /// Options to change API behaviour.
+ /// Thrown when a general API error occurs.
+ /// The team's repositories
+ public Task> GetAllRepositories(int id, ApiOptions options)
+ {
+ Ensure.ArgumentNotNull(options, "options");
+
var endpoint = ApiUrls.TeamRepositories(id);
- return ApiConnection.GetAll(endpoint);
+ return ApiConnection.GetAll(endpoint, options);
}
///