using FastEndpoints; using FrameworkBLL.GCM; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.GCM { public class GetGCM : BaseEndpoint> { private readonly IGCMBLL _gcmBLL; public GetGCM(IGCMBLL gcmBLL) { _gcmBLL = gcmBLL; } public override void Configure() { Get("/GCM/GetGCM"); AllowAnonymous(); } public record GetGCMParameters( [property: FromHeader] string Login, [property: QueryParam] int GcmId ); protected override string? GetCacheKey(GetGCMParameters req, LoginDTO loginDTO) { try { return KeyGenerator.KeyGeneration(req.GcmId, EntityConstant.OBJECTGCM, CacheKeyLevel.USER_LEVEL, loginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetGCMParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _gcmBLL.GetGCM(req.GcmId, loginDTO); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.USER_LEVEL, loginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.USER_LEVEL, loginDTO, ex.Message, 500); } } } }