Skip to content

Commit

Permalink
Merge branch 'master' into MAP-78-deprecate-cmt-v1-calls
Browse files Browse the repository at this point in the history
  • Loading branch information
VasanthaKasirajan3008 committed Jun 23, 2022
2 parents efc24b6 + 7dd34b8 commit b65d04b
Show file tree
Hide file tree
Showing 45 changed files with 327 additions and 493 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ resources:
- repository: das-platform-building-blocks
type: github
name: SkillsFundingAgency/das-platform-building-blocks
ref: refs/tags/0.4.34
ref: refs/tags/0.4.61
endpoint: SkillsFundingAgency

steps:
Expand Down
2 changes: 0 additions & 2 deletions src/SFA.DAS.EAS.Api/App_Start/WebApiConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public static void Register(HttpConfiguration config)
c.AddRegistry<CommitmentsRegistry>();
c.AddRegistry<ConfigurationRegistry>();
c.AddRegistry<EventsRegistry>();
c.AddRegistry<ExecutionPoliciesRegistry>();
c.AddRegistry<HashingRegistry>();
c.AddRegistry<LoggerRegistry>();
c.AddRegistry<MapperRegistry>();
Expand All @@ -40,7 +39,6 @@ public static void Register(HttpConfiguration config)
c.AddRegistry<ReferenceDataRegistry>();
c.AddRegistry<RepositoriesRegistry>();
c.AddRegistry<TasksRegistry>();
c.AddRegistry<TokenServiceRegistry>();
c.AddRegistry<ValidationRegistry>();
c.AddRegistry<EmployerAccountsApiServiceRegistry>();
c.AddRegistry<DefaultRegistry>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@
<Compile Include="Services\LevyTokenHttpClientMaker.cs" />
<Compile Include="Settings\EmployerAccountsConfiguration.cs" />
<Compile Include="Settings\HashingServiceConfig.cs" />
<Compile Include="Settings\HmrcApiBaseUrlConfig.cs" />
<Compile Include="Settings\IHmrcApiBaseUrlConfig.cs" />
<Compile Include="Settings\HmrcApiClientConfiguration.cs" />
<Compile Include="Settings\IHmrcApiClientConfiguration.cs" />
<Compile Include="Settings\ILevySubmissionsSettings.cs" />
<Compile Include="Settings\LevySubmissionsApiConfiguration.cs" />
<Compile Include="Settings\LevySubmissionsSettings.cs" />
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -114,7 +113,7 @@
<Version>1.2.1</Version>
</PackageReference>
<PackageReference Include="SFA.DAS.TokenService.Api.Client">
<Version>2.1.1</Version>
<Version>2.3.0</Version>
</PackageReference>
<PackageReference Include="StructureMap">
<Version>4.7.1</Version>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
using HMRC.ESFA.Levy.Api.Client;
using SFA.DAS.EAS.Support.Infrastructure.Settings;
using SFA.DAS.TokenService.Api.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

namespace SFA.DAS.EAS.Support.Infrastructure.Services
{
public class LevyTokenHttpClientMaker: ILevyTokenHttpClientFactory
{
private readonly IHmrcApiBaseUrlConfig _hmrcApiBaseUrlConfig;
private readonly ITokenServiceApiClientConfiguration _levySubmissionsApiConfiguration;
private readonly IHmrcApiClientConfiguration _hmrcApiBaseUrlConfig;
private readonly ITokenServiceApiClient _tokenServiceApiClient;

public LevyTokenHttpClientMaker(ITokenServiceApiClientConfiguration levySubmissionsApiConfiguration, IHmrcApiBaseUrlConfig hmrcApiBaseUrlConfig)
public LevyTokenHttpClientMaker(ITokenServiceApiClient tokenServiceApiClient, IHmrcApiClientConfiguration hmrcApiBaseUrlConfig)
{
_hmrcApiBaseUrlConfig = hmrcApiBaseUrlConfig;
_levySubmissionsApiConfiguration = levySubmissionsApiConfiguration;
_tokenServiceApiClient = tokenServiceApiClient;
}

public async Task<IApprenticeshipLevyApiClient> GetLevyHttpClient()
{
var tokenService = new TokenServiceApiClient(_levySubmissionsApiConfiguration);
var tokenResult = await tokenService.GetPrivilegedAccessTokenAsync();
var httpclient = ApprenticeshipLevyApiClient.CreateHttpClient(tokenResult.AccessCode, _hmrcApiBaseUrlConfig.HmrcApiBaseUrl);
var tokenResult = await _tokenServiceApiClient.GetPrivilegedAccessTokenAsync();
var httpclient = ApprenticeshipLevyApiClient.CreateHttpClient(tokenResult.AccessCode, _hmrcApiBaseUrlConfig.ApiBaseUrl);

return new ApprenticeshipLevyApiClient(httpclient);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Newtonsoft.Json;

namespace SFA.DAS.EAS.Support.Infrastructure.Settings
{
public class HmrcApiClientConfiguration : IHmrcApiClientConfiguration
{
[JsonRequired]
public string ApiBaseUrl { get; set; }
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace SFA.DAS.EAS.Support.Infrastructure.Settings
{
public interface IHmrcApiClientConfiguration
{
string ApiBaseUrl { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SFA.DAS.TokenService.Api.Client;

namespace SFA.DAS.EAS.Support.Infrastructure.Settings
{
public interface ILevySubmissionsSettings
{
LevySubmissionsApiConfiguration LevySubmissionsApiConfig { get; set; }
TokenServiceApiClientConfiguration TokenServiceApi { get; set; }

HmrcApiBaseUrlConfig HmrcApiBaseUrlSetting { get; set; }
HmrcApiClientConfiguration HmrcApi { get; set; }

}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SFA.DAS.TokenService.Api.Client;

namespace SFA.DAS.EAS.Support.Infrastructure.Settings
{
public class LevySubmissionsSettings: ILevySubmissionsSettings
public class LevySubmissionsSettings : ILevySubmissionsSettings
{
[JsonRequired] public LevySubmissionsApiConfiguration LevySubmissionsApiConfig { get; set; }
[JsonRequired] public TokenServiceApiClientConfiguration TokenServiceApi { get; set; }

[JsonRequired] public HmrcApiBaseUrlConfig HmrcApiBaseUrlSetting { get; set; }
[JsonRequired] public HmrcApiClientConfiguration HmrcApi { get; set; }
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using SFA.DAS.EAS.Support.Infrastructure.Settings;
using SFA.DAS.EAS.Support.Web.Configuration;
using SFA.DAS.Support.Shared.SiteConnection;
using SFA.DAS.TokenService.Api.Client;
using System;
using System.IO;

Expand Down Expand Up @@ -35,18 +36,15 @@ public void Setup()
},
LevySubmission = new LevySubmissionsSettings
{
HmrcApiBaseUrlSetting = new HmrcApiBaseUrlConfig
{
HmrcApiBaseUrl ="--- configuration value goes here ---"
},
LevySubmissionsApiConfig = new LevySubmissionsApiConfiguration
HmrcApi = new HmrcApiClientConfiguration
{
ApiBaseUrl = "--- configuration value goes here ---"
},
TokenServiceApi = new TokenServiceApiClientConfiguration
{
ApiBaseUrl = "",
ClientId = "",
ClientSecret = "",
IdentifierUri = "",
Tenant = ""
}
ClientSecret = ""
}
},
HashingService = new HashingServiceConfig
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,12 @@ public class DefaultRegistry : Registry

public DefaultRegistry()
{
Scan(
scan =>
{
scan.TheCallingAssembly();
scan.WithDefaultConventions();
scan.With(new ControllerConvention());
});
Scan(s =>
{
s.TheCallingAssembly();
s.WithDefaultConventions();
s.With(new ControllerConvention());
});

WebConfiguration configuration = GetConfiguration();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Web;
using SFA.DAS.EAS.Account.Api.Client;
using SFA.DAS.EAS.Account.Api.Client;
using SFA.DAS.EAS.Support.Infrastructure.DependencyResolution;
using SFA.DAS.EAS.Support.Infrastructure.Services;
using SFA.DAS.EAS.Support.Infrastructure.Settings;
Expand All @@ -9,7 +7,8 @@
using SFA.DAS.NLog.Logger;
using SFA.DAS.TokenService.Api.Client;
using StructureMap;
using StructureMap.Configuration.DSL;
using System.Diagnostics.CodeAnalysis;
using System.Web;

namespace SFA.DAS.EAS.Support.Web.DependencyResolution
{
Expand Down Expand Up @@ -39,26 +38,22 @@ public InfrastuctureRegistry()

For<ILevyTokenHttpClientFactory>().Use<LevyTokenHttpClientMaker>();

For<IHmrcApiBaseUrlConfig>().Use(string.Empty, (ctx) =>
For<IHmrcApiClientConfiguration>().Use(string.Empty, (ctx) =>
{
return ctx.GetInstance<IWebConfiguration>().LevySubmission.HmrcApiBaseUrlSetting;
return ctx.GetInstance<IWebConfiguration>().LevySubmission.HmrcApi;
});

For<ITokenServiceApiClient>().Use<TokenServiceApiClient>();
For<ITokenServiceApiClientConfiguration>().Use(string.Empty, (ctx) =>
{
return ctx.GetInstance<IWebConfiguration>().LevySubmission.LevySubmissionsApiConfig;
return ctx.GetInstance<IWebConfiguration>().LevySubmission.TokenServiceApi;
});


For<IHashingService>().Use(string.Empty, (ctx) =>
{
var hashServiceconfig = ctx.GetInstance<IWebConfiguration>().HashingService;
return new HashingService.HashingService(hashServiceconfig.AllowedCharacters, hashServiceconfig.Hashstring);
});

}



}
}
68 changes: 33 additions & 35 deletions src/SFA.DAS.EAS.Web/DependencyResolution/IoC.cs
Original file line number Diff line number Diff line change
@@ -1,38 +1,36 @@
using SFA.DAS.Activities.Client;
using SFA.DAS.EAS.Application.DependencyResolution;
using StructureMap;
using SFA.DAS.Activities.Client;
using SFA.DAS.EAS.Application.DependencyResolution;
using StructureMap;
using SFA.DAS.Authorization.DependencyResolution.StructureMap;

namespace SFA.DAS.EAS.Web.DependencyResolution
{
public static class IoC
{
public static IContainer Initialize()
{
return new Container(c =>
{
c.AddRegistry<ActivitiesClientRegistry>();
c.AddRegistry<AuditRegistry>();
c.AddRegistry<AuthorizationRegistry>();
c.AddRegistry<CachesRegistry>();
c.AddRegistry<CommitmentsRegistry>();
c.AddRegistry<ConfigurationRegistry>();
c.AddRegistry<DataRegistry>();
c.AddRegistry<EventsRegistry>();
c.AddRegistry<ExecutionPoliciesRegistry>();
c.AddRegistry<HashingRegistry>();
c.AddRegistry<LoggerRegistry>();
c.AddRegistry<MapperRegistry>();
c.AddRegistry<MediatorRegistry>();
c.AddRegistry<MessagePublisherRegistry>();
c.AddRegistry<NotificationsRegistry>();
c.AddRegistry<ReferenceDataRegistry>();
c.AddRegistry<RepositoriesRegistry>();
c.AddRegistry<TasksRegistry>();
c.AddRegistry<TokenServiceRegistry>();
c.AddRegistry<ValidationRegistry>();
c.AddRegistry<DefaultRegistry>();
});
}
}
namespace SFA.DAS.EAS.Web.DependencyResolution
{
public static class IoC
{
public static IContainer Initialize()
{
return new Container(c =>
{
c.AddRegistry<ActivitiesClientRegistry>();
c.AddRegistry<AuditRegistry>();
c.AddRegistry<AuthorizationRegistry>();
c.AddRegistry<CachesRegistry>();
c.AddRegistry<CommitmentsRegistry>();
c.AddRegistry<ConfigurationRegistry>();
c.AddRegistry<DataRegistry>();
c.AddRegistry<EventsRegistry>();
c.AddRegistry<HashingRegistry>();
c.AddRegistry<LoggerRegistry>();
c.AddRegistry<MapperRegistry>();
c.AddRegistry<MediatorRegistry>();
c.AddRegistry<MessagePublisherRegistry>();
c.AddRegistry<NotificationsRegistry>();
c.AddRegistry<ReferenceDataRegistry>();
c.AddRegistry<RepositoriesRegistry>();
c.AddRegistry<TasksRegistry>();
c.AddRegistry<ValidationRegistry>();
c.AddRegistry<DefaultRegistry>();
});
}
}
}
Loading

0 comments on commit b65d04b

Please sign in to comment.