Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asapferg/user email visibility #1757

Merged
merged 6 commits into from
Feb 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Octokit.Tests.Integration/Clients/UserEmailsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public async Task ReturnsCorrectCountOfEmailsWithoutStart()

const string testEmailAddress = "[email protected]";

[IntegrationTest(Skip = "this isn't passing in CI - i hate past me right now")]
[IntegrationTest]
public async Task CanAddAndDeleteEmail()
{
var github = Helper.GetAuthenticatedClient();
Expand Down
34 changes: 30 additions & 4 deletions Octokit/Models/Response/EmailAddress.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using Octokit.Internal;

namespace Octokit
{
Expand All @@ -12,11 +13,12 @@ public class EmailAddress
{
public EmailAddress() { }

public EmailAddress(string email, bool verified, bool primary)
public EmailAddress(string email, bool verified, bool primary, EmailVisibility visibility)
{
Email = email;
Verified = verified;
Primary = primary;
Visibility = visibility;
}

/// <summary>
Expand All @@ -25,24 +27,48 @@ public EmailAddress(string email, bool verified, bool primary)
public string Email { get; protected set; }

/// <summary>
/// true if the email is verified; otherwise false
/// True if the email is verified; otherwise false
/// </summary>
public bool Verified { get; protected set; }

/// <summary>
/// true if this is the users primary email; otherwise false
/// True if this is the users primary email; otherwise false
/// </summary>
public bool Primary { get; protected set; }

/// <summary>
/// "private" or "public" if the email address is the primary;
/// otherwise null
/// </summary>
public StringEnum<EmailVisibility>? Visibility { get; protected set; }

[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode",
Justification = "Used by DebuggerDisplayAttribute")]
internal string DebuggerDisplay
{
get
{
return string.Format(CultureInfo.InvariantCulture,
"EmailAddress: Email: {0}; Primary: {1}, Verified: {2}", Email, Primary, Verified);
"EmailAddress: Email: {0}; Primary: {1}, Verified: {2}, Visibility: {3}", Email, Primary, Verified, Visibility);
}
}
}

/// <summary>
/// Represents the visibility of an email address.
/// </summary>
public enum EmailVisibility
{
/// <summary>
/// Primary email address and is public
/// </summary>
[Parameter(Value = "public")]
Public,

/// <summary>
/// Primary email address and is private
/// </summary>
[Parameter(Value = "private")]
Private
}
}