using EntitlementBLL.Interfaces; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using GB5Shared.Resource.Response; using static GB5Shared.GB5Constant.Constant; using GB5Shared.Authorization; namespace EntitlementSL.Endpoints.FeatureFlag; [MenuRights("entfeatureflags", RightOperation.Update)] public class ActivateKillSwitch : BaseEndpoint> { private readonly IFeatureFlagService _FeatureFlagService; public ActivateKillSwitch(IFeatureFlagService featureFlagService) => _FeatureFlagService = featureFlagService; public override void Configure() { Post("/lic/FeatureFlag.svc/ActivateKillSwitch"); AllowAnonymous(); } public record Params( [property: FromHeader] string Login, [property: FromBody] Body Body ); public record Body(int FeatureFlagId, string Reason); protected override string? GetCacheKey(Params req, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync(Params req, LoginDTO loginDTO, CancellationToken ct) { await _FeatureFlagService.ActivateKillSwitchAsync(req.Body.FeatureFlagId, req.Body.Reason, loginDTO.UserId, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(SuccessResponse.UpdateSuccess, CacheKeyLevel.NOT_REQUIRED, loginDTO); } }