public static async Task <IPOS> CreatePosAsync(HttpPosOptions options) { var connectionhandler = new HttpProxyConnectionHandler <IPOS>(new HttpPos(options)); if (options.RetryPolicyOptions != null) { var retryPolicyHelper = new RetryPolicyHandler <IPOS>(options.RetryPolicyOptions, connectionhandler); return(new PosRetryProxyClient(retryPolicyHelper)); } else { return(await connectionhandler.GetProxyAsync()); } }
private HttpClient GetClient(HttpPosOptions options) { var url = options.Url.ToString().EndsWith("/") ? options.Url : new Uri($"{options.Url}/"); var client = new HttpClient { BaseAddress = url }; if (options.CashboxId.HasValue) { client.DefaultRequestHeaders.Add("cashboxid", options.CashboxId.Value.ToString()); } if (!string.IsNullOrEmpty(options.AccessToken)) { client.DefaultRequestHeaders.Add("accesstoken", options.AccessToken); } return(client); }
public HttpPos(HttpPosOptions options) { _httpClient = GetClient(options); _options = options; }