Skip to content

Commit

Permalink
Merge pull request #46 from easykeys/feature/fedex/openapis
Browse files Browse the repository at this point in the history
Update FedEx API integration and refactor related classes
  • Loading branch information
ucrengineer authored May 10, 2024
2 parents a8760e1 + 247a34e commit a76d7da
Show file tree
Hide file tree
Showing 134 changed files with 39,149 additions and 2,507 deletions.
2 changes: 1 addition & 1 deletion GitVersion.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mode: Mainline
next-version: 4.1.0
next-version: 4.2.0
branches:
feature:
tag: preview
Expand Down
2 changes: 1 addition & 1 deletion build/dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</ItemGroup>

<ItemGroup Label="Others">
<PackageReference Update="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Update="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Update="Ardalis.SmartEnum" Version="7.0.*" />
<PackageReference Update="Swashbuckle.AspNetCore" Version="6.5.*" />
<PackageReference Update="Humanizer" Version="2.14.1" />
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using EasyKeys.Shipping.FedEx.Abstractions.Api.V1.Auth;
using EasyKeys.Shipping.FedEx.Abstractions.Api.V1.Auth.Impl;
using EasyKeys.Shipping.FedEx.Abstractions.Middleware;
using EasyKeys.Shipping.FedEx.Abstractions.Middleware;
using EasyKeys.Shipping.FedEx.Abstractions.OpenApis.V1.AddressValidation;
using EasyKeys.Shipping.FedEx.Abstractions.OpenApis.V1.Authorization;
using EasyKeys.Shipping.FedEx.Abstractions.OpenApis.V1.RatesAndTransitTimes;
using EasyKeys.Shipping.FedEx.Abstractions.OpenApis.V1.Ship;
using EasyKeys.Shipping.FedEx.Abstractions.Options;
using EasyKeys.Shipping.FedEx.Abstractions.Services;
using EasyKeys.Shipping.FedEx.Abstractions.Services.Impl;
Expand Down Expand Up @@ -31,21 +33,25 @@ public static IServiceCollection AddFedExClient(
}

/// <summary>
/// Adds <see cref="IFedExAuthClient"/> and <see cref="AuthRequestMiddleware"/> with configuration options <see cref="FedExApiOptions"/>.
/// Adds <see cref="AuthorizationApi"/>, <see cref="AddressValidationApi"/>, <see cref="RatesAndTransientTimesApi"/>,<see cref="ShipApi"/>,<see cref="IFedexApiAuthenticatorService"/> with configuration options <see cref="FedExApiOptions"/>.
/// </summary>
/// <param name="services">The DI services.</param>
/// <param name="sectionName">The section name for the options.</param>
/// <param name="configure">The configuration of options.</param>
/// <returns></returns>
public static IServiceCollection AddFedExAuthApiClient(
public static IServiceCollection AddFedExApiClients(
this IServiceCollection services,
string sectionName = nameof(FedExApiOptions),
Action<FedExApiOptions, IServiceProvider>? configure = null)
{
services.AddChangeTokenOptions<FedExApiOptions>(sectionName, null, (options, config) => configure?.Invoke(options, config));
services.AddHttpClient(name: nameof(IFedExAuthClient));
services.AddTransient<AuthRequestMiddleware>();
services.AddSingleton<IFedExAuthClient, FedExAuthClient>();
services.AddSingleton<IFedexApiAuthenticatorService, FedexApiAuthenticatorService>();

// add generated api clients
services.AddHttpClient<AuthorizationApi>();
services.AddHttpClient<AddressValidationApi>();
services.AddHttpClient<RatesAndTransientTimesApi>();
services.AddHttpClient<ShipApi>();

return services;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,30 @@
<Description>DotNetCore Implementation of FedEx Authorization Api and Web Services 2020 of WCF.</Description>
<PackageTags>DotNetCore, FedEx 2020 WCF, FedEx v1 API, FedEx Authorization Api</PackageTags>
</PropertyGroup>
<ItemGroup>
<None Remove="OpenApis\authorization.json" />
<None Remove="OpenApis\V1\AddressValidation\address-validation.json" />
<None Remove="OpenApis\V1\RatesAndTransitTimes\rate.json" />
<None Remove="OpenApis\V1\Ship\ship.json" />
</ItemGroup>
<ItemGroup>
<OpenApiReference Include="OpenApis\V1\AddressValidation\address-validation.json" CodeGenerator="NSwagCSharp" ClassName="AddressValidationApi" />
<OpenApiReference Include="OpenApis\V1\Authorization\authorization.json" CodeGenerator="NSwagCSharp" ClassName="AuthorizationApi" />
<OpenApiReference Include="OpenApis\V1\RatesAndTransitTimes\rate.json" CodeGenerator="NSwagCSharp" ClassName="RatesAndTransitTimesApi" />
<OpenApiReference Include="OpenApis\V1\Ship\ship.json" CodeGenerator="NSwagCSharp" ClassName="ShipApi" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Ardalis.SmartEnum" />
<PackageReference Include="Microsoft.Extensions.ApiDescription.Client" Version="7.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NSwag.ApiDescription.Client" Version="13.18.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.ServiceModel.Http" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using System.IO.Compression;
using System.Net;
using System.Text;

using EasyKeys.Shipping.FedEx.Abstractions.Api.V1.Auth;
using EasyKeys.Shipping.FedEx.Abstractions.Services;

using Microsoft.Extensions.Logging;

Expand All @@ -13,11 +12,11 @@ namespace EasyKeys.Shipping.FedEx.Abstractions.Middleware;
/// </summary>
public class AuthRequestMiddleware : DelegatingHandler
{
private readonly IFedExAuthClient _authClient;
private readonly IFedexApiAuthenticatorService _authClient;
private ILogger<AuthRequestMiddleware> _logger;

public AuthRequestMiddleware(
IFedExAuthClient authClient,
IFedexApiAuthenticatorService authClient,
ILogger<AuthRequestMiddleware> logger)
{
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
Expand Down
Loading

0 comments on commit a76d7da

Please sign in to comment.