From 3b77345aeea04e725d67158213e86dda5537d5f5 Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 12 Dec 2025 13:17:54 +0100 Subject: [PATCH] Refactor API key location to use enum instead of string Changed EndpointAuthApiKeyAddTo from string? to ApiKeyLocation? enum in RecActionDto for type safety. Updated related logic in InvokeRecActionCommandHandler to use the enum, and added the necessary using directive for ReC.Domain.Constants. --- src/ReC.Application/Common/Dto/RecActionDto.cs | 2 +- .../RecActions/Commands/InvokeRecActionCommand.cs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ReC.Application/Common/Dto/RecActionDto.cs b/src/ReC.Application/Common/Dto/RecActionDto.cs index 4395e59..800de52 100644 --- a/src/ReC.Application/Common/Dto/RecActionDto.cs +++ b/src/ReC.Application/Common/Dto/RecActionDto.cs @@ -27,7 +27,7 @@ public record RecActionDto public string? EndpointAuthApiValue { get; init; } - public string? EndpointAuthApiKeyAddTo { get; init; } + public ApiKeyLocation? EndpointAuthApiKeyAddTo { get; init; } public string? EndpointAuthToken { get; init; } diff --git a/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs b/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs index 0bd9114..6a3fced 100644 --- a/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs +++ b/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs @@ -5,6 +5,7 @@ using ReC.Application.Common.Constants; using ReC.Application.Common.Dto; using ReC.Application.Common.Exceptions; using ReC.Application.OutResults.Commands; +using ReC.Domain.Constants; using System.Net; using System.Net.Http.Headers; using System.Text; @@ -63,7 +64,7 @@ public class InvokeRecActionCommandHandler( case "API Key": if (action.EndpointAuthApiKey is string apiKey && action.EndpointAuthApiValue is string apiValue) { - if (action.EndpointAuthApiKeyAddTo == "Header") + if (action.EndpointAuthApiKeyAddTo == ApiKeyLocation.Header) { httpReq.Headers.Add(apiKey, apiValue); }