This repository has been archived by the owner on Dec 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix email verification status parsing error (closes #212)
- Loading branch information
1 parent
a86fd17
commit 6d40408
Showing
10 changed files
with
168 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/Stormpath.SDK.Abstractions/Account/EmailVerificationStatus.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// <copyright file="EmailVerificationStatus.cs" company="Stormpath, Inc."> | ||
// Copyright (c) 2016 Stormpath, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// </copyright> | ||
|
||
using System; | ||
using Stormpath.SDK.Shared; | ||
|
||
namespace Stormpath.SDK.Account | ||
{ | ||
/// <summary> | ||
/// Represents the various states an <see cref="IAccount">Account</see>'s email address may be in. | ||
/// </summary> | ||
public sealed class EmailVerificationStatus : StringEnumeration | ||
{ | ||
/// <summary> | ||
/// The account's email has been verified. | ||
/// </summary> | ||
public static EmailVerificationStatus Verified = new EmailVerificationStatus("VERIFIED"); | ||
|
||
/// <summary> | ||
/// The account's email has not been verified. | ||
/// </summary> | ||
public static EmailVerificationStatus Unverified = new EmailVerificationStatus("UNVERIFIED"); | ||
|
||
/// <summary> | ||
/// The account's email status is not known. | ||
/// </summary> | ||
public static EmailVerificationStatus Unknown = new EmailVerificationStatus("UNKNOWN"); | ||
|
||
private EmailVerificationStatus(string value) | ||
: base(value) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Parses a string to an <see cref="EmailVerificationStatus"/>. | ||
/// </summary> | ||
/// <param name="status">A string containing "verified", "unverified", or "unknown" (matching is case-insensitive).</param> | ||
/// <returns>The <see cref="EmailVerificationStatus"/> with the specified name.</returns> | ||
/// <exception cref="Exception">No match is found.</exception> | ||
public static EmailVerificationStatus Parse(string status) | ||
{ | ||
switch (status.ToUpper()) | ||
{ | ||
case "VERIFIED": | ||
return Verified; | ||
case "UNVERIFIED": | ||
return Unverified; | ||
case "UNKNOWN": | ||
return Unknown; | ||
default: | ||
throw new Exception($"Could not parse email verification status value '{status.ToUpper()}'"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,5 +36,5 @@ | |
"tooling": { | ||
"defaultNamespace": "Stormpath.SDK" | ||
}, | ||
"version": "0.94.1" | ||
"version": "0.94.2" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,6 +77,7 @@ public static class FakeJson | |
}, | ||
""email"": ""[email protected]"", | ||
""emailVerificationToken"": null, | ||
""emailVerificationStatus"": ""UNKNOWN"", | ||
""fullName"": ""Han Solo"", | ||
""givenName"": ""Han"", | ||
""groupMemberships"": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters