-
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 branch 'main' of github.com:ShipEngine/shipengine-dotnet into E…
…NGINE-7190-funding-sources-wallet-errors
- Loading branch information
Showing
10 changed files
with
267 additions
and
24 deletions.
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
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 |
---|---|---|
|
@@ -29,6 +29,18 @@ public enum InsuranceProvider | |
/// The package is insured by a third-party insurance service, outside of ShipEngine. | ||
/// </summary> | ||
[EnumMember(Value = "third_party")] | ||
ThirdParty | ||
ThirdParty, | ||
|
||
/// <summary> | ||
/// This option will assign the insurance provider available with ShipEngine Carriers to the shipment (currently ParcelGuard). The response will auto-populate the insurance_provider field with parcelguard. | ||
/// </summary> | ||
[EnumMember(Value = "funding_source")] | ||
FundingSource, | ||
Check warning on line 38 in ShipEngineSDK/Models/Dto/Common/Enums/InsuranceProvider.cs GitHub Actions / .Net 8.0 on windows-latest
|
||
|
||
/// <summary> | ||
/// This option will assign ParcelGuard as the insurance provider for the shipment. Using this value is functionally the same as using the 'funding_source' value. | ||
/// </summary> | ||
[EnumMember(Value = "parcelguard")] | ||
ParcelGuard | ||
Check warning on line 44 in ShipEngineSDK/Models/Dto/Common/Enums/InsuranceProvider.cs GitHub Actions / .Net 8.0 on windows-latest
Check warning on line 44 in ShipEngineSDK/Models/Dto/Common/Enums/InsuranceProvider.cs GitHub Actions / .Net 8.0 on windows-latest
|
||
} | ||
} |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
using ShipEngineSDK.Common; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Net.Http; | ||
|
@@ -19,6 +20,20 @@ namespace ShipEngineSDK | |
/// </summary> | ||
public class ShipEngineClient | ||
{ | ||
/// <summary> | ||
/// Default constructor | ||
/// </summary> | ||
public ShipEngineClient() { } | ||
|
||
/// <summary> | ||
/// Constructor that takes a collection of request modifiers to apply to the request before it is sent | ||
/// </summary> | ||
/// <param name="requestModifiers">Collection of modifiers to be used for each request</param> | ||
protected ShipEngineClient(IEnumerable<Action<HttpRequestMessage>> requestModifiers) | ||
{ | ||
this.requestModifiers = requestModifiers; | ||
} | ||
|
||
/// <summary> | ||
/// Options for serializing the method call params to JSON. | ||
/// A separate inline setting is used for deserializing the response | ||
|
@@ -46,9 +61,13 @@ public class ShipEngineClient | |
public CancellationToken CancellationToken { get; set; } | ||
|
||
/// <summary> | ||
/// Modifies the client request before it is sent | ||
/// Collections of request modifiers to apply to the request before it is sent | ||
/// </summary> | ||
public Action<HttpRequestMessage>? ModifyRequest { get; set; } | ||
/// <remarks> | ||
/// This is a collection instead of a single action so that modifiers can be added at multiple levels. | ||
/// For example, a consumer could add a modifier at the client level, and then add another at the method level. | ||
/// </remarks> | ||
protected IEnumerable<Action<HttpRequestMessage>> requestModifiers = []; | ||
Check warning on line 70 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 | ||
|
@@ -209,7 +228,10 @@ public virtual async Task<T> SendHttpRequestAsync<T>(HttpMethod method, string p | |
try | ||
{ | ||
var request = BuildRequest(method, path, jsonContent); | ||
ModifyRequest?.Invoke(request); | ||
foreach (var modifier in requestModifiers ?? []) | ||
{ | ||
modifier?.Invoke(request); | ||
} | ||
response = await client.SendAsync(request, cancellationToken); | ||
|
||
var deserializedResult = await DeserializedResultOrThrow<T>(response); | ||
|
Oops, something went wrong.