From 9488813294cd41e5d482fab4f56e8610431d10c6 Mon Sep 17 00:00:00 2001 From: Joe Pill Date: Mon, 22 Jul 2024 14:53:33 -0500 Subject: [PATCH] feat: modify request --- ShipEngineSDK/ShipEngine.cs | 11 +++++++++++ ShipEngineSDK/ShipEngineClient.cs | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/ShipEngineSDK/ShipEngine.cs b/ShipEngineSDK/ShipEngine.cs index f08206e7..13dc1e37 100644 --- a/ShipEngineSDK/ShipEngine.cs +++ b/ShipEngineSDK/ShipEngine.cs @@ -225,6 +225,17 @@ public ShipEngine(HttpClient httpClient) : base() _client = httpClient; } + /// + /// Modifies the request before it is sent to the ShipEngine API + /// + /// + /// + public ShipEngine ModifyRequest(Action modifyRequest) + { + base.ModifyRequest = modifyRequest; + return this; + } + /// /// Dispose of the ShipEngine client /// diff --git a/ShipEngineSDK/ShipEngineClient.cs b/ShipEngineSDK/ShipEngineClient.cs index 2e6b1201..5e7aa861 100644 --- a/ShipEngineSDK/ShipEngineClient.cs +++ b/ShipEngineSDK/ShipEngineClient.cs @@ -45,6 +45,11 @@ public class ShipEngineClient /// public CancellationToken CancellationToken { get; set; } + /// + /// Modifies the client request before it is sent + /// + public Action? ModifyRequest { get; set; } + /// /// Sets the HttpClient User agent, the json media type, and the API key to be used /// for all ShipEngine API calls unless overrwritten at the method level. @@ -199,6 +204,7 @@ public virtual async Task SendHttpRequestAsync(HttpMethod method, string p try { var request = BuildRequest(method, path, jsonContent); + ModifyRequest?.Invoke(request); response = await client.SendAsync(request, cancellationToken); var deserializedResult = await DeserializedResultOrThrow(response);