diff --git a/src/SFA.DAS.EmployerCommitmentsV2.Web.UnitTests/WhenAddingServicesToTheContainer.cs b/src/SFA.DAS.EmployerCommitmentsV2.Web.UnitTests/WhenAddingServicesToTheContainer.cs index 80d16a2a..9ed5eb69 100644 --- a/src/SFA.DAS.EmployerCommitmentsV2.Web.UnitTests/WhenAddingServicesToTheContainer.cs +++ b/src/SFA.DAS.EmployerCommitmentsV2.Web.UnitTests/WhenAddingServicesToTheContainer.cs @@ -124,7 +124,7 @@ private static void SetupServiceCollection(IServiceCollection services) services.AddConfigurationOptions(configuration); services.AddDistributedMemoryCache(); services.AddModelMappings(); - services.AddCommitmentPermissionsApiClient(); + services.AddCommitmentPermissionsApiClient(configuration); services.AddApplicationServices(employerCommitmentsV2Configuration); services.AddModelMappings(); services.AddDasMvc(); diff --git a/src/SFA.DAS.EmployerCommitmentsV2.Web/ServiceRegistrations/CommitmentPermissionsApiClientServiceRegistrations.cs b/src/SFA.DAS.EmployerCommitmentsV2.Web/ServiceRegistrations/CommitmentPermissionsApiClientServiceRegistrations.cs index 83a20aeb..25e81db1 100644 --- a/src/SFA.DAS.EmployerCommitmentsV2.Web/ServiceRegistrations/CommitmentPermissionsApiClientServiceRegistrations.cs +++ b/src/SFA.DAS.EmployerCommitmentsV2.Web/ServiceRegistrations/CommitmentPermissionsApiClientServiceRegistrations.cs @@ -1,15 +1,30 @@ -using SFA.DAS.EmployerCommitmentsV2.Client; +using Microsoft.Extensions.Configuration; +using SFA.DAS.CommitmentsV2.Api.Client.Configuration; +using SFA.DAS.EmployerCommitmentsV2.Client; +using SFA.DAS.EmployerCommitmentsV2.Web.Extensions; namespace SFA.DAS.EmployerCommitmentsV2.Web.ServiceRegistrations; public static class CommitmentPermissionsApiClientServiceRegistrations { - public static IServiceCollection AddCommitmentPermissionsApiClient(this IServiceCollection services) + public static IServiceCollection AddCommitmentPermissionsApiClient(this IServiceCollection services, IConfiguration configuration) { services.AddSingleton(); services.AddSingleton(provider => { - var factory = provider.GetService(); + ICommitmentPermissionsApiClientFactory factory; + + if (configuration.UseLocalRegistry()) + { + var config = provider.GetService(); + var loggerFactory = provider.GetService(); + factory = new LocalDevApiClientFactory(config, loggerFactory); + } + else + { + factory = provider.GetService(); + } + return factory.CreateClient(); }); diff --git a/src/SFA.DAS.EmployerCommitmentsV2.Web/Startup.cs b/src/SFA.DAS.EmployerCommitmentsV2.Web/Startup.cs index 03969c8f..d54317ee 100644 --- a/src/SFA.DAS.EmployerCommitmentsV2.Web/Startup.cs +++ b/src/SFA.DAS.EmployerCommitmentsV2.Web/Startup.cs @@ -46,7 +46,7 @@ public void ConfigureServices(IServiceCollection services) .AddCommitmentsApiClient(_configuration) .AddAccountsApiClient(employerCommitmentsV2Configuration) .AddAuthorizationServices(_configuration) - .AddCommitmentPermissionsApiClient() + .AddCommitmentPermissionsApiClient(_configuration) .AddDasHealthChecks() .AddDasMaMenuConfiguration(_configuration) .AddDasMvc()