From b4fc16e6840ecdc3548d06f26f43fdc1689152bf Mon Sep 17 00:00:00 2001 From: "Jason K." Date: Thu, 27 Feb 2014 16:46:29 -0500 Subject: [PATCH 01/35] - Renamed ApiUrls.TeamsUpdateOrDelete method name to just "Team". This was done because the same Uri is also used to get a team, not just updating and deleting. - Fixed references pointing to method name that was changed. --- Octokit/Clients/TeamsClient.cs | 4 ++-- Octokit/Helpers/ApiUrls.cs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Octokit/Clients/TeamsClient.cs b/Octokit/Clients/TeamsClient.cs index 0af67320..9928e62e 100644 --- a/Octokit/Clients/TeamsClient.cs +++ b/Octokit/Clients/TeamsClient.cs @@ -61,7 +61,7 @@ namespace Octokit { Ensure.ArgumentNotNull(team, "team"); - var endpoint = ApiUrls.TeamsUpdateOrDelete(id); + var endpoint = ApiUrls.Team(id); return ApiConnection.Patch(endpoint, team); } @@ -72,7 +72,7 @@ namespace Octokit /// public Task DeleteTeam(int id) { - var endpoint = ApiUrls.TeamsUpdateOrDelete(id); + var endpoint = ApiUrls.Team(id); return ApiConnection.Delete(endpoint); } } diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 5956d371..62671fc3 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -901,12 +901,12 @@ namespace Octokit } /// - /// returns the for teams - /// use for update or deleting a team + /// Returns the for teams + /// use for getting, updating, or deleting a . /// - /// + /// The id of the . /// - public static Uri TeamsUpdateOrDelete(int id) + public static Uri Team(int id) { return "teams/{0}".FormatUri(id); } From 8d3aa5b41e32c6596fe14dc9fe4673984d964d27 Mon Sep 17 00:00:00 2001 From: "Jason K." Date: Thu, 27 Feb 2014 16:50:54 -0500 Subject: [PATCH 02/35] - Added Get method to the Octokit/Clients/ITeamsClient interface. - Implemented the aforementioned Get method in the Octokit/Clients/TeamsClient class. - Added test in Octokit.Tests/Clients/TeamsClientTests for the aforementioned Get method. --- Octokit.Tests/Clients/TeamsClientTests.cs | 14 ++++++++++++++ Octokit/Clients/ITeamsClient.cs | 13 +++++++++++++ Octokit/Clients/TeamsClient.cs | 15 +++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/Octokit.Tests/Clients/TeamsClientTests.cs b/Octokit.Tests/Clients/TeamsClientTests.cs index e3c09858..3251e7d0 100644 --- a/Octokit.Tests/Clients/TeamsClientTests.cs +++ b/Octokit.Tests/Clients/TeamsClientTests.cs @@ -21,6 +21,20 @@ namespace Octokit.Tests.Clients } } + public class TheGetMethod + { + [Fact] + public void RequestsTheCorrectlUrl() + { + var connection = Substitute.For(); + var client = new TeamsClient(connection); + + client.Get(1); + + connection.Received().Get(Arg.Is(u => u.ToString() == "teams/1"), null); + } + } + public class TheGetAllMethod { [Fact] diff --git a/Octokit/Clients/ITeamsClient.cs b/Octokit/Clients/ITeamsClient.cs index a2abafab..c00b5735 100644 --- a/Octokit/Clients/ITeamsClient.cs +++ b/Octokit/Clients/ITeamsClient.cs @@ -14,6 +14,19 @@ namespace Octokit /// public interface ITeamsClient { + /// + /// Gets a . + /// + /// + /// http://developer.github.com/v3/orgs/teams/#get-team + /// + /// The id of the . + /// Thrown when a general API error occurs. + /// A . + [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", + Justification = "Method makes a network request")] + Task Get(int id); + /// /// Returns all s for the current org. /// diff --git a/Octokit/Clients/TeamsClient.cs b/Octokit/Clients/TeamsClient.cs index 9928e62e..8d02e3df 100644 --- a/Octokit/Clients/TeamsClient.cs +++ b/Octokit/Clients/TeamsClient.cs @@ -24,6 +24,21 @@ namespace Octokit { } + /// + /// Gets a . + /// + /// + /// http://developer.github.com/v3/orgs/teams/#get-team + /// + /// The id of the . + /// Thrown when a general API error occurs. + /// A . + public Task Get(int id) + { + var endpoint = ApiUrls.Team(id); + return ApiConnection.Get(endpoint); + } + /// /// Returns all s for the current org. /// From 8b6a05579ac02f89281759f182982dc700151eeb Mon Sep 17 00:00:00 2001 From: "Jason K." Date: Thu, 27 Feb 2014 16:53:01 -0500 Subject: [PATCH 03/35] - Added Get method to Octokit.Reactive/Clients/IObservableTeamsClient interface. - Implemented aforementioned Get method in Octokit.Reactive/Clients/ObservableTeamsClient class. --- Octokit.Reactive/Clients/IObservableTeamsClient.cs | 14 ++++++++++++++ Octokit.Reactive/Clients/ObservableTeamsClient.cs | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/Octokit.Reactive/Clients/IObservableTeamsClient.cs b/Octokit.Reactive/Clients/IObservableTeamsClient.cs index f70d4cfa..bc97c4e7 100644 --- a/Octokit.Reactive/Clients/IObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/IObservableTeamsClient.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics.CodeAnalysis; using System.Reactive; namespace Octokit.Reactive @@ -11,6 +12,19 @@ namespace Octokit.Reactive /// public interface IObservableTeamsClient { + /// + /// Gets a . + /// + /// + /// http://developer.github.com/v3/orgs/teams/#get-team + /// + /// The id of the . + /// Thrown when a general API error occurs. + /// A . + [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", + Justification = "Method makes a network request")] + IObservable Get(int id); + /// /// Returns all s for the current org. /// diff --git a/Octokit.Reactive/Clients/ObservableTeamsClient.cs b/Octokit.Reactive/Clients/ObservableTeamsClient.cs index cf4fdf23..2c8fa22e 100644 --- a/Octokit.Reactive/Clients/ObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/ObservableTeamsClient.cs @@ -27,6 +27,20 @@ namespace Octokit.Reactive _client = client.Organization.Team; } + /// + /// Gets a . + /// + /// + /// http://developer.github.com/v3/orgs/teams/#get-team + /// + /// The id of the . + /// Thrown when a general API error occurs. + /// A . + public IObservable Get(int id) + { + return _client.Get(id).ToObservable(); + } + /// /// Returns all s for the current org. /// From b153f762535974593a78cfb9a066eef2a7e69e8e Mon Sep 17 00:00:00 2001 From: Jason Kanaris Date: Thu, 10 Jul 2014 00:05:23 -0400 Subject: [PATCH 04/35] Add more methods to teams client - Added functionality for AddMember, RemoveMember and GetRepositories - Unit tests missing for now. --- .../Clients/IObservableTeamsClient.cs | 35 +++++++++ .../Clients/ObservableTeamsClient.cs | 43 +++++++++++ Octokit/Clients/ITeamsClient.cs | 35 +++++++++ Octokit/Clients/TeamsClient.cs | 72 +++++++++++++++++++ Octokit/Helpers/ApiUrls.cs | 9 +++ 5 files changed, 194 insertions(+) diff --git a/Octokit.Reactive/Clients/IObservableTeamsClient.cs b/Octokit.Reactive/Clients/IObservableTeamsClient.cs index bf670845..cf51c40e 100644 --- a/Octokit.Reactive/Clients/IObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/IObservableTeamsClient.cs @@ -64,6 +64,30 @@ namespace Octokit.Reactive /// IObservable Delete(int id); + /// + /// Adds a to a . + /// + /// + /// See the API documentation for more information. + /// + /// The team identifier. + /// The user to add to the team. + /// Thrown when a general API error occurs. + /// if the user was added to the team; otherwise. + IObservable AddMember(int id, string login); + + /// + /// Removes a from a . + /// + /// + /// See the API documentation for more information. + /// + /// The team identifier. + /// The user to remove from the team. + /// Thrown when a general API error occurs. + /// if the user was removed from the team; otherwise. + IObservable RemoveMember(int id, string login); + /// /// Gets whether the user with the given /// is a member of the team with the given . @@ -72,5 +96,16 @@ namespace Octokit.Reactive /// The user to check. /// if the user is a member of the team; otherwise. IObservable IsMember(int id, string login); + + /// + /// Returns all (ies) associated with the given team. + /// + /// The team identifier + /// + /// See the API documentation for more information. + /// + /// Thrown when a general API error occurs. + /// A list of the team's (ies). + IObservable GetRepositories(int id); } } diff --git a/Octokit.Reactive/Clients/ObservableTeamsClient.cs b/Octokit.Reactive/Clients/ObservableTeamsClient.cs index 28bb3843..50beb15a 100644 --- a/Octokit.Reactive/Clients/ObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/ObservableTeamsClient.cs @@ -96,6 +96,36 @@ namespace Octokit.Reactive return _client.Delete(id).ToObservable(); } + /// + /// Adds a to a . + /// + /// + /// See the API documentation for more information. + /// + /// The team identifier. + /// The user to add to the team. + /// Thrown when a general API error occurs. + /// if the user was added to the team; otherwise. + public IObservable AddMember(int id, string login) + { + return _client.AddMember(id, login).ToObservable(); + } + + /// + /// Removes a from a . + /// + /// + /// See the API documentation for more information. + /// + /// The team identifier. + /// The user to remove from the team. + /// Thrown when a general API error occurs. + /// if the user was removed from the team; otherwise. + public IObservable RemoveMember(int id, string login) + { + return _client.RemoveMember(id, login).ToObservable(); + } + /// /// Gets whether the user with the given /// is a member of the team with the given . @@ -108,5 +138,18 @@ namespace Octokit.Reactive return _client.IsMember(id, login).ToObservable(); } + /// + /// Returns all (ies) associated with the given team. + /// + /// The team identifier + /// + /// See the API documentation for more information. + /// + /// Thrown when a general API error occurs. + /// A list of the team's (ies). + public IObservable GetRepositories(int id) + { + return _connection.GetAndFlattenAllPages(ApiUrls.TeamRepositories(id)); + } } } diff --git a/Octokit/Clients/ITeamsClient.cs b/Octokit/Clients/ITeamsClient.cs index 9fc03371..7077c402 100644 --- a/Octokit/Clients/ITeamsClient.cs +++ b/Octokit/Clients/ITeamsClient.cs @@ -65,6 +65,30 @@ namespace Octokit /// Task Delete(int id); + /// + /// Adds a to a . + /// + /// + /// See the API documentation for more information. + /// + /// The team identifier. + /// The user to add to the team. + /// Thrown when a general API error occurs. + /// if the user was added to the team; otherwise. + Task AddMember(int id, string login); + + /// + /// Removes a from a . + /// + /// + /// See the API documentation for more information. + /// + /// The team identifier. + /// The user to remove from the team. + /// Thrown when a general API error occurs. + /// if the user was removed from the team; otherwise. + Task RemoveMember(int id, string login); + /// /// Gets whether the user with the given /// is a member of the team with the given . @@ -73,5 +97,16 @@ namespace Octokit /// The user to check. /// if the user is a member of the team; otherwise. Task IsMember(int id, string login); + + /// + /// Returns all (ies) associated with the given team. + /// + /// The team identifier + /// + /// See the API documentation for more information. + /// + /// Thrown when a general API error occurs. + /// A list of the team's (ies). + Task> GetRepositories(int id); } } diff --git a/Octokit/Clients/TeamsClient.cs b/Octokit/Clients/TeamsClient.cs index 1211becf..58946681 100644 --- a/Octokit/Clients/TeamsClient.cs +++ b/Octokit/Clients/TeamsClient.cs @@ -107,6 +107,62 @@ namespace Octokit return ApiConnection.Delete(endpoint); } + /// + /// Adds a to a . + /// + /// + /// See the API documentation for more information. + /// + /// The team identifier. + /// The user to add to the team. + /// Thrown when a general API error occurs. + /// if the user was added to the team; otherwise. + public async Task AddMember(int id, string login) + { + Ensure.ArgumentNotNullOrEmptyString(login, "login"); + + var endpoint = ApiUrls.TeamMember(id, login); + + try + { + var httpStatusCode = await ApiConnection.Connection.Put(endpoint); + + return httpStatusCode == System.Net.HttpStatusCode.NoContent; + } + catch (NotFoundException) + { + return false; + } + } + + /// + /// Removes a from a . + /// + /// + /// See the API documentation for more information. + /// + /// The team identifier. + /// The user to remove from the team. + /// Thrown when a general API error occurs. + /// if the user was removed from the team; otherwise. + public async Task RemoveMember(int id, string login) + { + Ensure.ArgumentNotNullOrEmptyString(login, "login"); + + var endpoint = ApiUrls.TeamMember(id, login); + + try + { + var httpStatusCode = await ApiConnection.Connection.Delete(endpoint); + + return httpStatusCode == System.Net.HttpStatusCode.NoContent; + } + catch (NotFoundException) + { + return false; + } + } + /// /// Gets whether the user with the given /// is a member of the team with the given . @@ -130,5 +186,21 @@ namespace Octokit return false; } } + + /// + /// Returns all (ies) associated with the given team. + /// + /// The team identifier + /// + /// See the API documentation for more information. + /// + /// Thrown when a general API error occurs. + /// A list of the team's (ies). + public Task> GetRepositories(int id) + { + var endpoint = ApiUrls.TeamRepositories(id); + + return ApiConnection.GetAll(endpoint); + } } } diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 7b1ba17a..40fab094 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -954,6 +954,15 @@ namespace Octokit return "teams/{0}/members".FormatUri(id); } + /// + /// returns the for listing team repositories + /// + /// The team id + public static Uri TeamRepositories(int id) + { + return "teams/{0}/repos".FormatUri(id); + } + /// /// returns the for teams /// use for update or deleting a team From 824cc14f8c568db5324f6c52c22898ff1e151b7e Mon Sep 17 00:00:00 2001 From: "Jason K." Date: Thu, 10 Jul 2014 11:31:09 -0400 Subject: [PATCH 05/35] Added todo's to make tests for recently add methods --- Octokit.Tests/Clients/TeamsClientTests.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Octokit.Tests/Clients/TeamsClientTests.cs b/Octokit.Tests/Clients/TeamsClientTests.cs index 8f564eb3..af600bcc 100644 --- a/Octokit.Tests/Clients/TeamsClientTests.cs +++ b/Octokit.Tests/Clients/TeamsClientTests.cs @@ -135,6 +135,10 @@ namespace Octokit.Tests.Clients } } +#warning TODO: Add test for AddMember method. + +#warning TODO: Add test for RemoveMember method. + public class TheIsMemberMethod { [Fact] @@ -155,5 +159,7 @@ namespace Octokit.Tests.Clients AssertEx.Throws(() => client.IsMember(1, "")); } } + +#warning TODO: Add test for GetRepositories method. } } From 7560c03d5b378f7f0b59dcdacf5759b0bfa156bc Mon Sep 17 00:00:00 2001 From: Jason Kanaris Date: Fri, 11 Jul 2014 00:10:31 -0400 Subject: [PATCH 06/35] xml-doc exception documentation changes for teams client - Removed generic ApiException exception from xml-doc on Teams related client methods. - Added ApiValidationException exception in xml-doc for AddMember team client method. --- Octokit.Reactive/Clients/IObservableTeamsClient.cs | 10 +--------- Octokit.Reactive/Clients/ObservableTeamsClient.cs | 10 +--------- Octokit/Clients/ITeamsClient.cs | 9 +-------- Octokit/Clients/TeamsClient.cs | 9 +-------- 4 files changed, 4 insertions(+), 34 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableTeamsClient.cs b/Octokit.Reactive/Clients/IObservableTeamsClient.cs index cf51c40e..ea016b0c 100644 --- a/Octokit.Reactive/Clients/IObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/IObservableTeamsClient.cs @@ -19,7 +19,6 @@ namespace Octokit.Reactive /// https://developer.github.com/v3/orgs/teams/#get-team /// /// The team identifier. - /// Thrown when a general API error occurs. /// The with the given identifier. [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "Method makes a network request")] @@ -28,7 +27,6 @@ namespace Octokit.Reactive /// /// Returns all s for the current org. /// - /// Thrown when a general API error occurs. /// A list of the orgs's teams s. IObservable GetAll(string org); @@ -39,28 +37,24 @@ namespace Octokit.Reactive /// /// https://developer.github.com/v3/orgs/teams/#list-team-members /// - /// Thrown when a general API error occurs. /// A list of the team's member s. IObservable GetMembers(int id); /// /// Returns newly created for the current org. /// - /// Thrown when a general API error occurs. /// Newly created IObservable Create(string org, NewTeam team); /// /// Returns updated for the current org. /// - /// Thrown when a general API error occurs. /// Updated IObservable Update(int id, UpdateTeam team); /// /// Delete a team - must have owner permissions to this /// - /// Thrown when a general API error occurs. /// IObservable Delete(int id); @@ -72,7 +66,7 @@ namespace Octokit.Reactive /// /// The team identifier. /// The user to add to the team. - /// Thrown when a general API error occurs. + /// Thrown if you attempt to add an organization to a team. /// if the user was added to the team; otherwise. IObservable AddMember(int id, string login); @@ -84,7 +78,6 @@ namespace Octokit.Reactive /// /// The team identifier. /// The user to remove from the team. - /// Thrown when a general API error occurs. /// if the user was removed from the team; otherwise. IObservable RemoveMember(int id, string login); @@ -104,7 +97,6 @@ namespace Octokit.Reactive /// /// See the API documentation for more information. /// - /// Thrown when a general API error occurs. /// A list of the team's (ies). IObservable GetRepositories(int id); } diff --git a/Octokit.Reactive/Clients/ObservableTeamsClient.cs b/Octokit.Reactive/Clients/ObservableTeamsClient.cs index 50beb15a..12f81b9e 100644 --- a/Octokit.Reactive/Clients/ObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/ObservableTeamsClient.cs @@ -34,7 +34,6 @@ namespace Octokit.Reactive /// https://developer.github.com/v3/orgs/teams/#get-team /// /// The team identifier. - /// Thrown when a general API error occurs. /// The with the given identifier. public IObservable Get(int id) { @@ -44,7 +43,6 @@ namespace Octokit.Reactive /// /// Returns all s for the current org. /// - /// Thrown when a general API error occurs. /// A list of the orgs's teams s. public IObservable GetAll(string org) { @@ -59,7 +57,6 @@ namespace Octokit.Reactive /// /// https://developer.github.com/v3/orgs/teams/#list-team-members /// - /// Thrown when a general API error occurs. /// A list of the team's member s. public IObservable GetMembers(int id) { @@ -69,7 +66,6 @@ namespace Octokit.Reactive /// /// Returns newly created for the current org. /// - /// Thrown when a general API error occurs. /// Newly created public IObservable Create(string org, NewTeam team) { @@ -79,7 +75,6 @@ namespace Octokit.Reactive /// /// Returns updated for the current org. /// - /// Thrown when a general API error occurs. /// Updated public IObservable Update(int id, UpdateTeam team) { @@ -89,7 +84,6 @@ namespace Octokit.Reactive /// /// Delete a team - must have owner permissions to this /// - /// Thrown when a general API error occurs. /// public IObservable Delete(int id) { @@ -104,7 +98,7 @@ namespace Octokit.Reactive /// /// The team identifier. /// The user to add to the team. - /// Thrown when a general API error occurs. + /// Thrown if you attempt to add an organization to a team. /// if the user was added to the team; otherwise. public IObservable AddMember(int id, string login) { @@ -119,7 +113,6 @@ namespace Octokit.Reactive /// /// The team identifier. /// The user to remove from the team. - /// Thrown when a general API error occurs. /// if the user was removed from the team; otherwise. public IObservable RemoveMember(int id, string login) { @@ -145,7 +138,6 @@ namespace Octokit.Reactive /// /// See the API documentation for more information. /// - /// Thrown when a general API error occurs. /// A list of the team's (ies). public IObservable GetRepositories(int id) { diff --git a/Octokit/Clients/ITeamsClient.cs b/Octokit/Clients/ITeamsClient.cs index 7077c402..24030127 100644 --- a/Octokit/Clients/ITeamsClient.cs +++ b/Octokit/Clients/ITeamsClient.cs @@ -21,7 +21,6 @@ namespace Octokit /// https://developer.github.com/v3/orgs/teams/#get-team /// /// The team identifier. - /// Thrown when a general API error occurs. /// The with the given identifier. [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "Method makes a network request")] @@ -30,7 +29,6 @@ namespace Octokit /// /// Returns all s for the current org. /// - /// Thrown when a general API error occurs. /// A list of the orgs's teams s. Task> GetAll(string org); @@ -47,21 +45,18 @@ namespace Octokit /// /// Returns newly created for the current org. /// - /// Thrown when a general API error occurs. /// Newly created Task Create(string org, NewTeam team); /// /// Returns updated for the current org. /// - /// Thrown when a general API error occurs. /// Updated Task Update(int id, UpdateTeam team); /// /// Delte a team - must have owner permissions to this /// - /// Thrown when a general API error occurs. /// Task Delete(int id); @@ -73,7 +68,7 @@ namespace Octokit /// /// The team identifier. /// The user to add to the team. - /// Thrown when a general API error occurs. + /// Thrown if you attempt to add an organization to a team. /// if the user was added to the team; otherwise. Task AddMember(int id, string login); @@ -85,7 +80,6 @@ namespace Octokit /// /// The team identifier. /// The user to remove from the team. - /// Thrown when a general API error occurs. /// if the user was removed from the team; otherwise. Task RemoveMember(int id, string login); @@ -105,7 +99,6 @@ namespace Octokit /// /// See the API documentation for more information. /// - /// Thrown when a general API error occurs. /// A list of the team's (ies). Task> GetRepositories(int id); } diff --git a/Octokit/Clients/TeamsClient.cs b/Octokit/Clients/TeamsClient.cs index 58946681..393cfa4c 100644 --- a/Octokit/Clients/TeamsClient.cs +++ b/Octokit/Clients/TeamsClient.cs @@ -31,7 +31,6 @@ namespace Octokit /// https://developer.github.com/v3/orgs/teams/#get-team /// /// The team identifier. - /// Thrown when a general API error occurs. /// The with the given identifier. public Task Get(int id) { @@ -43,7 +42,6 @@ namespace Octokit /// /// Returns all s for the current org. /// - /// Thrown when a general API error occurs. /// A list of the orgs's teams s. public Task> GetAll(string org) { @@ -71,7 +69,6 @@ namespace Octokit /// /// Returns newly created for the current org. /// - /// Thrown when a general API error occurs. /// Newly created public Task Create(string org, NewTeam team) { @@ -85,7 +82,6 @@ namespace Octokit /// /// Returns updated for the current org. /// - /// Thrown when a general API error occurs. /// Updated public Task Update(int id, UpdateTeam team) { @@ -98,7 +94,6 @@ namespace Octokit /// /// Delte a team - must have owner permissions to this /// - /// Thrown when a general API error occurs. /// public Task Delete(int id) { @@ -115,7 +110,7 @@ namespace Octokit /// /// The team identifier. /// The user to add to the team. - /// Thrown when a general API error occurs. + /// Thrown if you attempt to add an organization to a team. /// if the user was added to the team; otherwise. public async Task AddMember(int id, string login) { @@ -143,7 +138,6 @@ namespace Octokit /// /// The team identifier. /// The user to remove from the team. - /// Thrown when a general API error occurs. /// if the user was removed from the team; otherwise. public async Task RemoveMember(int id, string login) { @@ -194,7 +188,6 @@ namespace Octokit /// /// See the API documentation for more information. /// - /// Thrown when a general API error occurs. /// A list of the team's (ies). public Task> GetRepositories(int id) { From 639055118831a70969fc87c11aa45050f4aef59f Mon Sep 17 00:00:00 2001 From: Jason Kanaris Date: Mon, 14 Jul 2014 01:31:45 -0400 Subject: [PATCH 07/35] Added some more tests for teams client Added AddMember and Remove Member tests. --- Octokit.Tests/Clients/TeamsClientTests.cs | 39 +++++++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/Octokit.Tests/Clients/TeamsClientTests.cs b/Octokit.Tests/Clients/TeamsClientTests.cs index af600bcc..ff9c99f4 100644 --- a/Octokit.Tests/Clients/TeamsClientTests.cs +++ b/Octokit.Tests/Clients/TeamsClientTests.cs @@ -1,8 +1,11 @@ using System; +using System.Net; using System.Threading.Tasks; using NSubstitute; +using Octokit.Internal; using Octokit.Tests.Helpers; using Xunit; +using Xunit.Extensions; namespace Octokit.Tests.Clients { @@ -135,9 +138,39 @@ namespace Octokit.Tests.Clients } } -#warning TODO: Add test for AddMember method. + public class TheAddMemberMethod + { +#warning TODO: implement RequestsTheCorrectUrl test -#warning TODO: Add test for RemoveMember method. +#warning TODO: implement ReturnsCorrectResultBasedOnStatus test + + [Fact] + public void EnsuresNonNullOrEmptyLogin() + { + var connection = Substitute.For(); + var client = new TeamsClient(connection); + + AssertEx.Throws(() => client.AddMember(1, null)); + AssertEx.Throws(() => client.AddMember(1, "")); + } + } + + public class TheRemoveMemberMethod + { +#warning TODO: implement RequestsTheCorrectUrl test + +#warning TODO: implement ReturnsCorrectResultBasedOnStatus test + + [Fact] + public void EnsuresNonNullOrEmptyLogin() + { + var connection = Substitute.For(); + var client = new TeamsClient(connection); + + AssertEx.Throws(() => client.RemoveMember(1, null)); + AssertEx.Throws(() => client.RemoveMember(1, "")); + } + } public class TheIsMemberMethod { @@ -160,6 +193,6 @@ namespace Octokit.Tests.Clients } } -#warning TODO: Add test for GetRepositories method. +#warning TODO: Add tests for GetRepositories method. } } From 4363b8f270f96ce358e03df02c84a8465c7a155e Mon Sep 17 00:00:00 2001 From: Jason Kanaris Date: Tue, 15 Jul 2014 22:24:39 -0400 Subject: [PATCH 08/35] Modifications to teams client tests - Added test for GetRepositories method. - Updated todo's on other tests for the teams client. --- Octokit.Tests/Clients/TeamsClientTests.cs | 24 ++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/Octokit.Tests/Clients/TeamsClientTests.cs b/Octokit.Tests/Clients/TeamsClientTests.cs index ff9c99f4..f1902c3a 100644 --- a/Octokit.Tests/Clients/TeamsClientTests.cs +++ b/Octokit.Tests/Clients/TeamsClientTests.cs @@ -140,9 +140,9 @@ namespace Octokit.Tests.Clients public class TheAddMemberMethod { -#warning TODO: implement RequestsTheCorrectUrl test +#warning TODO: implement RequestsTheCorrectUrl test for TheAddMemberMethod -#warning TODO: implement ReturnsCorrectResultBasedOnStatus test +#warning TODO: implement ReturnsCorrectResultBasedOnStatus test for TheAddMemberMethod [Fact] public void EnsuresNonNullOrEmptyLogin() @@ -157,9 +157,9 @@ namespace Octokit.Tests.Clients public class TheRemoveMemberMethod { -#warning TODO: implement RequestsTheCorrectUrl test +#warning TODO: implement RequestsTheCorrectUrl test for TheRemoveMemberMethod -#warning TODO: implement ReturnsCorrectResultBasedOnStatus test +#warning TODO: implement ReturnsCorrectResultBasedOnStatus test for TheRemoveMemberMethod [Fact] public void EnsuresNonNullOrEmptyLogin() @@ -193,6 +193,20 @@ namespace Octokit.Tests.Clients } } -#warning TODO: Add tests for GetRepositories method. + public class TheGetRepositoriesMethod + { +#warning TODO: implement ReturnsCorrectResultBasedOnStatus test for TheGetRepositoriesMethod + + [Fact] + public void RequestsTheCorrectUrl() + { + var connection = Substitute.For(); + var client = new TeamsClient(connection); + + client.GetRepositories(1); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "teams/1/repos")); + } + } } } From 468741b0da7b922b46508972edb9e8df0c53dc7d Mon Sep 17 00:00:00 2001 From: Jason Kanaris Date: Tue, 15 Jul 2014 23:24:28 -0400 Subject: [PATCH 09/35] More team client repository methods - Added teams client interface methods for AddRepository, RemoveRepository and IsRepositoryManagedByTeam. - Added Uri for the aforementioned methods. --- Octokit/Clients/ITeamsClient.cs | 36 +++++++++++++++++++++++++++++++++ Octokit/Helpers/ApiUrls.cs | 12 +++++++++++ 2 files changed, 48 insertions(+) diff --git a/Octokit/Clients/ITeamsClient.cs b/Octokit/Clients/ITeamsClient.cs index 24030127..57ed5021 100644 --- a/Octokit/Clients/ITeamsClient.cs +++ b/Octokit/Clients/ITeamsClient.cs @@ -101,5 +101,41 @@ namespace Octokit /// /// A list of the team's (ies). Task> GetRepositories(int id); + + /// + /// Adds a to a . + /// + /// The team identifier. + /// Org to associate the repo with. + /// Name of the repo. + /// + /// See the API documentation for more information. + /// + /// + Task AddRepository(int id, string org, string repo); + + /// + /// Removes a from a . + /// + /// The team identifier. + /// Owner of the org the team is associated with. + /// Name of the repo. + /// + /// See the API documentation for more information. + /// + /// + Task RemoveRepository(int id, string owner, string repo); + + /// + /// Gets whether or not the given repository is managed by the given team. + /// + /// The team identifier + /// Owner of the org the team is associated with. + /// Name of the repo. + /// + /// See the API documentation for more information. + /// + /// + Task IsRepositoryManagedByTeam(int id, string owner, string repo); } } diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 40fab094..735d3c9a 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -954,6 +954,18 @@ namespace Octokit return "teams/{0}/members".FormatUri(id); } + /// + /// returns the for adding/removing repo to/from a team and also checking if a team manages a repo. + /// + /// The team id + /// The org or owner (of the org) + /// Name of the repo + /// + public static Uri TeamRepository(int id, string orgOrOwner, string repo) + { + return "teams/{0}/repos/{1}/{2}".FormatUri(id, orgOrOwner, repo); + } + /// /// returns the for listing team repositories /// From a6b60a2bd5918cd30158cef99f7d35c012ed68b3 Mon Sep 17 00:00:00 2001 From: Jason Kanaris Date: Tue, 15 Jul 2014 23:30:19 -0400 Subject: [PATCH 10/35] Forgot some xml-doc items in the ITeamsClient --- Octokit/Clients/ITeamsClient.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Octokit/Clients/ITeamsClient.cs b/Octokit/Clients/ITeamsClient.cs index 57ed5021..6af3a7a3 100644 --- a/Octokit/Clients/ITeamsClient.cs +++ b/Octokit/Clients/ITeamsClient.cs @@ -108,10 +108,11 @@ namespace Octokit /// The team identifier. /// Org to associate the repo with. /// Name of the repo. + /// Thrown if you attempt to add a repository to a team that is not owned by the organization. /// /// See the API documentation for more information. /// - /// + /// if the repository was added to the team; otherwise. Task AddRepository(int id, string org, string repo); /// @@ -123,7 +124,7 @@ namespace Octokit /// /// See the API documentation for more information. /// - /// + /// if the repository was removed from the team; otherwise. Task RemoveRepository(int id, string owner, string repo); /// @@ -135,7 +136,7 @@ namespace Octokit /// /// See the API documentation for more information. /// - /// + /// if the repository is managed by the given team; otherwise. Task IsRepositoryManagedByTeam(int id, string owner, string repo); } } From cd8f54272ebee12de2ae7d07bf4a5cf2b23b99dc Mon Sep 17 00:00:00 2001 From: Jason Kanaris Date: Tue, 15 Jul 2014 23:37:51 -0400 Subject: [PATCH 11/35] Added IObservableTeamsClient interface methods - AddRepository - RemoveRepository - IsRepositoryManagedByTeam --- .../Clients/IObservableTeamsClient.cs | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Octokit.Reactive/Clients/IObservableTeamsClient.cs b/Octokit.Reactive/Clients/IObservableTeamsClient.cs index ea016b0c..25354af2 100644 --- a/Octokit.Reactive/Clients/IObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/IObservableTeamsClient.cs @@ -99,5 +99,42 @@ namespace Octokit.Reactive /// /// A list of the team's (ies). IObservable GetRepositories(int id); + + /// + /// Adds a to a . + /// + /// The team identifier. + /// Org to associate the repo with. + /// Name of the repo. + /// Thrown if you attempt to add a repository to a team that is not owned by the organization. + /// + /// See the API documentation for more information. + /// + /// if the repository was added to the team; otherwise. + IObservable AddRepository(int id, string org, string repo); + + /// + /// Removes a from a . + /// + /// The team identifier. + /// Owner of the org the team is associated with. + /// Name of the repo. + /// + /// See the API documentation for more information. + /// + /// if the repository was removed from the team; otherwise. + IObservable RemoveRepository(int id, string owner, string repo); + + /// + /// Gets whether or not the given repository is managed by the given team. + /// + /// The team identifier + /// Owner of the org the team is associated with. + /// Name of the repo. + /// + /// See the API documentation for more information. + /// + /// if the repository is managed by the given team; otherwise. + IObservable IsRepositoryManagedByTeam(int id, string owner, string repo); } } From ed85234ce208ad89b2c5539b24b9237dc6fa1c44 Mon Sep 17 00:00:00 2001 From: Jason Kanaris Date: Tue, 15 Jul 2014 23:41:23 -0400 Subject: [PATCH 12/35] Added moar methods to teams client In both the ObservableTeamsClient and TeamsClient, added: - AddRepository - RemoveRepository - IsRepositoryManagedByTeam --- .../Clients/ObservableTeamsClient.cs | 46 ++++++++++ Octokit/Clients/TeamsClient.cs | 87 +++++++++++++++++++ 2 files changed, 133 insertions(+) diff --git a/Octokit.Reactive/Clients/ObservableTeamsClient.cs b/Octokit.Reactive/Clients/ObservableTeamsClient.cs index 12f81b9e..bd49e541 100644 --- a/Octokit.Reactive/Clients/ObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/ObservableTeamsClient.cs @@ -143,5 +143,51 @@ namespace Octokit.Reactive { return _connection.GetAndFlattenAllPages(ApiUrls.TeamRepositories(id)); } + + /// + /// Adds a to a . + /// + /// The team identifier. + /// Org to associate the repo with. + /// Name of the repo. + /// Thrown if you attempt to add a repository to a team that is not owned by the organization. + /// + /// See the API documentation for more information. + /// + /// if the repository was added to the team; otherwise. + public IObservable AddRepository(int id, string org, string repo) + { + return _client.AddRepository(id, org, repo).ToObservable(); + } + + /// + /// Removes a from a . + /// + /// The team identifier. + /// Owner of the org the team is associated with. + /// Name of the repo. + /// + /// See the API documentation for more information. + /// + /// if the repository was removed from the team; otherwise. + public IObservable RemoveRepository(int id, string owner, string repo) + { + return _client.RemoveRepository(id, owner, repo).ToObservable(); + } + + /// + /// Gets whether or not the given repository is managed by the given team. + /// + /// The team identifier + /// Owner of the org the team is associated with. + /// Name of the repo. + /// + /// See the API documentation for more information. + /// + /// if the repository is managed by the given team; otherwise. + public IObservable IsRepositoryManagedByTeam(int id, string owner, string repo) + { + return _client.IsRepositoryManagedByTeam(id, owner, repo).ToObservable(); + } } } diff --git a/Octokit/Clients/TeamsClient.cs b/Octokit/Clients/TeamsClient.cs index 393cfa4c..de149530 100644 --- a/Octokit/Clients/TeamsClient.cs +++ b/Octokit/Clients/TeamsClient.cs @@ -195,5 +195,92 @@ namespace Octokit return ApiConnection.GetAll(endpoint); } + + /// + /// Adds a to a . + /// + /// The team identifier. + /// Org to associate the repo with. + /// Name of the repo. + /// Thrown if you attempt to add a repository to a team that is not owned by the organization. + /// + /// See the API documentation for more information. + /// + /// if the repository was added to the team; otherwise. + public async Task AddRepository(int id, string org, string repo) + { + Ensure.ArgumentNotNullOrEmptyString(org, "org"); + Ensure.ArgumentNotNullOrEmptyString(repo, "repo"); + + var endpoint = ApiUrls.TeamRepository(id, org, repo); + + try + { + var httpStatusCode = await ApiConnection.Connection.Put(endpoint); + + return httpStatusCode == System.Net.HttpStatusCode.NoContent; + } + catch (NotFoundException) + { + return false; + } + } + + /// + /// Removes a from a . + /// + /// The team identifier. + /// Owner of the org the team is associated with. + /// Name of the repo. + /// + /// See the API documentation for more information. + /// + /// if the repository was removed from the team; otherwise. + public async Task RemoveRepository(int id, string owner, string repo) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(repo, "repo"); + + var endpoint = ApiUrls.TeamRepository(id, owner, repo); + + try + { + var httpStatusCode = await ApiConnection.Connection.Delete(endpoint); + + return httpStatusCode == System.Net.HttpStatusCode.NoContent; + } + catch (NotFoundException) + { + return false; + } + } + + /// + /// Gets whether or not the given repository is managed by the given team. + /// + /// The team identifier + /// Owner of the org the team is associated with. + /// Name of the repo. + /// + /// See the API documentation for more information. + /// + /// if the repository is managed by the given team; otherwise. + public async Task IsRepositoryManagedByTeam(int id, string owner, string repo) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(repo, "repo"); + + var endpoint = ApiUrls.TeamRepository(id, owner, repo); + + try + { + var response = await ApiConnection.Connection.GetResponse(endpoint); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + catch (NotFoundException) + { + return false; + } + } } } From f2a8128a303b06940952ff015ad1e01f8fbd8564 Mon Sep 17 00:00:00 2001 From: Jason Kanaris Date: Tue, 15 Jul 2014 23:50:14 -0400 Subject: [PATCH 13/35] Added some unit tests for teams client Added tests to ensure non null or empty arguments for the AddRepository, RemoveRepository and IsRepositoryManagedByTeam methods in the teams client. Also included todo's for adding tests to check if methods request the correct url and also return correct results. --- Octokit.Tests/Clients/TeamsClientTests.cs | 66 +++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/Octokit.Tests/Clients/TeamsClientTests.cs b/Octokit.Tests/Clients/TeamsClientTests.cs index f1902c3a..bd84eb4a 100644 --- a/Octokit.Tests/Clients/TeamsClientTests.cs +++ b/Octokit.Tests/Clients/TeamsClientTests.cs @@ -208,5 +208,71 @@ namespace Octokit.Tests.Clients connection.Received().GetAll(Arg.Is(u => u.ToString() == "teams/1/repos")); } } + + public class TheAddRepositoryMethod + { +#warning TODO: implement RequestsTheCorrectUrl test for TheAddRepositoryMethod + +#warning TODO: implement ReturnsCorrectResultBasedOnStatus test for TheAddRepositoryMethod + + [Fact] + public void EnsuresNonNullOrEmptyArguments() + { + var connection = Substitute.For(); + var client = new TeamsClient(connection); + + // Check org arguments. + AssertEx.Throws(() => client.AddRepository(1, null, "repoName")); + AssertEx.Throws(() => client.AddRepository(1, "", "repoName")); + + // Check repo arguments. + AssertEx.Throws(() => client.AddRepository(1, "orgName", null)); + AssertEx.Throws(() => client.AddRepository(1, "orgName", "")); + } + } + + public class TheRemoveRepositoryMethod + { +#warning TODO: implement RequestsTheCorrectUrl test for TheRemoveRepositoryMethod + +#warning TODO: implement ReturnsCorrectResultBasedOnStatus test for TheRemoveRepositoryMethod + + [Fact] + public void EnsuresNonNullOrEmptyArguments() + { + var connection = Substitute.For(); + var client = new TeamsClient(connection); + + // Check owner arguments. + AssertEx.Throws(() => client.RemoveRepository(1, null, "repoName")); + AssertEx.Throws(() => client.RemoveRepository(1, "", "repoName")); + + // Check repo arguments. + AssertEx.Throws(() => client.RemoveRepository(1, "ownerName", null)); + AssertEx.Throws(() => client.RemoveRepository(1, "ownerName", "")); + } + } + + public class TheIsRepositoryManagedByTeamMethod + { +#warning TODO: implement RequestsTheCorrectUrl test for TheIsRepositoryManagedByTeamMethod + +#warning TODO: implement ReturnsCorrectResultBasedOnStatus test for TheIsRepositoryManagedByTeamMethod + + [Fact] + public void EnsuresNonNullOrEmptyArguments() + { + var connection = Substitute.For(); + var client = new TeamsClient(connection); + + // Check owner arguments. + AssertEx.Throws(() => client.IsRepositoryManagedByTeam(1, null, "repoName")); + AssertEx.Throws(() => client.IsRepositoryManagedByTeam(1, "", "repoName")); + + // Check repo arguments. + AssertEx.Throws(() => client.IsRepositoryManagedByTeam(1, "ownerName", null)); + AssertEx.Throws(() => client.IsRepositoryManagedByTeam(1, "ownerName", "")); + } + } } } From 9eeef03abac2169d3f5dc2a05be2dc0046853345 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Fri, 8 May 2015 17:35:55 +0930 Subject: [PATCH 14/35] updated impacted tests --- Octokit.Tests/Clients/TeamsClientTests.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Octokit.Tests/Clients/TeamsClientTests.cs b/Octokit.Tests/Clients/TeamsClientTests.cs index 960b182b..0f6909df 100644 --- a/Octokit.Tests/Clients/TeamsClientTests.cs +++ b/Octokit.Tests/Clients/TeamsClientTests.cs @@ -145,7 +145,7 @@ namespace Octokit.Tests.Clients client.AddMember(1, "user"); - connection.Received().Put(Arg.Is(u => u.ToString() == "teams/1/memberships/user")); + connection.Connection.Received().Put(Arg.Is(u => u.ToString() == "teams/1/memberships/user")); } [Fact] @@ -189,7 +189,7 @@ namespace Octokit.Tests.Clients var client = new TeamsClient(connection); client.RemoveMember(1, "user"); - connection.Received().Delete(Arg.Is(u => u.ToString() == "teams/1/memberships/user")); + connection.Connection.Received().Delete(Arg.Is(u => u.ToString() == "teams/1/memberships/user")); } [Fact] @@ -230,7 +230,7 @@ namespace Octokit.Tests.Clients var client = new TeamsClient(connection); client.RemoveRepository(1, "org", "repo"); - connection.Received().Delete(Arg.Is(u => u.ToString() == "teams/1/repos/org/repo")); + connection.Connection.Received().Delete(Arg.Is(u => u.ToString() == "teams/1/repos/org/repo")); } } @@ -259,7 +259,7 @@ namespace Octokit.Tests.Clients var client = new TeamsClient(connection); client.AddRepository(1, "org", "repo"); - connection.Received().Put(Arg.Is(u => u.ToString() == "teams/1/repos/org/repo")); + connection.Connection.Received().Put(Arg.Is(u => u.ToString() == "teams/1/repos/org/repo")); } [Fact] From b969fa1e04edf71359da89303ec7a621cc74ac55 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Fri, 8 May 2015 17:42:02 +0930 Subject: [PATCH 15/35] cleanup due to GetAll* convention tests --- Octokit.Tests/Clients/TeamsClientTests.cs | 4 ++-- Octokit/Clients/ITeamsClient.cs | 10 ---------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/Octokit.Tests/Clients/TeamsClientTests.cs b/Octokit.Tests/Clients/TeamsClientTests.cs index 0f6909df..65b70467 100644 --- a/Octokit.Tests/Clients/TeamsClientTests.cs +++ b/Octokit.Tests/Clients/TeamsClientTests.cs @@ -204,7 +204,7 @@ namespace Octokit.Tests.Clients } - public class TheGetRepositoriesMethod + public class TheGetAllRepositoriesMethod { [Fact] public void RequestsTheCorrectUrl() @@ -215,7 +215,7 @@ namespace Octokit.Tests.Clients connection.Received().GetAll(Arg.Is(u => u.ToString() == "teams/1/repos")); - client.GetRepositories(1); + client.GetAllRepositories(1); connection.Received().GetAll(Arg.Is(u => u.ToString() == "teams/1/repos")); } diff --git a/Octokit/Clients/ITeamsClient.cs b/Octokit/Clients/ITeamsClient.cs index 5a889d0d..68717610 100644 --- a/Octokit/Clients/ITeamsClient.cs +++ b/Octokit/Clients/ITeamsClient.cs @@ -117,16 +117,6 @@ namespace Octokit /// Task RemoveRepository(int id, string organization, string repoName); - /// - /// Returns all (ies) associated with the given team. - /// - /// The team identifier - /// - /// See the API documentation for more information. - /// - /// A list of the team's (ies). - Task> GetRepositories(int id); - /// /// Gets whether or not the given repository is managed by the given team. /// From 6408b04c2cf898e4052ee4c58ba95fce80c4afd6 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Fri, 8 May 2015 17:44:17 +0930 Subject: [PATCH 16/35] obsolete reactive method --- Octokit.Reactive/Clients/IObservableTeamsClient.cs | 10 ---------- Octokit.Reactive/Clients/ObservableTeamsClient.cs | 13 ------------- 2 files changed, 23 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableTeamsClient.cs b/Octokit.Reactive/Clients/IObservableTeamsClient.cs index 937ef02c..3ccf4106 100644 --- a/Octokit.Reactive/Clients/IObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/IObservableTeamsClient.cs @@ -109,16 +109,6 @@ namespace Octokit.Reactive /// IObservable RemoveRepository(int id, string organization, string repoName); - /// - /// Returns all (ies) associated with the given team. - /// - /// The team identifier - /// - /// See the API documentation for more information. - /// - /// A list of the team's (ies). - IObservable GetRepositories(int id); - /// /// Adds a to a . /// diff --git a/Octokit.Reactive/Clients/ObservableTeamsClient.cs b/Octokit.Reactive/Clients/ObservableTeamsClient.cs index 161968a8..3ff5c68b 100644 --- a/Octokit.Reactive/Clients/ObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/ObservableTeamsClient.cs @@ -146,19 +146,6 @@ namespace Octokit.Reactive return _connection.GetAndFlattenAllPages(ApiUrls.TeamRepositories(id)); } - /// - /// Returns all (ies) associated with the given team. - /// - /// The team identifier - /// - /// See the API documentation for more information. - /// - /// A list of the team's (ies). - public IObservable GetRepositories(int id) - { - return _connection.GetAndFlattenAllPages(ApiUrls.TeamRepositories(id)); - } - /// /// Adds a to a . /// From 0d201e6f2294517a1427b11c7ee513ee910b0dce Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Fri, 22 May 2015 11:29:26 +0930 Subject: [PATCH 17/35] add GetMembership endpoint which supports new behaviour --- Octokit/Clients/ITeamsClient.cs | 4 +++- Octokit/Clients/TeamsClient.cs | 24 +++++++++++++++++++++-- Octokit/Models/Response/TeamMembership.cs | 9 +++++++++ Octokit/Octokit.csproj | 1 + 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 Octokit/Models/Response/TeamMembership.cs diff --git a/Octokit/Clients/ITeamsClient.cs b/Octokit/Clients/ITeamsClient.cs index 68717610..82e514b9 100644 --- a/Octokit/Clients/ITeamsClient.cs +++ b/Octokit/Clients/ITeamsClient.cs @@ -1,4 +1,5 @@ -#if NET_45 +using System; +#if NET_45 using System.Collections.Generic; #endif using System.Threading.Tasks; @@ -94,6 +95,7 @@ namespace Octokit /// The team to check. /// The user to check. /// if the user is a member of the team; otherwise. + [Obsolete("Use GetMembership(id, login) as this will report on pending requests")] Task IsMember(int id, string login); /// diff --git a/Octokit/Clients/TeamsClient.cs b/Octokit/Clients/TeamsClient.cs index eae73c33..dde8d1a0 100644 --- a/Octokit/Clients/TeamsClient.cs +++ b/Octokit/Clients/TeamsClient.cs @@ -1,8 +1,10 @@ -#if NET_45 + +using System; +#if NET_45 using System.Collections.Generic; #endif using System.Threading.Tasks; -using System.Diagnostics.CodeAnalysis; +using Octokit.Models.Response; namespace Octokit { @@ -67,6 +69,23 @@ namespace Octokit return ApiConnection.GetAll(endpoint); } + /// + /// Returns all members of the given team. + /// + /// The team identifier + /// The username to query + /// + /// https://developer.github.com/v3/orgs/teams/#list-team-members + /// + /// A list of the team's member s. + public Task GetMembership(int id, string login) + { + var endpoint = ApiUrls.TeamMember(id, login); + + return ApiConnection.Get(endpoint); + } + + /// /// Returns newly created for the current org. /// @@ -168,6 +187,7 @@ namespace Octokit /// The team to check. /// The user to check. /// if the user is a member of the team; otherwise. + [Obsolete("Use GetMembership(id, login) as this will report on pending requests")] public async Task IsMember(int id, string login) { Ensure.ArgumentNotNullOrEmptyString(login, "login"); diff --git a/Octokit/Models/Response/TeamMembership.cs b/Octokit/Models/Response/TeamMembership.cs new file mode 100644 index 00000000..902b293d --- /dev/null +++ b/Octokit/Models/Response/TeamMembership.cs @@ -0,0 +1,9 @@ +namespace Octokit.Models.Response +{ + public enum TeamMembership + { + NotFound = 0, + Pending = 1, + Active = 2 + } +} diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index a3cac0ad..c880cc1a 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -222,6 +222,7 @@ + From b070e72d0a6cc696f820f3da1094f62348892def Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Fri, 22 May 2015 11:32:52 +0930 Subject: [PATCH 18/35] actually implement the right logic --- Octokit/Clients/TeamsClient.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Octokit/Clients/TeamsClient.cs b/Octokit/Clients/TeamsClient.cs index dde8d1a0..6b7a27c0 100644 --- a/Octokit/Clients/TeamsClient.cs +++ b/Octokit/Clients/TeamsClient.cs @@ -1,5 +1,5 @@ - -using System; +using System; +using System.Net; #if NET_45 using System.Collections.Generic; #endif @@ -8,7 +8,6 @@ using Octokit.Models.Response; namespace Octokit { - /// /// A client for GitHub's Organization Teams API. /// @@ -78,11 +77,20 @@ namespace Octokit /// https://developer.github.com/v3/orgs/teams/#list-team-members /// /// A list of the team's member s. - public Task GetMembership(int id, string login) + public async Task GetMembership(int id, string login) { var endpoint = ApiUrls.TeamMember(id, login); - return ApiConnection.Get(endpoint); + var response = await ApiConnection.Connection.Get>(endpoint, null, null); + + if (response.HttpResponse.StatusCode == HttpStatusCode.NotFound) + { + return TeamMembership.NotFound; + } + + return response.Body["state"] == "active" + ? TeamMembership.Active + : TeamMembership.Pending; } From f2e52aaad297ee1725dbb878e2e0b686d90e1049 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Fri, 22 May 2015 11:43:14 +0930 Subject: [PATCH 19/35] added new file to other projects --- Octokit/Clients/TeamsClient.cs | 1 - Octokit/Octokit-Mono.csproj | 1 + Octokit/Octokit-MonoAndroid.csproj | 1 + Octokit/Octokit-Monotouch.csproj | 1 + Octokit/Octokit-Portable.csproj | 1 + Octokit/Octokit-netcore45.csproj | 3 ++- 6 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Octokit/Clients/TeamsClient.cs b/Octokit/Clients/TeamsClient.cs index 6b7a27c0..80fd9a40 100644 --- a/Octokit/Clients/TeamsClient.cs +++ b/Octokit/Clients/TeamsClient.cs @@ -93,7 +93,6 @@ namespace Octokit : TeamMembership.Pending; } - /// /// Returns newly created for the current org. /// diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj index 4d049e80..99360bc0 100644 --- a/Octokit/Octokit-Mono.csproj +++ b/Octokit/Octokit-Mono.csproj @@ -393,6 +393,7 @@ + \ No newline at end of file diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj index 4a1ca1f5..40389d2f 100644 --- a/Octokit/Octokit-MonoAndroid.csproj +++ b/Octokit/Octokit-MonoAndroid.csproj @@ -409,6 +409,7 @@ + \ No newline at end of file diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj index d306f674..558570e9 100644 --- a/Octokit/Octokit-Monotouch.csproj +++ b/Octokit/Octokit-Monotouch.csproj @@ -402,6 +402,7 @@ + diff --git a/Octokit/Octokit-Portable.csproj b/Octokit/Octokit-Portable.csproj index 30be17bc..32fcf524 100644 --- a/Octokit/Octokit-Portable.csproj +++ b/Octokit/Octokit-Portable.csproj @@ -391,6 +391,7 @@ + diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj index 38e80b1a..b0896731 100644 --- a/Octokit/Octokit-netcore45.csproj +++ b/Octokit/Octokit-netcore45.csproj @@ -395,6 +395,7 @@ + @@ -410,4 +411,4 @@ --> - + \ No newline at end of file From 809ecc563064e7b37a4ab0da8ece92a2911e6fb0 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Fri, 22 May 2015 11:51:04 +0930 Subject: [PATCH 20/35] actually finish implementing the endpoint --- Octokit.Reactive/Clients/IObservableTeamsClient.cs | 11 +++++++++++ Octokit.Reactive/Clients/ObservableTeamsClient.cs | 13 +++++++++++++ Octokit/Clients/ITeamsClient.cs | 11 +++++++++++ Octokit/Clients/TeamsClient.cs | 13 +++++-------- Octokit/Models/Response/TeamMembership.cs | 2 +- 5 files changed, 41 insertions(+), 9 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableTeamsClient.cs b/Octokit.Reactive/Clients/IObservableTeamsClient.cs index 3ccf4106..f88a1b51 100644 --- a/Octokit.Reactive/Clients/IObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/IObservableTeamsClient.cs @@ -86,6 +86,7 @@ namespace Octokit.Reactive /// if the user was removed from the team; otherwise. IObservable RemoveMember(int id, string login); + /// /// Gets whether the user with the given /// is a member of the team with the given . @@ -93,8 +94,18 @@ namespace Octokit.Reactive /// The team to check. /// The user to check. /// if the user is a member of the team; otherwise. + [Obsolete("Use GetMembership(id, login) to detect pending memberships")] IObservable IsMember(int id, string login); + /// + /// Gets whether the user with the given + /// is a member of the team with the given . + /// + /// The team to check. + /// The user to check. + /// if the user is a member of the team; otherwise. + IObservable GetMembership(int id, string login); + /// /// Returns all team's repositories. /// diff --git a/Octokit.Reactive/Clients/ObservableTeamsClient.cs b/Octokit.Reactive/Clients/ObservableTeamsClient.cs index 3ff5c68b..8b98d7c8 100644 --- a/Octokit.Reactive/Clients/ObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/ObservableTeamsClient.cs @@ -131,11 +131,24 @@ namespace Octokit.Reactive /// The team to check. /// The user to check. /// if the user is a member of the team; otherwise. + [Obsolete("Use GetMembership(id, login) to detect pending memberships")] public IObservable IsMember(int id, string login) { return _client.IsMember(id, login).ToObservable(); } + /// + /// Gets whether the user with the given + /// is a member of the team with the given . + /// + /// The team to check. + /// The user to check. + /// if the user is a member of the team; otherwise. + public IObservable GetMembership(int id, string login) + { + return _client.GetMembership(id, login).ToObservable(); + } + /// /// Returns all team's repositories. /// diff --git a/Octokit/Clients/ITeamsClient.cs b/Octokit/Clients/ITeamsClient.cs index 82e514b9..9f3e563e 100644 --- a/Octokit/Clients/ITeamsClient.cs +++ b/Octokit/Clients/ITeamsClient.cs @@ -98,6 +98,17 @@ namespace Octokit [Obsolete("Use GetMembership(id, login) as this will report on pending requests")] Task IsMember(int id, string login); + + /// + /// Gets whether the user with the given + /// is a member of the team with the given . + /// + /// The team to check. + /// The user to check. + /// if the user is a member of the team; otherwise. + Task GetMembership(int id, string login); + + /// /// Returns all team's repositories. /// diff --git a/Octokit/Clients/TeamsClient.cs b/Octokit/Clients/TeamsClient.cs index 80fd9a40..2bab8939 100644 --- a/Octokit/Clients/TeamsClient.cs +++ b/Octokit/Clients/TeamsClient.cs @@ -4,7 +4,6 @@ using System.Net; using System.Collections.Generic; #endif using System.Threading.Tasks; -using Octokit.Models.Response; namespace Octokit { @@ -69,14 +68,12 @@ namespace Octokit } /// - /// Returns all members of the given team. + /// Gets whether the user with the given + /// is a member of the team with the given . /// - /// The team identifier - /// The username to query - /// - /// https://developer.github.com/v3/orgs/teams/#list-team-members - /// - /// A list of the team's member s. + /// The team to check. + /// The user to check. + /// if the user is a member of the team; otherwise. public async Task GetMembership(int id, string login) { var endpoint = ApiUrls.TeamMember(id, login); diff --git a/Octokit/Models/Response/TeamMembership.cs b/Octokit/Models/Response/TeamMembership.cs index 902b293d..2dba0d8b 100644 --- a/Octokit/Models/Response/TeamMembership.cs +++ b/Octokit/Models/Response/TeamMembership.cs @@ -1,4 +1,4 @@ -namespace Octokit.Models.Response +namespace Octokit { public enum TeamMembership { From 38849e8798087cd7dbebd449bd1d5fb6a084dbb6 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Fri, 22 May 2015 13:37:06 +0930 Subject: [PATCH 21/35] update tests to use new endpoint --- .../Clients/TeamsClientTests.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/TeamsClientTests.cs b/Octokit.Tests.Integration/Clients/TeamsClientTests.cs index a7377abb..9b7efa11 100644 --- a/Octokit.Tests.Integration/Clients/TeamsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/TeamsClientTests.cs @@ -46,11 +46,11 @@ public class TeamsClientTests } } - public class TheIsMemberMethod + public class TheGetMembershipMethod { readonly Team team; - public TheIsMemberMethod() + public TheGetMembershipMethod() { var github = Helper.GetAuthenticatedClient(); @@ -62,7 +62,7 @@ public class TeamsClientTests { var github = Helper.GetAnonymousClient(); - var e = await Assert.ThrowsAsync(() => github.Organization.Team.IsMember(team.Id, Helper.UserName)); + var e = await Assert.ThrowsAsync(() => github.Organization.Team.GetMembership(team.Id, Helper.UserName)); Assert.Equal(HttpStatusCode.Unauthorized, e.StatusCode); } @@ -81,9 +81,9 @@ public class TeamsClientTests { var github = Helper.GetAuthenticatedClient(); - var isMember = await github.Organization.Team.IsMember(team.Id, Helper.UserName); + var membership = await github.Organization.Team.GetMembership(team.Id, Helper.UserName); - Assert.True(isMember); + Assert.Equal(TeamMembership.Active, membership); } [OrganizationTest] @@ -91,9 +91,9 @@ public class TeamsClientTests { var github = Helper.GetAuthenticatedClient(); - var isMember = await github.Organization.Team.IsMember(team.Id, "foo"); + var membership = await github.Organization.Team.GetMembership(team.Id, "foo"); - Assert.False(isMember); + Assert.Equal(TeamMembership.NotFound, membership); } } From 747a69f596cffb0f382c2850cb44dae940f3b4c4 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Fri, 22 May 2015 13:43:33 +0930 Subject: [PATCH 22/35] rewrote the thing again --- Octokit/Clients/TeamsClient.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Octokit/Clients/TeamsClient.cs b/Octokit/Clients/TeamsClient.cs index 2bab8939..a8d41818 100644 --- a/Octokit/Clients/TeamsClient.cs +++ b/Octokit/Clients/TeamsClient.cs @@ -78,14 +78,18 @@ namespace Octokit { var endpoint = ApiUrls.TeamMember(id, login); - var response = await ApiConnection.Connection.Get>(endpoint, null, null); + Dictionary response; - if (response.HttpResponse.StatusCode == HttpStatusCode.NotFound) + try + { + response = await ApiConnection.Get>(endpoint); + } + catch (NotFoundException) { return TeamMembership.NotFound; } - return response.Body["state"] == "active" + return response["state"] == "active" ? TeamMembership.Active : TeamMembership.Pending; } From 6055ad7ac93c76fe78ad9ca5c3b85ce5fcf5abd3 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Fri, 22 May 2015 13:52:46 +0930 Subject: [PATCH 23/35] not sure why this test is being reverted --- Octokit.Tests.Integration/Clients/TeamsClientTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit.Tests.Integration/Clients/TeamsClientTests.cs b/Octokit.Tests.Integration/Clients/TeamsClientTests.cs index 9b7efa11..53c68fd4 100644 --- a/Octokit.Tests.Integration/Clients/TeamsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/TeamsClientTests.cs @@ -67,7 +67,7 @@ public class TeamsClientTests Assert.Equal(HttpStatusCode.Unauthorized, e.StatusCode); } - [OrganizationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for the resolution to this failing test")] + [OrganizationTest] public async Task FailsWhenAuthenticatedWithBadCredentials() { var github = Helper.GetBadCredentialsClient(); From 2a17c7d991160346c00c58485adacba48c6397fb Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Fri, 22 May 2015 13:53:02 +0930 Subject: [PATCH 24/35] ignoring this unloved test --- Octokit.Tests.Integration/Clients/TeamsClientTests.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/TeamsClientTests.cs b/Octokit.Tests.Integration/Clients/TeamsClientTests.cs index 53c68fd4..4a02c0d2 100644 --- a/Octokit.Tests.Integration/Clients/TeamsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/TeamsClientTests.cs @@ -57,16 +57,6 @@ public class TeamsClientTests team = github.Organization.Team.GetAll(Helper.Organization).Result.First(); } - [OrganizationTest(Skip="actually returning the membership information! Maybe because it's a public organization?")] - public async Task FailsWhenNotAuthenticated() - { - var github = Helper.GetAnonymousClient(); - - var e = await Assert.ThrowsAsync(() => github.Organization.Team.GetMembership(team.Id, Helper.UserName)); - - Assert.Equal(HttpStatusCode.Unauthorized, e.StatusCode); - } - [OrganizationTest] public async Task FailsWhenAuthenticatedWithBadCredentials() { From 27d9a40090637557e663d7846fcb9062193da76b Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Fri, 22 May 2015 14:15:40 +0930 Subject: [PATCH 25/35] introduce AddMembership endpoint with new behaviour --- .../Clients/IObservableTeamsClient.cs | 13 ++++++ .../Clients/ObservableTeamsClient.cs | 16 +++++++ Octokit/Clients/ITeamsClient.cs | 13 ++++++ Octokit/Clients/TeamsClient.cs | 45 ++++++++++++++++--- 4 files changed, 81 insertions(+), 6 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableTeamsClient.cs b/Octokit.Reactive/Clients/IObservableTeamsClient.cs index f88a1b51..7fb180f9 100644 --- a/Octokit.Reactive/Clients/IObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/IObservableTeamsClient.cs @@ -73,8 +73,21 @@ namespace Octokit.Reactive /// The user to add to the team. /// Thrown if you attempt to add an organization to a team. /// if the user was added to the team; otherwise. + [Obsolete("Use AddMembership(id, login) to track pending requests")] IObservable AddMember(int id, string login); + /// + /// Adds a to a . + /// + /// + /// See the API documentation for more information. + /// + /// The team identifier. + /// The user to add to the team. + /// Thrown if you attempt to add an organization to a team. + /// if the user was added to the team; otherwise. + IObservable AddMembership(int id, string login); + /// /// Removes a from a . /// diff --git a/Octokit.Reactive/Clients/ObservableTeamsClient.cs b/Octokit.Reactive/Clients/ObservableTeamsClient.cs index 8b98d7c8..5f099a28 100644 --- a/Octokit.Reactive/Clients/ObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/ObservableTeamsClient.cs @@ -105,11 +105,27 @@ namespace Octokit.Reactive /// The user to add to the team. /// Thrown if you attempt to add an organization to a team. /// if the user was added to the team; otherwise. + [Obsolete("Use AddMembership(int, login) to get pending invitations")] public IObservable AddMember(int id, string login) { return _client.AddMember(id, login).ToObservable(); } + /// + /// Adds a to a . + /// + /// + /// See the API documentation for more information. + /// + /// The team identifier. + /// The user to add to the team. + /// Thrown if you attempt to add an organization to a team. + /// if the user was added to the team; otherwise. + public IObservable AddMembership(int id, string login) + { + return _client.AddMembership(id, login).ToObservable(); + } + /// /// Removes a from a . /// diff --git a/Octokit/Clients/ITeamsClient.cs b/Octokit/Clients/ITeamsClient.cs index 9f3e563e..66c1d2ec 100644 --- a/Octokit/Clients/ITeamsClient.cs +++ b/Octokit/Clients/ITeamsClient.cs @@ -75,8 +75,21 @@ namespace Octokit /// The user to add to the team. /// Thrown if you attempt to add an organization to a team. /// if the user was added to the team; otherwise. + [Obsolete("Use AddMembership(id, login) to track pending requests")] Task AddMember(int id, string login); + /// + /// Adds a to a . + /// + /// + /// See the API documentation for more information. + /// + /// The team identifier. + /// The user to add to the team. + /// Thrown if you attempt to add an organization to a team. + /// if the user was added to the team; otherwise. + Task AddMembership(int id, string login); + /// /// Removes a from a . /// diff --git a/Octokit/Clients/TeamsClient.cs b/Octokit/Clients/TeamsClient.cs index a8d41818..0cf075bd 100644 --- a/Octokit/Clients/TeamsClient.cs +++ b/Octokit/Clients/TeamsClient.cs @@ -143,6 +143,7 @@ namespace Octokit /// The user to add to the team. /// Thrown if you attempt to add an organization to a team. /// if the user was added to the team; otherwise. + [Obsolete("Use AddTeamMember(id, login) to track pending requests")] public async Task AddMember(int id, string login) { Ensure.ArgumentNotNullOrEmptyString(login, "login"); @@ -153,7 +154,7 @@ namespace Octokit { var httpStatusCode = await ApiConnection.Connection.Put(endpoint); - return httpStatusCode == System.Net.HttpStatusCode.NoContent; + return httpStatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) { @@ -161,6 +162,38 @@ namespace Octokit } } + /// + /// Adds a to a . + /// + /// + /// See the API documentation for more information. + /// + /// The team identifier. + /// The user to add to the team. + /// Thrown if you attempt to add an organization to a team. + /// if the user was added to the team; otherwise. + public async Task AddMembership(int id, string login) + { + Ensure.ArgumentNotNullOrEmptyString(login, "login"); + + var endpoint = ApiUrls.TeamMember(id, login); + + Dictionary response; + + try + { + response = await ApiConnection.Put>(endpoint, null); + } + catch (NotFoundException) + { + return TeamMembership.NotFound; + } + + return response["state"] == "active" + ? TeamMembership.Active + : TeamMembership.Pending; + } + /// /// Removes a from a . /// @@ -180,7 +213,7 @@ namespace Octokit { var httpStatusCode = await ApiConnection.Connection.Delete(endpoint); - return httpStatusCode == System.Net.HttpStatusCode.NoContent; + return httpStatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) { @@ -205,7 +238,7 @@ namespace Octokit try { var response = await ApiConnection.Connection.GetResponse(endpoint); - return response.HttpResponse.StatusCode == System.Net.HttpStatusCode.NoContent; + return response.HttpResponse.StatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) { @@ -255,7 +288,7 @@ namespace Octokit try { var httpStatusCode = await ApiConnection.Connection.Put(endpoint); - return httpStatusCode == System.Net.HttpStatusCode.NoContent; + return httpStatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) { @@ -279,7 +312,7 @@ namespace Octokit { var httpStatusCode = await ApiConnection.Connection.Delete(endpoint); - return httpStatusCode == System.Net.HttpStatusCode.NoContent; + return httpStatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) { @@ -307,7 +340,7 @@ namespace Octokit try { var response = await ApiConnection.Connection.GetResponse(endpoint); - return response.HttpResponse.StatusCode == System.Net.HttpStatusCode.NoContent; + return response.HttpResponse.StatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) { From b9da7291775678d7407812fdaa9a445954e1d953 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Fri, 22 May 2015 14:15:55 +0930 Subject: [PATCH 26/35] updated docs --- Octokit.Reactive/Clients/IObservableTeamsClient.cs | 4 ++-- Octokit.Reactive/Clients/ObservableTeamsClient.cs | 4 ++-- Octokit/Clients/ITeamsClient.cs | 6 ++---- Octokit/Clients/TeamsClient.cs | 4 ++-- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableTeamsClient.cs b/Octokit.Reactive/Clients/IObservableTeamsClient.cs index 7fb180f9..f4a72a62 100644 --- a/Octokit.Reactive/Clients/IObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/IObservableTeamsClient.cs @@ -85,7 +85,7 @@ namespace Octokit.Reactive /// The team identifier. /// The user to add to the team. /// Thrown if you attempt to add an organization to a team. - /// if the user was added to the team; otherwise. + /// A result indicating the membership status IObservable AddMembership(int id, string login); /// @@ -116,7 +116,7 @@ namespace Octokit.Reactive /// /// The team to check. /// The user to check. - /// if the user is a member of the team; otherwise. + /// A result indicating the membership status IObservable GetMembership(int id, string login); /// diff --git a/Octokit.Reactive/Clients/ObservableTeamsClient.cs b/Octokit.Reactive/Clients/ObservableTeamsClient.cs index 5f099a28..772166c6 100644 --- a/Octokit.Reactive/Clients/ObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/ObservableTeamsClient.cs @@ -120,7 +120,7 @@ namespace Octokit.Reactive /// The team identifier. /// The user to add to the team. /// Thrown if you attempt to add an organization to a team. - /// if the user was added to the team; otherwise. + /// A result indicating the membership status public IObservable AddMembership(int id, string login) { return _client.AddMembership(id, login).ToObservable(); @@ -159,7 +159,7 @@ namespace Octokit.Reactive /// /// The team to check. /// The user to check. - /// if the user is a member of the team; otherwise. + /// A result indicating the membership status public IObservable GetMembership(int id, string login) { return _client.GetMembership(id, login).ToObservable(); diff --git a/Octokit/Clients/ITeamsClient.cs b/Octokit/Clients/ITeamsClient.cs index 66c1d2ec..69dba2c1 100644 --- a/Octokit/Clients/ITeamsClient.cs +++ b/Octokit/Clients/ITeamsClient.cs @@ -87,7 +87,7 @@ namespace Octokit /// The team identifier. /// The user to add to the team. /// Thrown if you attempt to add an organization to a team. - /// if the user was added to the team; otherwise. + /// A result indicating the membership status Task AddMembership(int id, string login); /// @@ -111,17 +111,15 @@ namespace Octokit [Obsolete("Use GetMembership(id, login) as this will report on pending requests")] Task IsMember(int id, string login); - /// /// Gets whether the user with the given /// is a member of the team with the given . /// /// The team to check. /// The user to check. - /// if the user is a member of the team; otherwise. + /// A result indicating the membership status Task GetMembership(int id, string login); - /// /// Returns all team's repositories. /// diff --git a/Octokit/Clients/TeamsClient.cs b/Octokit/Clients/TeamsClient.cs index 0cf075bd..6b977e7a 100644 --- a/Octokit/Clients/TeamsClient.cs +++ b/Octokit/Clients/TeamsClient.cs @@ -73,7 +73,7 @@ namespace Octokit /// /// The team to check. /// The user to check. - /// if the user is a member of the team; otherwise. + /// A result indicating the membership status public async Task GetMembership(int id, string login) { var endpoint = ApiUrls.TeamMember(id, login); @@ -171,7 +171,7 @@ namespace Octokit /// The team identifier. /// The user to add to the team. /// Thrown if you attempt to add an organization to a team. - /// if the user was added to the team; otherwise. + /// A result indicating the membership status public async Task AddMembership(int id, string login) { Ensure.ArgumentNotNullOrEmptyString(login, "login"); From 44909681261fedb052b501af56ba0decaeb39ddf Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Fri, 22 May 2015 14:29:11 +0930 Subject: [PATCH 27/35] removed new, but obsolete code --- .../Clients/IObservableTeamsClient.cs | 16 +--------- .../Clients/ObservableTeamsClient.cs | 20 ++---------- Octokit.Tests/Clients/TeamsClientTests.cs | 12 +++---- Octokit/Clients/ITeamsClient.cs | 15 +-------- Octokit/Clients/TeamsClient.cs | 31 +------------------ 5 files changed, 11 insertions(+), 83 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableTeamsClient.cs b/Octokit.Reactive/Clients/IObservableTeamsClient.cs index f4a72a62..101946a9 100644 --- a/Octokit.Reactive/Clients/IObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/IObservableTeamsClient.cs @@ -63,19 +63,6 @@ namespace Octokit.Reactive /// IObservable Delete(int id); - /// - /// Adds a to a . - /// - /// - /// See the API documentation for more information. - /// - /// The team identifier. - /// The user to add to the team. - /// Thrown if you attempt to add an organization to a team. - /// if the user was added to the team; otherwise. - [Obsolete("Use AddMembership(id, login) to track pending requests")] - IObservable AddMember(int id, string login); - /// /// Adds a to a . /// @@ -97,8 +84,7 @@ namespace Octokit.Reactive /// The team identifier. /// The user to remove from the team. /// if the user was removed from the team; otherwise. - IObservable RemoveMember(int id, string login); - + IObservable RemoveMembership(int id, string login); /// /// Gets whether the user with the given diff --git a/Octokit.Reactive/Clients/ObservableTeamsClient.cs b/Octokit.Reactive/Clients/ObservableTeamsClient.cs index 772166c6..a3e9af4f 100644 --- a/Octokit.Reactive/Clients/ObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/ObservableTeamsClient.cs @@ -95,22 +95,6 @@ namespace Octokit.Reactive return _client.Delete(id).ToObservable(); } - /// - /// Adds a to a . - /// - /// - /// See the API documentation for more information. - /// - /// The team identifier. - /// The user to add to the team. - /// Thrown if you attempt to add an organization to a team. - /// if the user was added to the team; otherwise. - [Obsolete("Use AddMembership(int, login) to get pending invitations")] - public IObservable AddMember(int id, string login) - { - return _client.AddMember(id, login).ToObservable(); - } - /// /// Adds a to a . /// @@ -135,9 +119,9 @@ namespace Octokit.Reactive /// The team identifier. /// The user to remove from the team. /// if the user was removed from the team; otherwise. - public IObservable RemoveMember(int id, string login) + public IObservable RemoveMembership(int id, string login) { - return _client.RemoveMember(id, login).ToObservable(); + return _client.RemoveMembership(id, login).ToObservable(); } /// diff --git a/Octokit.Tests/Clients/TeamsClientTests.cs b/Octokit.Tests/Clients/TeamsClientTests.cs index a06b3afc..16da07ff 100644 --- a/Octokit.Tests/Clients/TeamsClientTests.cs +++ b/Octokit.Tests/Clients/TeamsClientTests.cs @@ -143,7 +143,7 @@ namespace Octokit.Tests.Clients var connection = Substitute.For(); var client = new TeamsClient(connection); - client.AddMember(1, "user"); + client.AddMembership(1, "user"); connection.Connection.Received().Put(Arg.Is(u => u.ToString() == "teams/1/memberships/user")); } @@ -154,8 +154,8 @@ namespace Octokit.Tests.Clients var connection = Substitute.For(); var client = new TeamsClient(connection); - await Assert.ThrowsAsync(() => client.AddMember(1, null)); - await Assert.ThrowsAsync(() => client.AddMember(1, "")); + await Assert.ThrowsAsync(() => client.AddMembership(1, null)); + await Assert.ThrowsAsync(() => client.AddMembership(1, "")); } } @@ -187,7 +187,7 @@ namespace Octokit.Tests.Clients { var connection = Substitute.For(); var client = new TeamsClient(connection); - client.RemoveMember(1, "user"); + client.RemoveMembership(1, "user"); connection.Connection.Received().Delete(Arg.Is(u => u.ToString() == "teams/1/memberships/user")); } @@ -198,8 +198,8 @@ namespace Octokit.Tests.Clients var connection = Substitute.For(); var client = new TeamsClient(connection); - await Assert.ThrowsAsync(() => client.RemoveMember(1, null)); - await Assert.ThrowsAsync(() => client.RemoveMember(1, "")); + await Assert.ThrowsAsync(() => client.RemoveMembership(1, null)); + await Assert.ThrowsAsync(() => client.RemoveMembership(1, "")); } } diff --git a/Octokit/Clients/ITeamsClient.cs b/Octokit/Clients/ITeamsClient.cs index 69dba2c1..7049c268 100644 --- a/Octokit/Clients/ITeamsClient.cs +++ b/Octokit/Clients/ITeamsClient.cs @@ -65,19 +65,6 @@ namespace Octokit /// Task Delete(int id); - /// - /// Adds a to a . - /// - /// - /// See the API documentation for more information. - /// - /// The team identifier. - /// The user to add to the team. - /// Thrown if you attempt to add an organization to a team. - /// if the user was added to the team; otherwise. - [Obsolete("Use AddMembership(id, login) to track pending requests")] - Task AddMember(int id, string login); - /// /// Adds a to a . /// @@ -99,7 +86,7 @@ namespace Octokit /// The team identifier. /// The user to remove from the team. /// if the user was removed from the team; otherwise. - Task RemoveMember(int id, string login); + Task RemoveMembership(int id, string login); /// /// Gets whether the user with the given diff --git a/Octokit/Clients/TeamsClient.cs b/Octokit/Clients/TeamsClient.cs index 6b977e7a..ad7d154f 100644 --- a/Octokit/Clients/TeamsClient.cs +++ b/Octokit/Clients/TeamsClient.cs @@ -133,35 +133,6 @@ namespace Octokit return ApiConnection.Delete(endpoint); } - /// - /// Adds a to a . - /// - /// - /// See the API documentation for more information. - /// - /// The team identifier. - /// The user to add to the team. - /// Thrown if you attempt to add an organization to a team. - /// if the user was added to the team; otherwise. - [Obsolete("Use AddTeamMember(id, login) to track pending requests")] - public async Task AddMember(int id, string login) - { - Ensure.ArgumentNotNullOrEmptyString(login, "login"); - - var endpoint = ApiUrls.TeamMember(id, login); - - try - { - var httpStatusCode = await ApiConnection.Connection.Put(endpoint); - - return httpStatusCode == HttpStatusCode.NoContent; - } - catch (NotFoundException) - { - return false; - } - } - /// /// Adds a to a . /// @@ -203,7 +174,7 @@ namespace Octokit /// The team identifier. /// The user to remove from the team. /// if the user was removed from the team; otherwise. - public async Task RemoveMember(int id, string login) + public async Task RemoveMembership(int id, string login) { Ensure.ArgumentNotNullOrEmptyString(login, "login"); From 2299a894fbb88d0f244efef273f4aa1c18af4e2f Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Fri, 22 May 2015 14:31:24 +0930 Subject: [PATCH 28/35] naming things --- Octokit.Tests/Clients/TeamsClientTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit.Tests/Clients/TeamsClientTests.cs b/Octokit.Tests/Clients/TeamsClientTests.cs index 16da07ff..fa09c856 100644 --- a/Octokit.Tests/Clients/TeamsClientTests.cs +++ b/Octokit.Tests/Clients/TeamsClientTests.cs @@ -135,7 +135,7 @@ namespace Octokit.Tests.Clients } } - public class TheAddMemberMethod + public class TheAddMembershipMethod { [Fact] public void RequestsTheCorrectUrl() From 609c44e9239e172c52d8a8b30dae4f2d8180fc02 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Fri, 22 May 2015 14:32:11 +0930 Subject: [PATCH 29/35] a bit more renaming --- Octokit.Tests/Clients/TeamsClientTests.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Octokit.Tests/Clients/TeamsClientTests.cs b/Octokit.Tests/Clients/TeamsClientTests.cs index fa09c856..c57cf966 100644 --- a/Octokit.Tests/Clients/TeamsClientTests.cs +++ b/Octokit.Tests/Clients/TeamsClientTests.cs @@ -159,7 +159,7 @@ namespace Octokit.Tests.Clients } } - public class TheIsMemberMethod + public class TheGetMembershipMethod { [Fact] public void EnsuresNonNullLogin() @@ -167,7 +167,7 @@ namespace Octokit.Tests.Clients var connection = Substitute.For(); var client = new TeamsClient(connection); - Assert.ThrowsAsync(() => client.IsMember(1, null)); + Assert.ThrowsAsync(() => client.GetMembership(1, null)); } [Fact] @@ -176,11 +176,11 @@ namespace Octokit.Tests.Clients var connection = Substitute.For(); var client = new TeamsClient(connection); - Assert.ThrowsAsync(() => client.IsMember(1, "")); + Assert.ThrowsAsync(() => client.GetMembership(1, "")); } } - public class TheRemoveMemberMethod + public class TheRRemoveMembershipMethod { [Fact] public void RequestsTheCorrectUrl() From dbd48d7a90891634a7b8b1a6359e755fc055899a Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Fri, 22 May 2015 14:44:25 +0930 Subject: [PATCH 30/35] added GetAllForCurrent to find teams for the current user --- Octokit.Reactive/Clients/IObservableTeamsClient.cs | 8 ++++++++ Octokit.Reactive/Clients/ObservableTeamsClient.cs | 10 ++++++++++ Octokit/Clients/ITeamsClient.cs | 7 +++++++ Octokit/Clients/TeamsClient.cs | 11 +++++++++++ Octokit/Helpers/ApiUrls.cs | 10 ++++++++++ 5 files changed, 46 insertions(+) diff --git a/Octokit.Reactive/Clients/IObservableTeamsClient.cs b/Octokit.Reactive/Clients/IObservableTeamsClient.cs index 101946a9..e6671028 100644 --- a/Octokit.Reactive/Clients/IObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/IObservableTeamsClient.cs @@ -31,6 +31,14 @@ namespace Octokit.Reactive /// A list of the orgs's teams s. IObservable GetAll(string org); + /// + /// Returns all s for the current user. + /// + /// Thrown when a general API error occurs. + /// A list of the user's s. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + IObservable GetAllForCurrent(); + /// /// Returns all members of the given team. /// diff --git a/Octokit.Reactive/Clients/ObservableTeamsClient.cs b/Octokit.Reactive/Clients/ObservableTeamsClient.cs index a3e9af4f..c4d44985 100644 --- a/Octokit.Reactive/Clients/ObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/ObservableTeamsClient.cs @@ -51,6 +51,16 @@ namespace Octokit.Reactive return _connection.GetAndFlattenAllPages(ApiUrls.OrganizationTeams(org)); } + /// + /// Returns all s for the current user. + /// + /// Thrown when a general API error occurs. + /// A list of the user's s. + public IObservable GetAllForCurrent() + { + return _connection.GetAndFlattenAllPages(ApiUrls.UserTeams()); + } + /// /// Returns all members of the given team. /// diff --git a/Octokit/Clients/ITeamsClient.cs b/Octokit/Clients/ITeamsClient.cs index 7049c268..191648ed 100644 --- a/Octokit/Clients/ITeamsClient.cs +++ b/Octokit/Clients/ITeamsClient.cs @@ -34,6 +34,13 @@ namespace Octokit /// A list of the orgs's teams s. Task> GetAll(string org); + /// + /// Returns all s for the current user. + /// + /// Thrown when a general API error occurs. + /// A list of the user's s. + Task> GetAllForCurrent(); + /// /// Returns all members of the given team. /// diff --git a/Octokit/Clients/TeamsClient.cs b/Octokit/Clients/TeamsClient.cs index ad7d154f..ea8ee208 100644 --- a/Octokit/Clients/TeamsClient.cs +++ b/Octokit/Clients/TeamsClient.cs @@ -52,6 +52,17 @@ namespace Octokit return ApiConnection.GetAll(endpoint); } + /// + /// Returns all s for the current user. + /// + /// Thrown when a general API error occurs. + /// A list of the user's s. + public Task> GetAllForCurrent() + { + var endpoint = ApiUrls.UserTeams(); + return ApiConnection.GetAll(endpoint); + } + /// /// Returns all members of the given team. /// diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 47e0f4a0..3bc5ec9e 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -1148,6 +1148,16 @@ namespace Octokit return "orgs/{0}/teams".FormatUri(organization); } + /// + /// Returns the to discover teams + /// for the current user + /// + /// + public static Uri UserTeams() + { + return "user/teams".FormatUri(); + } + /// /// Returns the for teams /// use for getting, updating, or deleting a . From 1ef07c37e7342ab041cdb8685293ef3869ca4da1 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Fri, 22 May 2015 14:48:13 +0930 Subject: [PATCH 31/35] added integration test --- .../Clients/TeamsClientTests.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Octokit.Tests.Integration/Clients/TeamsClientTests.cs b/Octokit.Tests.Integration/Clients/TeamsClientTests.cs index 4a02c0d2..6414d398 100644 --- a/Octokit.Tests.Integration/Clients/TeamsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/TeamsClientTests.cs @@ -3,7 +3,6 @@ using System.Linq; using System.Net; using System.Threading.Tasks; using Octokit; -using Octokit.Tests.Helpers; using Octokit.Tests.Integration; using Xunit; @@ -46,6 +45,17 @@ public class TeamsClientTests } } + public class TheGetAllForCurrentMethod + { + [IntegrationTest] + public async Task GetsIsMemberWhenAuthenticated() + { + var github = Helper.GetAuthenticatedClient(); + var teams = await github.Organization.Team.GetAllForCurrent(); + Assert.NotEmpty(teams); + } + } + public class TheGetMembershipMethod { readonly Team team; From fe2a42d1c86c31bd681f4c9fc48bffc1c6eed43c Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Fri, 22 May 2015 14:51:20 +0930 Subject: [PATCH 32/35] and another unit test --- Octokit.Tests/Clients/TeamsClientTests.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Octokit.Tests/Clients/TeamsClientTests.cs b/Octokit.Tests/Clients/TeamsClientTests.cs index c57cf966..d1b04fbc 100644 --- a/Octokit.Tests/Clients/TeamsClientTests.cs +++ b/Octokit.Tests/Clients/TeamsClientTests.cs @@ -159,6 +159,20 @@ namespace Octokit.Tests.Clients } } + public class TheGetAllForCurrentMethod + { + [Fact] + public void RequestsTheCorrectUrl() + { + var connection = Substitute.For(); + var client = new TeamsClient(connection); + + client.GetAllForCurrent(); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "user/teams")); + } + } + public class TheGetMembershipMethod { [Fact] From bf4e773bd57fed95f66fc005b305dad73ccce633 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Fri, 22 May 2015 17:26:28 +0930 Subject: [PATCH 33/35] no tears, only dreams --- Octokit/Clients/ITeamsClient.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Octokit/Clients/ITeamsClient.cs b/Octokit/Clients/ITeamsClient.cs index 191648ed..86c67011 100644 --- a/Octokit/Clients/ITeamsClient.cs +++ b/Octokit/Clients/ITeamsClient.cs @@ -39,6 +39,7 @@ namespace Octokit /// /// Thrown when a general API error occurs. /// A list of the user's s. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] Task> GetAllForCurrent(); /// From eda59300e4a974e776e9a2a22afa259c972e9391 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Fri, 22 May 2015 20:17:35 +0930 Subject: [PATCH 34/35] cleanup test and make API call a bit more robust --- Octokit.Tests/Clients/TeamsClientTests.cs | 10 +++++++--- Octokit/Clients/TeamsClient.cs | 5 +++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Octokit.Tests/Clients/TeamsClientTests.cs b/Octokit.Tests/Clients/TeamsClientTests.cs index d1b04fbc..52fbe985 100644 --- a/Octokit.Tests/Clients/TeamsClientTests.cs +++ b/Octokit.Tests/Clients/TeamsClientTests.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Threading.Tasks; using NSubstitute; using Octokit.Tests.Helpers; @@ -138,14 +139,17 @@ namespace Octokit.Tests.Clients public class TheAddMembershipMethod { [Fact] - public void RequestsTheCorrectUrl() + public async Task RequestsTheCorrectUrl() { var connection = Substitute.For(); + var client = new TeamsClient(connection); - client.AddMembership(1, "user"); + await client.AddMembership(1, "user"); - connection.Connection.Received().Put(Arg.Is(u => u.ToString() == "teams/1/memberships/user")); + connection.Received().Put>( + Arg.Is(u => u.ToString() == "teams/1/memberships/user"), + Args.Object); } [Fact] diff --git a/Octokit/Clients/TeamsClient.cs b/Octokit/Clients/TeamsClient.cs index ea8ee208..4afab495 100644 --- a/Octokit/Clients/TeamsClient.cs +++ b/Octokit/Clients/TeamsClient.cs @@ -171,6 +171,11 @@ namespace Octokit return TeamMembership.NotFound; } + if (response == null || !response.ContainsKey("state")) + { + return TeamMembership.NotFound; + } + return response["state"] == "active" ? TeamMembership.Active : TeamMembership.Pending; From 8aa5a247d86f42e2a24dd12c4c534904241c84f4 Mon Sep 17 00:00:00 2001 From: campersau Date: Thu, 11 Jun 2015 18:34:16 +0200 Subject: [PATCH 35/35] rename misleading responseIsArray variable to responseIsObject --- Octokit/Http/JsonHttpPipeline.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Octokit/Http/JsonHttpPipeline.cs b/Octokit/Http/JsonHttpPipeline.cs index a79876d3..66e01c07 100644 --- a/Octokit/Http/JsonHttpPipeline.cs +++ b/Octokit/Http/JsonHttpPipeline.cs @@ -54,11 +54,11 @@ namespace Octokit.Internal { var typeIsDictionary = typeof(IDictionary).IsAssignableFrom(typeof(T)); var typeIsEnumerable = typeof(IEnumerable).IsAssignableFrom(typeof(T)); - var responseIsArray = body.StartsWith("{", StringComparison.Ordinal); + var responseIsObject = body.StartsWith("{", StringComparison.Ordinal); // If we're expecting an array, but we get a single object, just wrap it. // This supports an api that dynamically changes the return type based on the content. - if (!typeIsDictionary && typeIsEnumerable && responseIsArray) + if (!typeIsDictionary && typeIsEnumerable && responseIsObject) { body = "[" + body + "]"; }