2023-10-19 15:59:57 +10:00
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2023-10-19 16:55:42 +10:00
|
|
|
|
using PARR.EsppApi.Settings;
|
2023-10-19 15:59:57 +10:00
|
|
|
|
|
|
|
|
|
|
namespace PARR.EsppApi
|
|
|
|
|
|
{
|
|
|
|
|
|
public static class ParrEsppApiInstaller
|
|
|
|
|
|
{
|
|
|
|
|
|
public static void InstallEsppApiServices(this IServiceCollection services, IConfiguration configuration)
|
|
|
|
|
|
{
|
|
|
|
|
|
// settings
|
2023-10-19 16:55:42 +10:00
|
|
|
|
var esppSettings = new EsppOrderSettings();
|
|
|
|
|
|
configuration.GetSection(nameof(EsppOrderSettings)).Bind(esppSettings);
|
|
|
|
|
|
services.AddSingleton(esppSettings);
|
|
|
|
|
|
|
2023-10-25 10:21:18 +10:00
|
|
|
|
EsppUserTimeZoneSettings.TimeZone = esppSettings.EsppUserTimeZone;
|
2023-10-19 15:59:57 +10:00
|
|
|
|
|
|
|
|
|
|
services.AddTransient<IEsppApiService, EsppApiService>();
|
2023-10-19 16:55:42 +10:00
|
|
|
|
|
2023-10-24 12:10:19 +10:00
|
|
|
|
services.AddHttpClient<EsppHttpService>(client =>
|
|
|
|
|
|
{
|
|
|
|
|
|
client.BaseAddress = new Uri(esppSettings.Url);
|
|
|
|
|
|
client.DefaultRequestHeaders.Add("EsppUser", esppSettings.UserName);
|
|
|
|
|
|
client.DefaultRequestHeaders.Add("EsppPassword", esppSettings.Password);
|
|
|
|
|
|
});
|
2023-10-19 15:59:57 +10:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|