diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f832f28..ab0f9f47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -164,3 +164,7 @@ Updated nuget package dependencies ### Changed Fixed handling of No Content responses + +### Added + +- Added basic ability to modify the HttpClient in a request 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 9d72508d..62163ccb 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. @@ -204,6 +209,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); diff --git a/package.json b/package.json index 2975d10c..2239a9bb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "shipengine-dotnet", - "version": "2.2.0", + "version": "2.2.1", "description": "Package primarily used to generate the API and models from OpenApi spec\"", "main": "index.js", "directories": {