Skip to content

Commit

Permalink
feat: implement getting failed org invites (octokit#2533)
Browse files Browse the repository at this point in the history
  • Loading branch information
FrediKats authored Aug 9, 2022
1 parent bc156af commit 5386257
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 3 deletions.
23 changes: 23 additions & 0 deletions Octokit.Reactive/Clients/IObservableOrganizationMembersClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -340,5 +340,28 @@ public interface IObservableOrganizationMembersClient
/// <param name="options">Options to change API behaviour</param>
/// <returns></returns>
IObservable<OrganizationMembershipInvitation> GetAllPendingInvitations(string org, ApiOptions options);

/// <summary>
/// List failed organization invitations.
/// </summary>
/// <remarks>
/// See the <a href="https://docs.github.com/en/rest/orgs/members#list-failed-organization-invitations">API Documentation</a>
/// for more information.
/// </remarks>
/// <param name="org">The login for the organization</param>
/// <returns></returns>
IObservable<OrganizationMembershipInvitation> GetAllFailedInvitations(string org);

/// <summary>
/// List failed organization invitations.
/// </summary>
/// <remarks>
/// See the <a href="https://docs.github.com/en/rest/orgs/members#list-failed-organization-invitations">API Documentation</a>
/// for more information.
/// </remarks>
/// <param name="org">The login for the organization</param>
/// <param name="options">Options to change API behaviour</param>
/// <returns></returns>
IObservable<OrganizationMembershipInvitation> GetAllFailedInvitations(string org, ApiOptions options);
}
}
36 changes: 35 additions & 1 deletion Octokit.Reactive/Clients/ObservableOrganizationMembersClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,41 @@ public IObservable<OrganizationMembershipInvitation> GetAllPendingInvitations(st
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<OrganizationMembershipInvitation>(ApiUrls.OrganizationPendingInvititations(org), null, options);
return _connection.GetAndFlattenAllPages<OrganizationMembershipInvitation>(ApiUrls.OrganizationPendingInvitations(org), null, options);
}

/// <summary>
/// List failed organization invitations.
/// </summary>
/// <remarks>
/// See the <a href="https://docs.github.com/en/rest/orgs/members#list-failed-organization-invitations">API Documentation</a>
/// for more information.
/// </remarks>
/// <param name="org">The login for the organization</param>
/// <returns></returns>
public IObservable<OrganizationMembershipInvitation> GetAllFailedInvitations(string org)
{
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));

return GetAllFailedInvitations(org, ApiOptions.None);
}

/// <summary>
/// List failed organization invitations.
/// </summary>
/// <remarks>
/// See the <a href="https://docs.github.com/en/rest/orgs/members#list-failed-organization-invitations">API Documentation</a>
/// for more information.
/// </remarks>
/// <param name="org">The login for the organization</param>
/// <param name="options">Options to change API behaviour</param>
/// <returns></returns>
public IObservable<OrganizationMembershipInvitation> GetAllFailedInvitations(string org, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<OrganizationMembershipInvitation>(ApiUrls.OrganizationFailedInvitations(org), null, options);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
23 changes: 23 additions & 0 deletions Octokit/Clients/IOrganizationMembersClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -346,5 +346,28 @@ public interface IOrganizationMembersClient
/// <param name="options">Options to change API behaviour</param>
/// <returns></returns>
Task<IReadOnlyList<OrganizationMembershipInvitation>> GetAllPendingInvitations(string org, ApiOptions options);

/// <summary>
/// List failed organization invitations.
/// </summary>
/// <remarks>
/// See the <a href="https://docs.github.com/en/rest/orgs/members#list-failed-organization-invitations">API Documentation</a>
/// for more information.
/// </remarks>
/// <param name="org">The login for the organization</param>
/// <returns></returns>
Task<IReadOnlyList<OrganizationMembershipInvitation>> GetAllFailedInvitations(string org);

/// <summary>
/// List failed organization invitations.
/// </summary>
/// <remarks>
/// See the <a href="https://docs.github.com/en/rest/orgs/members#list-failed-organization-invitations">API Documentation</a>
/// for more information.
/// </remarks>
/// <param name="org">The login for the organization</param>
/// <param name="options">Options to change API behaviour</param>
/// <returns></returns>
Task<IReadOnlyList<OrganizationMembershipInvitation>> GetAllFailedInvitations(string org, ApiOptions options);
}
}
38 changes: 37 additions & 1 deletion Octokit/Clients/OrganizationMembersClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,43 @@ public Task<IReadOnlyList<OrganizationMembershipInvitation>> GetAllPendingInvita
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
Ensure.ArgumentNotNull(options, nameof(options));

return ApiConnection.GetAll<OrganizationMembershipInvitation>(ApiUrls.OrganizationPendingInvititations(org), null, options);
return ApiConnection.GetAll<OrganizationMembershipInvitation>(ApiUrls.OrganizationPendingInvitations(org), null, options);
}

/// <summary>
/// List failed organization invitations.
/// </summary>
/// <remarks>
/// See the <a href="https://docs.github.com/en/rest/orgs/members#list-failed-organization-invitations">API Documentation</a>
/// for more information.
/// </remarks>
/// <param name="org">The login for the organization</param>
/// <returns></returns>
[ManualRoute("GET", "/orgs/{org}/failed_invitations")]
public Task<IReadOnlyList<OrganizationMembershipInvitation>> GetAllFailedInvitations(string org)
{
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));

return GetAllFailedInvitations(org, ApiOptions.None);
}

/// <summary>
/// List failed organization invitations.
/// </summary>
/// <remarks>
/// See the <a href="https://docs.github.com/en/rest/orgs/members#list-failed-organization-invitations">API Documentation</a>
/// for more information.
/// </remarks>
/// <param name="org">The login for the organization</param>
/// <param name="options">Options to change API behaviour</param>
/// <returns></returns>
[ManualRoute("GET", "/orgs/{org}/failed_invitations")]
public Task<IReadOnlyList<OrganizationMembershipInvitation>> GetAllFailedInvitations(string org, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
Ensure.ArgumentNotNull(options, nameof(options));

return ApiConnection.GetAll<OrganizationMembershipInvitation>(ApiUrls.OrganizationFailedInvitations(org), null, options);
}
}
}
12 changes: 11 additions & 1 deletion Octokit/Helpers/ApiUrls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -850,11 +850,21 @@ public static Uri OrganizationMemberships(string org, string name)
/// </summary>
/// <param name="org">The name of the organization</param>
/// <returns></returns>
public static Uri OrganizationPendingInvititations(string org)
public static Uri OrganizationPendingInvitations(string org)
{
return "orgs/{0}/invitations".FormatUri(org);
}

/// <summary>
/// Returns the <see cref="Uri"/> for the organizations failed invitations
/// </summary>
/// <param name="org">The name of the organization</param>
/// <returns></returns>
public static Uri OrganizationFailedInvitations(string org)
{
return "orgs/{0}/failed_invitations".FormatUri(org);
}

/// <summary>
/// Returns the <see cref="Uri"/> that returns all of the outside collaborators of the organization
/// </summary>
Expand Down

0 comments on commit 5386257

Please sign in to comment.