using FastEndpoints; using FrameworkBLL.KeyCloak; using FrameworkDAL.DTO.KeyCloak; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.KeyCloak { public class UpdateClientAsync : BaseEndpoint> { private readonly IKeyCloakBLL _keyCloakBLL; public UpdateClientAsync(IKeyCloakBLL keyCloakBLL) { _keyCloakBLL = keyCloakBLL; } public override void Configure() { Put("/Keycloak/UpdateClientAsync"); AllowAnonymous(); } public record ClientParameters( [property: FromQuery] string realm, [property: FromQuery] string clientId, [property: FromBody] KeycloakClientDTO updatedClientDTO ); protected override async Task> ExecuteAsync(ClientParameters request, LoginDTO loginDTO, CancellationToken ct) { try { string result = await _keyCloakBLL.UpdateClientAsync(request.realm, request.clientId, request.updatedClientDTO); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.NOT_REQUIRED, loginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, loginDTO, ex.Message, 500); } } } }