public TulkasClient(TulkasCredentials credentials, IClientConfig config, IHttpClientFactory httpClientFactory, IAuthorizationManager authorizationManager, IRequestManager requestManager) { Credentials = credentials; Config = config; _httpClientFactory = httpClientFactory; _authorizationManager = authorizationManager; _requestManager = requestManager; }
public ClientCredentialsManager(IHttpClientFactory httpClientFactory, TulkasCredentials tulkasCredentials) { _httpClientFactory = httpClientFactory; _tulkasCredentials = tulkasCredentials; }
public static IServiceCollection AddTulkasOrderService(this IServiceCollection services, TulkasOptions options, TulkasCredentials credentials) { services.AddHttpClient("Tulkas", client => { client.BaseAddress = new Uri(_baseUri); client.Timeout = TimeSpan.FromSeconds(30); client.DefaultRequestHeaders.Add("User-Agent", "Tulkas.ShopEngine.ApiClient"); }) .ConfigurePrimaryHttpMessageHandler(configure => new HttpClientHandler { AutomaticDecompression = System.Net.DecompressionMethods.GZip | System.Net.DecompressionMethods.Deflate }); services.AddHttpClient("Identity", client => { client.BaseAddress = new Uri(_identityUri); }); services.AddSingleton(options); services.AddSingleton(credentials); services.AddSingleton <IAuthorizationManager, ClientCredentialsManager>(); services.AddSingleton <IRequestManager, DefaultRequestManager>(); services.Configure <TulkasOptions>(o => { o.DisableLogging = options.DisableLogging; o.LogMetrics = options.LogMetrics; o.MaxRetries = options.MaxRetries; }); services.AddSingleton(sp => { return(new TulkasOrderClient(credentials, options.GetClientConfiguration(), sp.GetService <IHttpClientFactory>(), sp.GetService <IAuthorizationManager>(), sp.GetService <IRequestManager>())); }); return(services); }