From 5386257a3f6c0e645c46685e71850c02692d9830 Mon Sep 17 00:00:00 2001 From: Fredi Kats Date: Tue, 9 Aug 2022 18:10:12 +0400 Subject: [PATCH] feat: implement getting failed org invites (#2533) --- .../IObservableOrganizationMembersClient.cs | 23 +++++++++++ .../ObservableOrganizationMembersClient.cs | 36 +++++++++++++++++- .../Clients/OrganizationMembersClientTests.cs | 18 +++++++++ Octokit/Clients/IOrganizationMembersClient.cs | 23 +++++++++++ Octokit/Clients/OrganizationMembersClient.cs | 38 ++++++++++++++++++- Octokit/Helpers/ApiUrls.cs | 12 +++++- 6 files changed, 147 insertions(+), 3 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableOrganizationMembersClient.cs b/Octokit.Reactive/Clients/IObservableOrganizationMembersClient.cs index a775e5f0e7..7bdea7fff3 100644 --- a/Octokit.Reactive/Clients/IObservableOrganizationMembersClient.cs +++ b/Octokit.Reactive/Clients/IObservableOrganizationMembersClient.cs @@ -340,5 +340,28 @@ public interface IObservableOrganizationMembersClient /// Options to change API behaviour /// IObservable GetAllPendingInvitations(string org, ApiOptions options); + + /// + /// List failed organization invitations. + /// + /// + /// See the API Documentation + /// for more information. + /// + /// The login for the organization + /// + IObservable GetAllFailedInvitations(string org); + + /// + /// List failed organization invitations. + /// + /// + /// See the API Documentation + /// for more information. + /// + /// The login for the organization + /// Options to change API behaviour + /// + IObservable GetAllFailedInvitations(string org, ApiOptions options); } } diff --git a/Octokit.Reactive/Clients/ObservableOrganizationMembersClient.cs b/Octokit.Reactive/Clients/ObservableOrganizationMembersClient.cs index bda101a24a..64a97cbcbe 100644 --- a/Octokit.Reactive/Clients/ObservableOrganizationMembersClient.cs +++ b/Octokit.Reactive/Clients/ObservableOrganizationMembersClient.cs @@ -470,7 +470,41 @@ public IObservable GetAllPendingInvitations(st Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages(ApiUrls.OrganizationPendingInvititations(org), null, options); + return _connection.GetAndFlattenAllPages(ApiUrls.OrganizationPendingInvitations(org), null, options); + } + + /// + /// List failed organization invitations. + /// + /// + /// See the API Documentation + /// for more information. + /// + /// The login for the organization + /// + public IObservable GetAllFailedInvitations(string org) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + + return GetAllFailedInvitations(org, ApiOptions.None); + } + + /// + /// List failed organization invitations. + /// + /// + /// See the API Documentation + /// for more information. + /// + /// The login for the organization + /// Options to change API behaviour + /// + public IObservable GetAllFailedInvitations(string org, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return _connection.GetAndFlattenAllPages(ApiUrls.OrganizationFailedInvitations(org), null, options); } } } diff --git a/Octokit.Tests.Integration/Clients/OrganizationMembersClientTests.cs b/Octokit.Tests.Integration/Clients/OrganizationMembersClientTests.cs index a86793f3c1..5e8dc01c04 100644 --- a/Octokit.Tests.Integration/Clients/OrganizationMembersClientTests.cs +++ b/Octokit.Tests.Integration/Clients/OrganizationMembersClientTests.cs @@ -275,5 +275,23 @@ public async Task ReturnsCorrectCountOfPendingInvitationsWithStart() } } } + + public class TheGetAllFailedInvitationsMethod + { + readonly IGitHubClient _gitHub; + + public TheGetAllFailedInvitationsMethod() + { + _gitHub = Helper.GetAuthenticatedClient(); + } + + [OrganizationTest] + public async Task ReturnsNoFailedInvitations() + { + var pendingInvitations = await _gitHub.Organization.Member.GetAllFailedInvitations(Helper.Organization); + Assert.NotNull(pendingInvitations); + Assert.Empty(pendingInvitations); + } + } } } diff --git a/Octokit/Clients/IOrganizationMembersClient.cs b/Octokit/Clients/IOrganizationMembersClient.cs index cb33f5aed7..91f102daec 100644 --- a/Octokit/Clients/IOrganizationMembersClient.cs +++ b/Octokit/Clients/IOrganizationMembersClient.cs @@ -346,5 +346,28 @@ public interface IOrganizationMembersClient /// Options to change API behaviour /// Task> GetAllPendingInvitations(string org, ApiOptions options); + + /// + /// List failed organization invitations. + /// + /// + /// See the API Documentation + /// for more information. + /// + /// The login for the organization + /// + Task> GetAllFailedInvitations(string org); + + /// + /// List failed organization invitations. + /// + /// + /// See the API Documentation + /// for more information. + /// + /// The login for the organization + /// Options to change API behaviour + /// + Task> GetAllFailedInvitations(string org, ApiOptions options); } } diff --git a/Octokit/Clients/OrganizationMembersClient.cs b/Octokit/Clients/OrganizationMembersClient.cs index ca2931ed37..4bed05e1ad 100644 --- a/Octokit/Clients/OrganizationMembersClient.cs +++ b/Octokit/Clients/OrganizationMembersClient.cs @@ -565,7 +565,43 @@ public Task> GetAllPendingInvita Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll(ApiUrls.OrganizationPendingInvititations(org), null, options); + return ApiConnection.GetAll(ApiUrls.OrganizationPendingInvitations(org), null, options); + } + + /// + /// List failed organization invitations. + /// + /// + /// See the API Documentation + /// for more information. + /// + /// The login for the organization + /// + [ManualRoute("GET", "/orgs/{org}/failed_invitations")] + public Task> GetAllFailedInvitations(string org) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + + return GetAllFailedInvitations(org, ApiOptions.None); + } + + /// + /// List failed organization invitations. + /// + /// + /// See the API Documentation + /// for more information. + /// + /// The login for the organization + /// Options to change API behaviour + /// + [ManualRoute("GET", "/orgs/{org}/failed_invitations")] + public Task> GetAllFailedInvitations(string org, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return ApiConnection.GetAll(ApiUrls.OrganizationFailedInvitations(org), null, options); } } } diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index be9f561037..de890c6247 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -850,11 +850,21 @@ public static Uri OrganizationMemberships(string org, string name) /// /// The name of the organization /// - public static Uri OrganizationPendingInvititations(string org) + public static Uri OrganizationPendingInvitations(string org) { return "orgs/{0}/invitations".FormatUri(org); } + /// + /// Returns the for the organizations failed invitations + /// + /// The name of the organization + /// + public static Uri OrganizationFailedInvitations(string org) + { + return "orgs/{0}/failed_invitations".FormatUri(org); + } + /// /// Returns the that returns all of the outside collaborators of the organization ///