diff --git a/README.md b/README.md
index f8c40bc0..6351291e 100644
--- a/README.md
+++ b/README.md
@@ -141,9 +141,9 @@ string emailAddressOrErrorMessage = userResponse.Result.Match(
## ⌛ Progress
-![Server & Client - 95 / 292](https://img.shields.io/badge/Server_&_Client-95%20%2F%20292-red?style=for-the-badge)
+![Server & Client - 96 / 292](https://img.shields.io/badge/Server_&_Client-96%20%2F%20292-red?style=for-the-badge)
-![Server - 51 / 202](https://img.shields.io/badge/Server-51%20%2F%20202-red?style=for-the-badge)
+![Server - 52 / 202](https://img.shields.io/badge/Server-52%20%2F%20202-red?style=for-the-badge)
![Client - 44 / 90](https://img.shields.io/badge/Client-44%20%2F%2090-gold?style=for-the-badge)
@@ -208,7 +208,7 @@ string emailAddressOrErrorMessage = userResponse.Result.Match(
| [Create Phone Verification (Confirmation)](https://appwrite.io/docs/references/1.6.x/client-rest/account#updatePhoneVerification) | ✅ | ❌ | |
### Users
-![Account - 40 / 42](https://img.shields.io/badge/Users-40%20%2F%2042-forestgreen?style=for-the-badge)
+![Account - 41 / 42](https://img.shields.io/badge/Users-40%20%2F%2042-forestgreen?style=for-the-badge)
| Endpoint | Client | Server |
|:-:|:-:|:-:|
@@ -252,7 +252,7 @@ string emailAddressOrErrorMessage = userResponse.Result.Match(
| [Update User Target](https://appwrite.io/docs/references/1.6.x/server-rest/users#updateTarget) | ❌ | ✅ |
| [Delete User Target](https://appwrite.io/docs/references/1.6.x/server-rest/users#deleteTarget) | ❌ | ✅ |
| [Create Token](https://appwrite.io/docs/references/1.6.x/server-rest/users#createToken) | ❌ | ✅ |
-| [Update Email Verification](https://appwrite.io/docs/references/1.6.x/server-rest/users#updateEmailVerification) | ❌ | ⬛ |
+| [Update Email Verification](https://appwrite.io/docs/references/1.6.x/server-rest/users#updateEmailVerification) | ❌ | ✅ |
| [Update Phone Verification](https://appwrite.io/docs/references/1.6.x/server-rest/users#updatePhoneVerification) | ❌ | ⬛ |
### Teams
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]
///
diff --git a/tests/PinguApps.Appwrite.Server.Tests/Clients/Users/UsersClientTests.UpdateEmailVerification.cs b/tests/PinguApps.Appwrite.Server.Tests/Clients/Users/UsersClientTests.UpdateEmailVerification.cs
new file mode 100644
index 00000000..e1881634
--- /dev/null
+++ b/tests/PinguApps.Appwrite.Server.Tests/Clients/Users/UsersClientTests.UpdateEmailVerification.cs
@@ -0,0 +1,78 @@
+using System.Net;
+using PinguApps.Appwrite.Shared.Requests.Users;
+using PinguApps.Appwrite.Shared.Tests;
+using PinguApps.Appwrite.Shared.Utils;
+using RichardSzalay.MockHttp;
+
+namespace PinguApps.Appwrite.Server.Tests.Clients.Users;
+public partial class UsersClientTests
+{
+ [Fact]
+ public async Task UpdateEmailVerification_ShouldReturnSuccess_WhenApiCallSucceeds()
+ {
+ // Arrange
+ var request = new UpdateEmailVerificationRequest
+ {
+ UserId = IdUtils.GenerateUniqueId(),
+ // Add other properties as needed
+ };
+
+ _mockHttp.Expect(HttpMethod.Patch, $"{Constants.Endpoint}/users/{request.UserId}/verification")
+ .ExpectedHeaders()
+ .WithJsonContent(request)
+ .Respond(Constants.AppJson, Constants.UserResponse);
+
+ // Act
+ var result = await _appwriteClient.Users.UpdateEmailVerification(request);
+
+ // Assert
+ Assert.True(result.Success);
+ }
+
+ [Fact]
+ public async Task UpdateEmailVerification_ShouldHandleException_WhenApiCallFails()
+ {
+ // Arrange
+ var request = new UpdateEmailVerificationRequest
+ {
+ UserId = IdUtils.GenerateUniqueId(),
+ // Add other properties as needed
+ };
+
+ _mockHttp.Expect(HttpMethod.Patch, $"{Constants.Endpoint}/users/{request.UserId}/verification")
+ .ExpectedHeaders()
+ .WithJsonContent(request)
+ .Respond(HttpStatusCode.BadRequest, Constants.AppJson, Constants.AppwriteError);
+
+ // Act
+ var result = await _appwriteClient.Users.UpdateEmailVerification(request);
+
+ // Assert
+ Assert.True(result.IsError);
+ Assert.True(result.IsAppwriteError);
+ }
+
+ [Fact]
+ public async Task UpdateEmailVerification_ShouldReturnErrorResponse_WhenExceptionOccurs()
+ {
+ // Arrange
+ var request = new UpdateEmailVerificationRequest
+ {
+ UserId = IdUtils.GenerateUniqueId(),
+ // Add other properties as needed
+ };
+
+ _mockHttp.Expect(HttpMethod.Patch, $"{Constants.Endpoint}/users/{request.UserId}/verification")
+ .ExpectedHeaders()
+ .WithJsonContent(request)
+ .Throw(new HttpRequestException("An error occurred"));
+
+ // Act
+ var result = await _appwriteClient.Users.UpdateEmailVerification(request);
+
+ // Assert
+ Assert.False(result.Success);
+ Assert.True(result.IsInternalError);
+ Assert.Equal("An error occurred", result.Result.AsT2.Message);
+ }
+}