public Exporter(ApiExportOptions apiExportOptions) { _apiExportOptions = apiExportOptions; var clientFactory = GetHttpClientServiceProvider(apiExportOptions); _getHttpClient = () => clientFactory.GetRequiredService <IHttpClientFactory>().CreateClient("Clockodo"); SetExportPaths(); }
public static IServiceProvider GetHttpClientServiceProvider(ApiExportOptions options) { var serviceCollection = new ServiceCollection(); serviceCollection.AddHttpClient("Clockodo", httpClientOptions => { httpClientOptions.DefaultRequestHeaders.Add("User-Agent", "Dangl IT GmbH Clockodo Export www.dangl-it.com"); httpClientOptions.DefaultRequestHeaders.Add("X-ClockodoApiUser", options.UserEmail); httpClientOptions.DefaultRequestHeaders.Add("X-ClockodoApiKey", options.ClockodoApiToken); }); return(serviceCollection.BuildServiceProvider()); }