示例#1
0
        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());
            }
        }
示例#2
0
        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);
        }
示例#3
0
 public HttpPos(HttpPosOptions options)
 {
     _httpClient = GetClient(options);
     _options    = options;
 }