Skip to content

Commit

Permalink
implemented update email
Browse files Browse the repository at this point in the history
  • Loading branch information
pingu2k4 committed Oct 8, 2024
1 parent f8c3775 commit c7a7518
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 DeleteUserRequest()
var request = new UpdateEmailRequest()
{
UserId = "670565fa00209de81fb0"
UserId = "664aac1a00113f82e620",
Email = "[email protected]"
};

var response = await _server.Users.DeleteUser(request);
var response = await _server.Users.UpdateEmail(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 @@ -116,7 +116,13 @@ public interface IUsersClient
/// <param name="request">The request content</param>
/// <returns>The user</returns>
Task<AppwriteResult<User>> GetUser(GetUserRequest request);
[Obsolete("This method hasn't yet been implemented.", true)]

/// <summary>
/// Update the user email by its unique ID
/// <para><see href="https://appwrite.io/docs/references/1.6.x/server-rest/users#updateEmail">Appwrite Docs</see></para>
/// </summary>
/// <param name="request">The request content</param>
/// <returns>The user</returns>
Task<AppwriteResult<User>> UpdateEmail(UpdateEmailRequest request);
[Obsolete("This method hasn't yet been implemented.", true)]
Task<AppwriteResult<Jwt>> CreateUserJwt(CreateUserJwtRequest 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 @@ -247,9 +247,22 @@ public async Task<AppwriteResult<User>> GetUser(GetUserRequest request)
}
}

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

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

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

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

0 comments on commit c7a7518

Please sign in to comment.