-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into CON-2087-Api
- Loading branch information
Showing
10 changed files
with
85 additions
and
18 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
37 changes: 37 additions & 0 deletions
37
src/SFA.DAS.CommitmentPayments.WebJob/DependencyResolution/PaymentsRegistry.cs
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System.Net.Http; | ||
using SFA.DAS.CommitmentPayments.WebJob.Configuration; | ||
using SFA.DAS.Http; | ||
using SFA.DAS.Http.TokenGenerators; | ||
using SFA.DAS.NLog.Logger.Web.MessageHandlers; | ||
using SFA.DAS.Provider.Events.Api.Client; | ||
using SFA.DAS.Provider.Events.Api.Client.Configuration; | ||
using StructureMap; | ||
|
||
namespace SFA.DAS.CommitmentPayments.WebJob.DependencyResolution | ||
{ | ||
internal class PaymentsRegistry : Registry | ||
{ | ||
public PaymentsRegistry() | ||
{ | ||
For<PaymentEventsApi>().Use(c => c.GetInstance<CommitmentPaymentsConfiguration>().PaymentEventsApi); | ||
For<IPaymentsEventsApiConfiguration>().Use(c => c.GetInstance<PaymentEventsApi>()); | ||
For<IPaymentsEventsApiClient>().Use<PaymentsEventsApiClient>().Ctor<HttpClient>().Is(c => CreateClient(c)); | ||
} | ||
|
||
private HttpClient CreateClient(IContext context) | ||
{ | ||
var config = context.GetInstance<CommitmentPaymentsConfiguration>().PaymentEventsApi; | ||
|
||
HttpClient httpClient = new HttpClientBuilder() | ||
.WithBearerAuthorisationHeader(new AzureActiveDirectoryBearerTokenGenerator(config)) | ||
.WithHandler(new RequestIdMessageRequestHandler()) | ||
.WithHandler(new SessionIdMessageRequestHandler()) | ||
.WithDefaultHeaders() | ||
.Build(); | ||
|
||
httpClient.DefaultRequestHeaders.Add("api-version", "2"); | ||
|
||
return httpClient; | ||
} | ||
} | ||
} |
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
36 changes: 36 additions & 0 deletions
36
...A.DAS.Commitments.AddEpaToApprenticeships.WebJob/DependencyResolution/PaymentsRegistry.cs
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Net.Http; | ||
using SFA.DAS.Commitments.AddEpaToApprenticeships.WebJob.Configuration; | ||
using SFA.DAS.Http; | ||
using SFA.DAS.Http.TokenGenerators; | ||
using SFA.DAS.NLog.Logger.Web.MessageHandlers; | ||
using SFA.DAS.Provider.Events.Api.Client; | ||
using SFA.DAS.Provider.Events.Api.Client.Configuration; | ||
using StructureMap; | ||
|
||
namespace SFA.DAS.Commitments.AddEpaToApprenticeships.WebJob.DependencyResolution | ||
{ | ||
internal class PaymentsRegistry : Registry | ||
{ | ||
public PaymentsRegistry() | ||
{ | ||
For<PaymentEventsApi>().Use(c => c.GetInstance<AddEpaToApprenticeshipsConfiguration>().PaymentEventsApi); | ||
For<IPaymentsEventsApiConfiguration>().Use(c => c.GetInstance<PaymentEventsApi>()); | ||
For<IPaymentsEventsApiClient>().Use<PaymentsEventsApiClient>().Ctor<HttpClient>().Is(c => CreateClient(c)); | ||
} | ||
|
||
private HttpClient CreateClient(IContext context) | ||
{ | ||
var config = context.GetInstance<AddEpaToApprenticeshipsConfiguration>().PaymentEventsApi; | ||
|
||
HttpClient httpClient = new HttpClientBuilder() | ||
.WithBearerAuthorisationHeader(new AzureActiveDirectoryBearerTokenGenerator(config)) | ||
.WithHandler(new RequestIdMessageRequestHandler()) | ||
.WithHandler(new SessionIdMessageRequestHandler()) | ||
.WithDefaultHeaders() | ||
.Build(); | ||
|
||
|
||
return httpClient; | ||
} | ||
} | ||
} |
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