public IDictionary <string, decimal> GetBalance() { GetBalanceAsyncReturn objResult = null; try { _logger.LogInformation("Get balance - {time}", DateTimeOffset.Now); var URL = "https://api.bitcointrade.com.br/v2/wallets/balance"; HttpClient request = new HttpClient(); request.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("ApiToken", _Key); var Task = request.GetStringAsync(URL); Task.Wait(); string strResult = Task.Result; objResult = JsonConvert.DeserializeObject <GetBalanceAsyncReturn>(strResult); } catch (HttpRequestException httpex) { throw new CoreException(httpex.Message); } return(getBalanceConvertTodict(objResult)); }
private IDictionary <string, decimal> getBalanceConvertTodict(GetBalanceAsyncReturn obj) { var dict = new Dictionary <string, decimal>(); var strCurrencycode = string.Empty; foreach (var item in obj.Data) { if (string.Compare(item.CurrencyCode, "BTC") == 0) { strCurrencycode = EnumCryptoCurrency.EnumCryptoCurrencyType.BRLBTC.ToString(); } else if (string.Compare(item.CurrencyCode, "ETH") == 0) { strCurrencycode = EnumCryptoCurrency.EnumCryptoCurrencyType.BRLETH.ToString(); } else if (string.Compare(item.CurrencyCode, "LTC") == 0) { strCurrencycode = EnumCryptoCurrency.EnumCryptoCurrencyType.BRLLTC.ToString(); } else if (string.Compare(item.CurrencyCode, "BCH") == 0) { strCurrencycode = EnumCryptoCurrency.EnumCryptoCurrencyType.BRLBCH.ToString(); } else if (string.Compare(item.CurrencyCode, "XRP") == 0) { strCurrencycode = EnumCryptoCurrency.EnumCryptoCurrencyType.BRLXRP.ToString(); } else { strCurrencycode = item.CurrencyCode; } dict.Add(strCurrencycode, item.AvailableAmount); } return(dict); }