Skip to content

Commit

Permalink
Add methods for getting all pending invites for a team
Browse files Browse the repository at this point in the history
  • Loading branch information
hnrkndrssn committed Aug 6, 2017
1 parent 5a0cda7 commit 96ea359
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Octokit.Reactive/Clients/IObservableTeamsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,5 +196,17 @@ public interface IObservableTeamsClient
/// </remarks>
/// <returns><see langword="true"/> if the repository is managed by the given team; <see langword="false"/> otherwise.</returns>
IObservable<bool> IsRepositoryManagedByTeam(int id, string owner, string repo);

/// <summary>
/// List all pending invites for the given team.
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/orgs/teams/#list-pending-team-invitations">API Documentation</a>
/// for more information.
/// </remarks>
/// <param name="id">The team identifier</param>
/// <returns></returns>
IObservable<OrganizationMembershipInvite> GetAllPendingInvitations(int id);

}
}
16 changes: 16 additions & 0 deletions Octokit.Reactive/Clients/ObservableTeamsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,5 +295,21 @@ public IObservable<bool> IsRepositoryManagedByTeam(int id, string owner, string
Ensure.ArgumentNotNullOrEmptyString(repo, "repo");
return _client.IsRepositoryManagedByTeam(id, owner, repo).ToObservable();
}

/// <summary>
/// List all pending invites for the given team.
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/orgs/teams/#list-pending-team-invitations">API Documentation</a>
/// for more information.
/// </remarks>
/// <param name="id">The team identifier</param>
/// <returns></returns>
public IObservable<OrganizationMembershipInvite> GetAllPendingInvitations(int id)
{
Ensure.ArgumentNotNull(id, nameof(id));

return _connection.GetAndFlattenAllPages<OrganizationMembershipInvite>(ApiUrls.TeamPendingInvites(id), null, AcceptHeaders.OrganizationMembershipPreview);
}
}
}
11 changes: 11 additions & 0 deletions Octokit/Clients/ITeamsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,5 +186,16 @@ public interface ITeamsClient
/// </remarks>
/// <returns><see langword="true"/> if the repository is managed by the given team; <see langword="false"/> otherwise.</returns>
Task<bool> IsRepositoryManagedByTeam(int id, string owner, string repo);

/// <summary>
/// List all pending invites for the given team.
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/orgs/teams/#list-pending-team-invitations">API Documentation</a>
/// for more information.
/// </remarks>
/// <param name="id">The team identifier</param>
/// <returns></returns>
Task<IReadOnlyList<OrganizationMembershipInvite>> GetAllPendingInvitations(int id);
}
}
16 changes: 16 additions & 0 deletions Octokit/Clients/TeamsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -380,5 +380,21 @@ public async Task<bool> IsRepositoryManagedByTeam(int id, string owner, string r
return false;
}
}

/// <summary>
/// List all pending invites for the given team.
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/orgs/teams/#list-pending-team-invitations">API Documentation</a>
/// for more information.
/// </remarks>
/// <param name="id">The team identifier</param>
/// <returns></returns>
public async Task<IReadOnlyList<OrganizationMembershipInvite>> GetAllPendingInvitations(int id)
{
Ensure.ArgumentNotNull(id, nameof(id));

return await ApiConnection.GetAll<OrganizationMembershipInvite>(ApiUrls.TeamPendingInvites(id), null, AcceptHeaders.OrganizationMembershipPreview);
}
}
}
16 changes: 16 additions & 0 deletions Octokit/Helpers/ApiUrls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,11 @@ public static Uri OrganizationMembership(string org, string name)
return "orgs/{0}/public_members/{1}".FormatUri(org, name);
}

/// <summary>
/// Returns the <see cref="Uri"/> for the organizations pending invitations
/// </summary>
/// <param name="org">The name of the organization</param>
/// <returns></returns>
public static Uri OrganizationPendingInvites(string org)
{
return "orgs/{0}/invitations".FormatUri(org);
Expand Down Expand Up @@ -1488,6 +1493,17 @@ public static Uri TeamRepository(int id, string organization, string repoName)
return "teams/{0}/repos/{1}/{2}".FormatUri(id, organization, repoName);
}

/// <summary>
/// returns the <see cref="Uri"/> for the teams pending invitations
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public static Uri TeamPendingInvites(int id)
{
return "teams/{0}/invitations".FormatUri(id);
}


/// <summary>
/// returns the <see cref="Uri"/> for teams
/// use for update or deleting a team
Expand Down

0 comments on commit 96ea359

Please sign in to comment.