From a1bef6227781e33b0a7428ca2d71c44e1baa45fb Mon Sep 17 00:00:00 2001 From: Matthew Parker Date: Sat, 12 Oct 2024 01:44:33 +0100 Subject: [PATCH] implemented update email verification --- src/PinguApps.Appwrite.Playground/App.cs | 7 ++++--- .../Clients/IUsersClient.cs | 8 +++++++- .../Clients/UsersClient.cs | 17 +++++++++++++++-- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/PinguApps.Appwrite.Playground/App.cs b/src/PinguApps.Appwrite.Playground/App.cs index 72b0a082..73555236 100644 --- a/src/PinguApps.Appwrite.Playground/App.cs +++ b/src/PinguApps.Appwrite.Playground/App.cs @@ -17,12 +17,13 @@ public App(Client.IAppwriteClient client, Server.Clients.IAppwriteClient server, public async Task Run(string[] args) { - var request = new CreateTokenRequest() + var request = new UpdateEmailVerificationRequest() { - UserId = "664aac1a00113f82e620" + UserId = "664aac1a00113f82e620", + EmailVerification = true }; - var response = await _server.Users.CreateToken(request); + var response = await _server.Users.UpdateEmailVerification(request); Console.WriteLine(response.Result.Match( result => result.ToString(), diff --git a/src/PinguApps.Appwrite.Server/Clients/IUsersClient.cs b/src/PinguApps.Appwrite.Server/Clients/IUsersClient.cs index d9ab29ee..f23ffef9 100644 --- a/src/PinguApps.Appwrite.Server/Clients/IUsersClient.cs +++ b/src/PinguApps.Appwrite.Server/Clients/IUsersClient.cs @@ -334,7 +334,13 @@ public interface IUsersClient /// The request content /// The token Task> CreateToken(CreateTokenRequest request); - [Obsolete("This method hasn't yet been implemented.", true)] + + /// + /// Update the user email verification status by its unique ID + /// Appwrite Docs + /// + /// The request content + /// The user Task> UpdateEmailVerification(UpdateEmailVerificationRequest request); [Obsolete("This method hasn't yet been implemented.", true)] Task> UpdatePhoneVerification(UpdatePhoneVerificationRequest request); diff --git a/src/PinguApps.Appwrite.Server/Clients/UsersClient.cs b/src/PinguApps.Appwrite.Server/Clients/UsersClient.cs index 7f5a90b2..cfbea96c 100644 --- a/src/PinguApps.Appwrite.Server/Clients/UsersClient.cs +++ b/src/PinguApps.Appwrite.Server/Clients/UsersClient.cs @@ -701,9 +701,22 @@ public async Task> CreateToken(CreateTokenRequest request) } } - [ExcludeFromCodeCoverage] /// - public Task> UpdateEmailVerification(UpdateEmailVerificationRequest request) => throw new NotImplementedException(); + public async Task> UpdateEmailVerification(UpdateEmailVerificationRequest request) + { + try + { + request.Validate(true); + + var result = await _usersApi.UpdateEmailVerification(request.UserId, request); + + return result.GetApiResponse(); + } + catch (Exception e) + { + return e.GetExceptionResponse(); + } + } [ExcludeFromCodeCoverage] ///