Ejemplo n.º 1
0
        public void GetHttpClient_Test()
        {
            var proxyAddress = "userproxy.visa.com";
            var proxyPort    = "443";

            var httpConnUtilityObj = new HttpConnUtility(proxyAddress, proxyPort, "");

            var httpClientObj = httpConnUtilityObj.GetHttpClient();

            Assert.IsInstanceOf(typeof(HttpClient), httpClientObj);
        }
        public HttpClient GetConnectionForGet(MerchantConfig merchantConfig)
        {
            var token           = AuthenticationHelper.GetToken(merchantConfig);
            var httpConnUtility = new HttpConnUtility(merchantConfig.ProxyAddress, merchantConfig.ProxyPort, merchantConfig.TimeOut);
            var client          = httpConnUtility.GetHttpClient();

            client.DefaultRequestHeaders
            .Accept
            .Add(new MediaTypeWithQualityHeaderValue(Constants.MediaTypeHalAndJson));

            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(Constants.Bearer, token.BearerToken);

            return(client);
        }
        public HttpClient GetConnectionForPut(MerchantConfig merchantConfig)
        {
            var token           = AuthenticationHelper.GetToken(merchantConfig);
            var httpConnUtility = new HttpConnUtility(merchantConfig.ProxyAddress, merchantConfig.ProxyPort, merchantConfig.TimeOut);
            var client          = httpConnUtility.GetHttpClient();

            var content = new StringContent(merchantConfig.RequestJsonData);

            content.Headers.ContentType = new MediaTypeHeaderValue(Constants.MediaTypeJson);

            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(Constants.Bearer, token.BearerToken);

            return(client);
        }
        public HttpClient GetConnectionForPut(MerchantConfig merchantConfig)
        {
            var signature       = AuthenticationHelper.GetSignature(merchantConfig);
            var httpConnUtility = new HttpConnUtility(merchantConfig.ProxyAddress, merchantConfig.ProxyPort, merchantConfig.TimeOut);
            var client          = httpConnUtility.GetHttpClient();

            client.DefaultRequestHeaders.Add("v-c-merchant-id", signature.MerchantId);

            client.DefaultRequestHeaders.Add("Date", signature.GmtDateTime);

            client.DefaultRequestHeaders.Add("Host", signature.HostName);

            client.DefaultRequestHeaders.Add("Digest", signature.Digest);

            client.DefaultRequestHeaders.Add("Signature", signature.SignatureParam);

            return(client);
        }
        public HttpClient GetConnectionForGet(MerchantConfig merchantConfig)
        {
            var signature       = AuthenticationHelper.GetSignature(merchantConfig);
            var httpConnUtility = new HttpConnUtility(merchantConfig.ProxyAddress, merchantConfig.ProxyPort, merchantConfig.TimeOut);
            var client          = httpConnUtility.GetHttpClient();

            client.DefaultRequestHeaders
            .Accept
            .Add(new MediaTypeWithQualityHeaderValue(Constants.MediaTypeHalAndJson));

            client.DefaultRequestHeaders.Add("v-c-merchant-id", signature.MerchantId);

            client.DefaultRequestHeaders.Add("Date", signature.GmtDateTime);

            client.DefaultRequestHeaders.Add("Host", signature.HostName);

            client.DefaultRequestHeaders.Add("Signature", signature.SignatureParam);

            return(client);
        }