Skip to content

Commit 27cef49

Browse files
authored
Merge pull request #63 from easykeys/develop
Develop - dhl openapi clients + expanded dotnet core frameworks
2 parents 7d60f79 + a22a69c commit 27cef49

File tree

47 files changed

+39405
-55
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+39405
-55
lines changed

EasyKeys.Shipping.sln

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyKeys.Shipping.Amazon.Ra
8989
EndProject
9090
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyKeys.Shipping.Amazon.Shipment", "src\EasyKeys.Shipping.Amazon.Shipment\EasyKeys.Shipping.Amazon.Shipment.csproj", "{8B109CC8-6252-4668-983F-B0877710827C}"
9191
EndProject
92+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DHL", "DHL", "{BC400693-827F-43C7-AD98-A9FC1E97ADD2}"
93+
EndProject
94+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyKeys.Shipping.DHL.Abstractions", "src\EasyKeys.Shipping.DHL.Abstractions\EasyKeys.Shipping.DHL.Abstractions.csproj", "{C3DB5200-3A61-4DB7-9634-E0A0AE04F5C3}"
95+
EndProject
96+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyKeys.Shipping.DHL.AddressValidation", "src\EasyKeys.Shipping.DHL.AddressValidation\EasyKeys.Shipping.DHL.AddressValidation.csproj", "{C7E38E01-C85D-4EB6-8968-BA0847F5FD1C}"
97+
EndProject
98+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyKeys.Shipping.DHL.Rates", "src\EasyKeys.Shipping.DHL.Rates\EasyKeys.Shipping.DHL.Rates.csproj", "{F7B0AA74-1B52-4979-A5D3-6A2D477C6EEE}"
99+
EndProject
100+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyKeys.Shipping.DHL.Shipment", "src\EasyKeys.Shipping.DHL.Shipment\EasyKeys.Shipping.DHL.Shipment.csproj", "{898E8B73-FBD3-447A-93D2-58D8E837678A}"
101+
EndProject
92102
Global
93103
GlobalSection(SolutionConfigurationPlatforms) = preSolution
94104
Debug|Any CPU = Debug|Any CPU
@@ -387,6 +397,54 @@ Global
387397
{8B109CC8-6252-4668-983F-B0877710827C}.Release|x64.Build.0 = Release|Any CPU
388398
{8B109CC8-6252-4668-983F-B0877710827C}.Release|x86.ActiveCfg = Release|Any CPU
389399
{8B109CC8-6252-4668-983F-B0877710827C}.Release|x86.Build.0 = Release|Any CPU
400+
{C3DB5200-3A61-4DB7-9634-E0A0AE04F5C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
401+
{C3DB5200-3A61-4DB7-9634-E0A0AE04F5C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
402+
{C3DB5200-3A61-4DB7-9634-E0A0AE04F5C3}.Debug|x64.ActiveCfg = Debug|Any CPU
403+
{C3DB5200-3A61-4DB7-9634-E0A0AE04F5C3}.Debug|x64.Build.0 = Debug|Any CPU
404+
{C3DB5200-3A61-4DB7-9634-E0A0AE04F5C3}.Debug|x86.ActiveCfg = Debug|Any CPU
405+
{C3DB5200-3A61-4DB7-9634-E0A0AE04F5C3}.Debug|x86.Build.0 = Debug|Any CPU
406+
{C3DB5200-3A61-4DB7-9634-E0A0AE04F5C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
407+
{C3DB5200-3A61-4DB7-9634-E0A0AE04F5C3}.Release|Any CPU.Build.0 = Release|Any CPU
408+
{C3DB5200-3A61-4DB7-9634-E0A0AE04F5C3}.Release|x64.ActiveCfg = Release|Any CPU
409+
{C3DB5200-3A61-4DB7-9634-E0A0AE04F5C3}.Release|x64.Build.0 = Release|Any CPU
410+
{C3DB5200-3A61-4DB7-9634-E0A0AE04F5C3}.Release|x86.ActiveCfg = Release|Any CPU
411+
{C3DB5200-3A61-4DB7-9634-E0A0AE04F5C3}.Release|x86.Build.0 = Release|Any CPU
412+
{C7E38E01-C85D-4EB6-8968-BA0847F5FD1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
413+
{C7E38E01-C85D-4EB6-8968-BA0847F5FD1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
414+
{C7E38E01-C85D-4EB6-8968-BA0847F5FD1C}.Debug|x64.ActiveCfg = Debug|Any CPU
415+
{C7E38E01-C85D-4EB6-8968-BA0847F5FD1C}.Debug|x64.Build.0 = Debug|Any CPU
416+
{C7E38E01-C85D-4EB6-8968-BA0847F5FD1C}.Debug|x86.ActiveCfg = Debug|Any CPU
417+
{C7E38E01-C85D-4EB6-8968-BA0847F5FD1C}.Debug|x86.Build.0 = Debug|Any CPU
418+
{C7E38E01-C85D-4EB6-8968-BA0847F5FD1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
419+
{C7E38E01-C85D-4EB6-8968-BA0847F5FD1C}.Release|Any CPU.Build.0 = Release|Any CPU
420+
{C7E38E01-C85D-4EB6-8968-BA0847F5FD1C}.Release|x64.ActiveCfg = Release|Any CPU
421+
{C7E38E01-C85D-4EB6-8968-BA0847F5FD1C}.Release|x64.Build.0 = Release|Any CPU
422+
{C7E38E01-C85D-4EB6-8968-BA0847F5FD1C}.Release|x86.ActiveCfg = Release|Any CPU
423+
{C7E38E01-C85D-4EB6-8968-BA0847F5FD1C}.Release|x86.Build.0 = Release|Any CPU
424+
{F7B0AA74-1B52-4979-A5D3-6A2D477C6EEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
425+
{F7B0AA74-1B52-4979-A5D3-6A2D477C6EEE}.Debug|Any CPU.Build.0 = Debug|Any CPU
426+
{F7B0AA74-1B52-4979-A5D3-6A2D477C6EEE}.Debug|x64.ActiveCfg = Debug|Any CPU
427+
{F7B0AA74-1B52-4979-A5D3-6A2D477C6EEE}.Debug|x64.Build.0 = Debug|Any CPU
428+
{F7B0AA74-1B52-4979-A5D3-6A2D477C6EEE}.Debug|x86.ActiveCfg = Debug|Any CPU
429+
{F7B0AA74-1B52-4979-A5D3-6A2D477C6EEE}.Debug|x86.Build.0 = Debug|Any CPU
430+
{F7B0AA74-1B52-4979-A5D3-6A2D477C6EEE}.Release|Any CPU.ActiveCfg = Release|Any CPU
431+
{F7B0AA74-1B52-4979-A5D3-6A2D477C6EEE}.Release|Any CPU.Build.0 = Release|Any CPU
432+
{F7B0AA74-1B52-4979-A5D3-6A2D477C6EEE}.Release|x64.ActiveCfg = Release|Any CPU
433+
{F7B0AA74-1B52-4979-A5D3-6A2D477C6EEE}.Release|x64.Build.0 = Release|Any CPU
434+
{F7B0AA74-1B52-4979-A5D3-6A2D477C6EEE}.Release|x86.ActiveCfg = Release|Any CPU
435+
{F7B0AA74-1B52-4979-A5D3-6A2D477C6EEE}.Release|x86.Build.0 = Release|Any CPU
436+
{898E8B73-FBD3-447A-93D2-58D8E837678A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
437+
{898E8B73-FBD3-447A-93D2-58D8E837678A}.Debug|Any CPU.Build.0 = Debug|Any CPU
438+
{898E8B73-FBD3-447A-93D2-58D8E837678A}.Debug|x64.ActiveCfg = Debug|Any CPU
439+
{898E8B73-FBD3-447A-93D2-58D8E837678A}.Debug|x64.Build.0 = Debug|Any CPU
440+
{898E8B73-FBD3-447A-93D2-58D8E837678A}.Debug|x86.ActiveCfg = Debug|Any CPU
441+
{898E8B73-FBD3-447A-93D2-58D8E837678A}.Debug|x86.Build.0 = Debug|Any CPU
442+
{898E8B73-FBD3-447A-93D2-58D8E837678A}.Release|Any CPU.ActiveCfg = Release|Any CPU
443+
{898E8B73-FBD3-447A-93D2-58D8E837678A}.Release|Any CPU.Build.0 = Release|Any CPU
444+
{898E8B73-FBD3-447A-93D2-58D8E837678A}.Release|x64.ActiveCfg = Release|Any CPU
445+
{898E8B73-FBD3-447A-93D2-58D8E837678A}.Release|x64.Build.0 = Release|Any CPU
446+
{898E8B73-FBD3-447A-93D2-58D8E837678A}.Release|x86.ActiveCfg = Release|Any CPU
447+
{898E8B73-FBD3-447A-93D2-58D8E837678A}.Release|x86.Build.0 = Release|Any CPU
390448
EndGlobalSection
391449
GlobalSection(SolutionProperties) = preSolution
392450
HideSolutionNode = FALSE
@@ -421,6 +479,11 @@ Global
421479
{3B6980FA-333A-46AD-9F33-0D9BFBD853A8} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
422480
{3668E9A5-CB31-4FC9-9918-B5046B67651A} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
423481
{8B109CC8-6252-4668-983F-B0877710827C} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
482+
{BC400693-827F-43C7-AD98-A9FC1E97ADD2} = {BCBBDD1A-FF30-41E8-B7C1-9BB2A441FF83}
483+
{C3DB5200-3A61-4DB7-9634-E0A0AE04F5C3} = {BC400693-827F-43C7-AD98-A9FC1E97ADD2}
484+
{C7E38E01-C85D-4EB6-8968-BA0847F5FD1C} = {BC400693-827F-43C7-AD98-A9FC1E97ADD2}
485+
{F7B0AA74-1B52-4979-A5D3-6A2D477C6EEE} = {BC400693-827F-43C7-AD98-A9FC1E97ADD2}
486+
{898E8B73-FBD3-447A-93D2-58D8E837678A} = {BC400693-827F-43C7-AD98-A9FC1E97ADD2}
424487
EndGlobalSection
425488
GlobalSection(ExtensibilityGlobals) = postSolution
426489
SolutionGuid = {0FBE81B8-162F-4342-BABD-0FFFD0C99331}

GitVersion.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
mode: ContinuousDelivery
2-
next-version: 6.1.1
2+
next-version: 6.2.0
33
increment: Patch
44
major-version-bump-message: '\+semver:\s?(breaking|major|release)'
55
minor-version-bump-message: '\+semver:\s?(feat|feature|minor)'

build/dependencies.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
<ItemGroup Label="Others">
4747
<PackageReference Update="Newtonsoft.Json" Version="13.0.1" />
48-
<PackageReference Update="Ardalis.SmartEnum" Version="7.0.*" />
48+
<PackageReference Update="Ardalis.SmartEnum" Version="2.1.0" />
4949
<PackageReference Update="Swashbuckle.AspNetCore" Version="6.5.*" />
5050
<PackageReference Update="Humanizer" Version="2.14.1" />
5151
</ItemGroup>

src/EasyKeys.Shipping.Abstractions/EasyKeys.Shipping.Abstractions.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net8.0</TargetFrameworks>
4-
</PropertyGroup>
3+
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
4+
</PropertyGroup>
55
<PropertyGroup Label="Nuget Package Settings">
66
<Description>DotNetCore Abstractions of Shipment Library.</Description>
77
<PackageTags>DotNetCore, Shipment Abstractions</PackageTags>

src/EasyKeys.Shipping.Amazon.Abstractions/EasyKeys.Shipping.Amazon.Abstractions.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
5-
<ImplicitUsings>enable</ImplicitUsings>
4+
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
5+
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
</PropertyGroup>
88
<PropertyGroup Label="Nuget Package Settings">

src/EasyKeys.Shipping.Amazon.Abstractions/Services/IAmazonApiAuthenticatorService.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,24 @@ public interface IAmazonApiAuthenticatorService
1111
Task<string> GetTokenAsync(CancellationToken cancellationToken = default);
1212
}
1313

14-
public record AmazonToken(string access_token, string refresh_token, string token_type, int expires_in);
14+
public class AmazonToken
15+
{
16+
#pragma warning disable SA1300 // Element should begin with upper-case letter
17+
public string access_token { get; set; }
18+
19+
public string refresh_token { get; set; }
20+
21+
public string token_type { get; set; }
22+
23+
public int expires_in { get; set; }
24+
25+
#pragma warning restore SA1300 // Element should begin with upper-case letter
26+
27+
public AmazonToken(string access_token, string refresh_token, string token_type, int expires_in)
28+
{
29+
this.access_token = access_token;
30+
this.refresh_token = refresh_token;
31+
this.token_type = token_type;
32+
this.expires_in = expires_in;
33+
}
34+
}

src/EasyKeys.Shipping.Amazon.Abstractions/Services/Impl/AmazonApiAuthenticatorService.cs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Collections.Concurrent;
2-
using System.Net.Http.Json;
32

43
using EasyKeys.Shipping.Amazon.Abstractions.OpenApis.V2.Shipping;
54
using EasyKeys.Shipping.Amazon.Abstractions.Options;
@@ -12,19 +11,16 @@ namespace EasyKeys.Shipping.Amazon.Abstractions.Services.Impl;
1211

1312
public class AmazonApiAuthenticatorService : IAmazonApiAuthenticatorService
1413
{
15-
private readonly AmazonShippingApi _httpClient;
1614
private readonly AmazonShippingApiOptions _options;
1715
private readonly ILogger<AmazonApiAuthenticatorService> _logger;
1816
private readonly ConcurrentDictionary<string, string> _token = new();
1917
private readonly ConcurrentDictionary<string, DateTimeOffset> _expirationClock = new();
2018

2119
public AmazonApiAuthenticatorService(
22-
AmazonShippingApi httpClient,
2320
IOptionsMonitor<AmazonShippingApiOptions> optionsMonitor,
2421
ILogger<AmazonApiAuthenticatorService> logger)
2522
{
2623
_options = optionsMonitor.CurrentValue;
27-
_httpClient = httpClient;
2824
_logger = logger;
2925
}
3026

@@ -35,7 +31,12 @@ public async Task<string> GetTokenAsync(CancellationToken cancellationToken = de
3531
if (DateTimeOffset.Now < _expirationClock.GetValueOrDefault(nameof(_expirationClock)))
3632
{
3733
_token.TryGetValue(nameof(AmazonToken), out var existingToken);
38-
ArgumentNullException.ThrowIfNull(existingToken, nameof(AmazonToken));
34+
35+
if (existingToken == null)
36+
{
37+
throw new ArgumentNullException(nameof(existingToken), "Token is null or expired.");
38+
}
39+
3940
return existingToken;
4041
}
4142

@@ -57,17 +58,21 @@ public async Task<string> GetTokenAsync(CancellationToken cancellationToken = de
5758
}),
5859
};
5960
var response = await client.SendAsync(request);
60-
var token = await response.Content.ReadFromJsonAsync<AmazonToken>();
61+
var token = await response.Content.ReadAsStringAsync();
62+
var tokenResult = System.Text.Json.JsonSerializer.Deserialize<AmazonToken>(token);
6163

6264
_logger.LogDebug("[Amazon][CreateToken] - authentication token returned {createdToken}", token);
6365

64-
ArgumentNullException.ThrowIfNull(token, nameof(AmazonToken));
66+
if (tokenResult == null)
67+
{
68+
throw new ArgumentNullException(nameof(tokenResult), "Token result is null.");
69+
}
6570

66-
_token.AddOrUpdate(nameof(AmazonToken), $"{token.access_token}", (x, y) => $"{token.access_token}");
71+
_token.AddOrUpdate(nameof(AmazonToken), $"{tokenResult.access_token}", (x, y) => $"{tokenResult.access_token}");
6772

68-
_expirationClock.AddOrUpdate(nameof(_expirationClock), (x) => DateTimeOffset.Now.AddSeconds(token.expires_in - 5), (x, y) => y.AddMilliseconds(token.expires_in - 5));
73+
_expirationClock.AddOrUpdate(nameof(_expirationClock), (x) => DateTimeOffset.Now.AddSeconds(tokenResult.expires_in - 5), (x, y) => y.AddMilliseconds(tokenResult.expires_in - 5));
6974

70-
return token.access_token;
75+
return tokenResult.access_token;
7176
}
7277
catch (Exception ex)
7378
{

src/EasyKeys.Shipping.Amazon.Rates/EasyKeys.Shipping.Amazon.Rates.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
5-
<ImplicitUsings>enable</ImplicitUsings>
4+
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
5+
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
</PropertyGroup>
88
<PropertyGroup Label="Nuget Package Settings">

src/EasyKeys.Shipping.Amazon.Shipment/EasyKeys.Shipping.Amazon.Shipment.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
5-
<ImplicitUsings>enable</ImplicitUsings>
4+
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
5+
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
</PropertyGroup>
88
<PropertyGroup Label="Nuget Package Settings">

0 commit comments

Comments
 (0)