-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from ShipEngine/jpill/modify-request-from-client
feat: allow modify request
- Loading branch information
Showing
4 changed files
with
22 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,11 @@ public class ShipEngineClient | |
/// </summary> | ||
public CancellationToken CancellationToken { get; set; } | ||
|
||
/// <summary> | ||
/// Modifies the client request before it is sent | ||
/// </summary> | ||
public Action<HttpRequestMessage>? ModifyRequest { get; set; } | ||
Check warning on line 51 in ShipEngineSDK/ShipEngineClient.cs GitHub Actions / .Net 8.0 on windows-latest
|
||
|
||
/// <summary> | ||
/// 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<T> SendHttpRequestAsync<T>(HttpMethod method, string p | |
try | ||
{ | ||
var request = BuildRequest(method, path, jsonContent); | ||
ModifyRequest?.Invoke(request); | ||
response = await client.SendAsync(request, cancellationToken); | ||
|
||
var deserializedResult = await DeserializedResultOrThrow<T>(response); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters