public static Task <GetWithdrawalInfoResponse> GetWithdrawalInfo(string txnId)
        {
            var request = new GetWithdrawalInfoRequest {
                Id = txnId
            };
            var req = new HttpUrlRequest(request);

            return(process <GetWithdrawalInfoResponse>(req));
        }
        public static Task <GetCallbackAddressResponse> GetCallbackAddress(string currency)
        {
            var req = new HttpUrlRequest(new {
                cmd = "get_callback_address",
                currency
            });

            return(process <GetCallbackAddressResponse>(req));
        }
        public static Task <CoinBalancesResponse> CoinBalances(int all = 0)
        {
            var request = new CoinBalancesRequest
            {
                All = all
            };

            var req = new HttpUrlRequest(request);

            return(process <CoinBalancesResponse>(req));
        }
        private static async Task <T1> process <T1>(HttpUrlRequest request)
            where T1 : ResponseModel, new()
        {
            var response = await HttpUrlCaller.GetResponse(request);

            var result = new T1();

            result.HttpResponse = response;
            result.ProcessJson();

            return(result);
        }
        public static Task <ExchangeRatesResponse> ExchangeRates(bool isshort = false, bool accepted = false)
        {
            var request = new ExchangeRatesRequest
            {
                Short    = isshort ? 1 : 0,
                Accepted = accepted ? 1 : 0
            };

            var req = new HttpUrlRequest(request);

            return(process <ExchangeRatesResponse>(req));
        }
        public async static Task <HttpUrlResponse> GetResponse(HttpUrlRequest request)
        {
            var absoluteUri = request.RequestUrl;

            var body   = request.GetQueryString();
            var method = request.Method;
            var url    = absoluteUri.ToString();

            var publicKey  = CoinpaymentsSettings.Default.PublicKey;
            var privateKey = CoinpaymentsSettings.Default.PrivateKey;

            var signature = CryptoUtil.CalcSignature(body, privateKey);

            using (var httpClient = new HttpClient())
            {
                //httpClient.Timeout = TimeSpan.FromSeconds(300);
                HttpResponseMessage response;

                httpClient.DefaultRequestHeaders.Add("HMAC", signature);

                switch (method)
                {
                case "GET":
                    response = await httpClient.GetAsync(absoluteUri);

                    break;

                case "POST":
                    var requestBody = new StringContent(body, Encoding.UTF8, "application/x-www-form-urlencoded");
                    //var requestBody = new StringContent(body);
                    response = await httpClient.PostAsync(absoluteUri, requestBody);

                    break;

                default:
                    throw new NotImplementedException("The supplied HTTP method is not supported: " + method ?? "(null)");
                }


                var contentBody = await response.Content.ReadAsStringAsync();

                var headers    = response.Headers.AsEnumerable();
                var statusCode = response.StatusCode;
                var isSuccess  = response.IsSuccessStatusCode;

                var genericExchangeResponse = new HttpUrlResponse(statusCode, isSuccess, headers, contentBody, absoluteUri, body);
                return(genericExchangeResponse);
            }
        }
        public static Task <CreateMassWithdrawalResponse> CreateMassWithdrawal(CreateMassWithdrawalRequest request)
        {
            var req = new HttpUrlRequest(request);

            return(process <CreateMassWithdrawalResponse>(req));
        }
        public static Task <CreateTransactionResponse> CreateTransaction(CreateTransactionRequest request)
        {
            var req = new HttpUrlRequest(request);

            return(process <CreateTransactionResponse>(req));
        }