Skip to content

Commit

Permalink
implemented update email verification
Browse files Browse the repository at this point in the history
  • Loading branch information
pingu2k4 committed Oct 12, 2024
1 parent ec20a72 commit a1bef62
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/PinguApps.Appwrite.Playground/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
8 changes: 7 additions & 1 deletion src/PinguApps.Appwrite.Server/Clients/IUsersClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,13 @@ public interface IUsersClient
/// <param name="request">The request content</param>
/// <returns>The token</returns>
Task<AppwriteResult<Token>> CreateToken(CreateTokenRequest request);
[Obsolete("This method hasn't yet been implemented.", true)]

/// <summary>
/// Update the user email verification status by its unique ID
/// <para><see href="https://appwrite.io/docs/references/1.6.x/server-rest/users#updateEmailVerification">Appwrite Docs</see></para>
/// </summary>
/// <param name="request">The request content</param>
/// <returns>The user</returns>
Task<AppwriteResult<User>> UpdateEmailVerification(UpdateEmailVerificationRequest request);
[Obsolete("This method hasn't yet been implemented.", true)]
Task<AppwriteResult<User>> UpdatePhoneVerification(UpdatePhoneVerificationRequest request);
Expand Down
17 changes: 15 additions & 2 deletions src/PinguApps.Appwrite.Server/Clients/UsersClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -701,9 +701,22 @@ public async Task<AppwriteResult<Token>> CreateToken(CreateTokenRequest request)
}
}

[ExcludeFromCodeCoverage]
/// <inheritdoc/>
public Task<AppwriteResult<User>> UpdateEmailVerification(UpdateEmailVerificationRequest request) => throw new NotImplementedException();
public async Task<AppwriteResult<User>> UpdateEmailVerification(UpdateEmailVerificationRequest request)
{
try
{
request.Validate(true);

var result = await _usersApi.UpdateEmailVerification(request.UserId, request);

return result.GetApiResponse();
}
catch (Exception e)
{
return e.GetExceptionResponse<User>();
}
}

[ExcludeFromCodeCoverage]
/// <inheritdoc/>
Expand Down

0 comments on commit a1bef62

Please sign in to comment.