-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #122 from PinguApps/89-delete-authenticator
Implemented delete authenticator
- Loading branch information
Showing
24 changed files
with
729 additions
and
42 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
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
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 |
---|---|---|
@@ -1,40 +1,44 @@ | ||
using OneOf; | ||
using OneOf.Types; | ||
|
||
namespace PinguApps.Appwrite.Shared; | ||
|
||
/// <summary> | ||
/// The result of all API calls | ||
/// </summary> | ||
/// <typeparam name="TResult">the type of response expected on success</typeparam> | ||
public class AppwriteResult<TResult> | ||
public class AppwriteResult | ||
{ | ||
public AppwriteResult(OneOf<TResult, AppwriteError, InternalError> result) | ||
public AppwriteResult(OneOf<Success, AppwriteError, InternalError> result) | ||
{ | ||
Result = result; | ||
} | ||
|
||
protected AppwriteResult() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// The result of making the API call. Can be <see cref="TResult"/>, <see cref="AppwriteError"/> or <see cref="InternalError"/> depending on what happened | ||
/// The result of making the API call. Can be <see cref="OneOf.Types.Success"/>, <see cref="AppwriteError"/> or <see cref="InternalError"/> depending on what happened | ||
/// </summary> | ||
public OneOf<TResult, AppwriteError, InternalError> Result { get; } | ||
public OneOf<Success, AppwriteError, InternalError> Result { get; } | ||
|
||
/// <summary> | ||
/// Indicates the API call was successful | ||
/// </summary> | ||
public bool Success => Result.IsT0; | ||
public virtual bool Success => Result.IsT0; | ||
|
||
/// <summary> | ||
/// Indicates there is an error | ||
/// </summary> | ||
public bool IsError => Result.IsT1 || Result.IsT2; | ||
public virtual bool IsError => Result.IsT1 || Result.IsT2; | ||
|
||
/// <summary> | ||
/// Indicates that there was an error thrown within Appwrite | ||
/// </summary> | ||
public bool IsAppwriteError => Result.IsT1; | ||
public virtual bool IsAppwriteError => Result.IsT1; | ||
|
||
/// <summary> | ||
/// Indicates that there was an error thrown within the SDK | ||
/// </summary> | ||
public bool IsInternalError => Result.IsT2; | ||
public virtual bool IsInternalError => Result.IsT2; | ||
} |
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,30 @@ | ||
using OneOf; | ||
|
||
namespace PinguApps.Appwrite.Shared; | ||
|
||
/// <inheritdoc/> | ||
/// <typeparam name="TResult">the type of response expected on success</typeparam> | ||
public class AppwriteResult<TResult> : AppwriteResult | ||
{ | ||
public AppwriteResult(OneOf<TResult, AppwriteError, InternalError> result) | ||
{ | ||
Result = result; | ||
} | ||
|
||
/// <summary> | ||
/// /// The result of making the API call. Can be <see cref="TResult"/>, <see cref="AppwriteError"/> or <see cref="InternalError"/> depending on what happened | ||
/// </summary> | ||
public new OneOf<TResult, AppwriteError, InternalError> Result { get; } | ||
|
||
/// <inheritdoc/> | ||
public override bool Success => Result.IsT0; | ||
|
||
/// <inheritdoc/> | ||
public override bool IsError => Result.IsT1 || Result.IsT2; | ||
|
||
/// <inheritdoc/> | ||
public override bool IsAppwriteError => Result.IsT1; | ||
|
||
/// <inheritdoc/> | ||
public override bool IsInternalError => Result.IsT2; | ||
} |
12 changes: 12 additions & 0 deletions
12
src/PinguApps.Appwrite.Shared/Requests/AddAuthenticatorRequest.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,12 @@ | ||
using System.Text.Json.Serialization; | ||
using PinguApps.Appwrite.Shared.Requests.Validators; | ||
|
||
namespace PinguApps.Appwrite.Shared.Requests; | ||
public class AddAuthenticatorRequest : BaseRequest<AddAuthenticatorRequest, AddAuthenticatorRequestValidator> | ||
{ | ||
/// <summary> | ||
/// Type of authenticator. Must be `totp` | ||
/// </summary> | ||
[JsonIgnore] | ||
public string Type { get; set; } = "totp"; | ||
} |
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
22 changes: 22 additions & 0 deletions
22
src/PinguApps.Appwrite.Shared/Requests/DeleteAuthenticatorRequest.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,22 @@ | ||
using System.Text.Json.Serialization; | ||
using PinguApps.Appwrite.Shared.Requests.Validators; | ||
|
||
namespace PinguApps.Appwrite.Shared.Requests; | ||
|
||
/// <summary> | ||
/// The request for deleting an authenticator | ||
/// </summary> | ||
public class DeleteAuthenticatorRequest : BaseRequest<DeleteAuthenticatorRequest, DeleteAuthenticatorRequestValidator> | ||
{ | ||
/// <summary> | ||
/// Type of authenticator | ||
/// </summary> | ||
[JsonIgnore] | ||
public string Type { get; set; } = "totp"; | ||
|
||
/// <summary> | ||
/// Valid verification token | ||
/// </summary> | ||
[JsonPropertyName("otp")] | ||
public string Otp { get; set; } = string.Empty; | ||
} |
10 changes: 10 additions & 0 deletions
10
src/PinguApps.Appwrite.Shared/Requests/Validators/AddAuthenticatorRequestValidator.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,10 @@ | ||
using FluentValidation; | ||
|
||
namespace PinguApps.Appwrite.Shared.Requests.Validators; | ||
public class AddAuthenticatorRequestValidator : AbstractValidator<AddAuthenticatorRequest> | ||
{ | ||
public AddAuthenticatorRequestValidator() | ||
{ | ||
RuleFor(x => x.Type).NotEmpty(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/PinguApps.Appwrite.Shared/Requests/Validators/DeleteAuthenticatorRequestValidator.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,11 @@ | ||
using FluentValidation; | ||
|
||
namespace PinguApps.Appwrite.Shared.Requests.Validators; | ||
public class DeleteAuthenticatorRequestValidator : AbstractValidator<DeleteAuthenticatorRequest> | ||
{ | ||
public DeleteAuthenticatorRequestValidator() | ||
{ | ||
RuleFor(x => x.Type).NotEmpty(); | ||
RuleFor(x => x.Otp).NotEmpty(); | ||
} | ||
} |
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
Oops, something went wrong.