public WalletModel GetWallet(string apiKey, string fiatCurrencyToDisplayValues) { WalletModel model = new WalletModel(); List <BalanceModel> balances = new List <BalanceModel>(); var response = _celsiusApiService.GetResultFromCelsiusPrivateApi(apiKey, Constants.CelsiusApiGetWalletBalance); dynamic des = JsonConvert.DeserializeObject(response.Content); decimal fiatExchangeRateToUsd = 1; if (fiatCurrencyToDisplayValues.ToUpper() != UsdFiatCurrencySymbol) { fiatExchangeRateToUsd = _exchangeService.GetExchangeRateToUsd(fiatCurrencyToDisplayValues); } foreach (var currency in _currencyService.GetSupportedCurrencies(apiKey)) { string currentCurrency = currency.ToString(); decimal amount = des["balance"][currentCurrency.ToLower()]; if (amount > 0) { var balanceModel = new BalanceModel { Amount = amount, Currency = currency, ValueInUsd = GetValueInUsd(apiKey, currentCurrency), FiatCurrencyToDisplay = fiatCurrencyToDisplayValues }; balanceModel.ValueInCurrencyToDisplay = balanceModel.ValueInUsd * fiatExchangeRateToUsd; balances.Add(balanceModel); } } model.Balances = balances.OrderByDescending(b => b.ValueInUsd); model.CurrentCelBalance = balances.SingleOrDefault(b => b.Currency == Constants.CelTicker)?.Amount; return(model); }
private List <string> LoadSupportedCurrenciesFromCelsius(string apiKey) { var currenciesReponse = _celsiusApiService.GetResultFromCelsiusPrivateApi(apiKey, Constants.CelsiusApiGetSupportedCurrencies); dynamic currencies = JsonConvert.DeserializeObject(currenciesReponse.Content); List <string> tmpCurrencies = new List <string>(); foreach (var currency in currencies["currencies"]) { tmpCurrencies.Add(currency.ToString()); } return(tmpCurrencies); }
private CelsiusGetTransactionResult GetResults(string apiKey, int page) { var result = _celsiusApiService.GetResultFromCelsiusPrivateApi(apiKey, $"{Constants.CelsiusApiGetWalletTransactions}?per_page={_pageSizeGetTransaction}&page={page}"); return((CelsiusGetTransactionResult)JsonConvert.DeserializeObject(result.Content, typeof(CelsiusGetTransactionResult))); }