mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-02 02:45:32 +00:00
Add client for organization outside collaborators (#1639)
* Add client for organization outside collaborators * Add unit/integration tests * Add methods for removing an outside collaborator * Add unit/integration tests * Add new Put method to Connection which accepts a preview header * Add methods for converting an org member to an outside collaborator * Fix copy paste errors in new exceptions * According to API docs, a 403 should be returned if the member is not a member of the org, but a 404 is actually returned * Add unit/integration tests * Remove unused using directives * Got a bit overzealous with my removal of using directives * Fix integration tests by using the configured Organization and test username rather than henrik's :) * Remove ApiOptions overloads as it isn't currently supported * Fix XML doc grammar * Fix failing unit tests * Missed a couple of nameof replacements
This commit is contained in:
committed by
Ryan Gribble
parent
cda714bef6
commit
1d1ca0a572
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
#if !NO_SERIALIZABLE
|
||||
using System.Runtime.Serialization;
|
||||
#endif
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an error that occurs when trying to convert a user
|
||||
/// that is not a member of the organization to an outside collaborator
|
||||
/// </summary>
|
||||
#if !NO_SERIALIZABLE
|
||||
[Serializable]
|
||||
#endif
|
||||
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors",
|
||||
Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")]
|
||||
public class UserIsNotMemberOfOrganizationException : ApiException
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructs an instance of the <see cref="UserIsNotMemberOfOrganizationException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="response">The HTTP payload from the server</param>
|
||||
public UserIsNotMemberOfOrganizationException(IResponse response) : this(response, null)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs an instance of the <see cref="UserIsNotMemberOfOrganizationException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="response">The HTTP payload from the server</param>
|
||||
/// <param name="innerException">The inner exception</param>
|
||||
public UserIsNotMemberOfOrganizationException(IResponse response, ApiException innerException)
|
||||
: base(response, innerException)
|
||||
{
|
||||
Debug.Assert(response != null && response.StatusCode == HttpStatusCode.NotFound,
|
||||
"UserIsNotMemberOfOrganizationException created with the wrong HTTP status code");
|
||||
}
|
||||
|
||||
// https://developer.github.com/v3/orgs/outside_collaborators/#response-if-user-is-not-a-member-of-the-organization
|
||||
public override string Message => ApiErrorMessageSafe ?? "User is not a member of the organization.";
|
||||
|
||||
#if !NO_SERIALIZABLE
|
||||
/// <summary>
|
||||
/// Constructs an instance of ForbiddenException
|
||||
/// </summary>
|
||||
/// <param name="info">
|
||||
/// The <see cref="SerializationInfo"/> that holds the
|
||||
/// serialized object data about the exception being thrown.
|
||||
/// </param>
|
||||
/// <param name="context">
|
||||
/// The <see cref="StreamingContext"/> that contains
|
||||
/// contextual information about the source or destination.
|
||||
/// </param>
|
||||
protected UserIsNotMemberOfOrganizationException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user