private async Task <string> GetGlobalMetrics() { try { if (!string.IsNullOrEmpty(keyStore.CoinMarketCapApiKey)) { return(await GlobalMetricsRequest.GetGlobalMetrics(this.cmcConn, keyStore.CoinMarketCapApiKey)); } } catch (Exception e) { RawData = e.Message; } return(null); }
private async Task Refresh() { IsBusy = true; if (string.IsNullOrEmpty(keyStore.CoinMarketCapApiKey) || string.IsNullOrEmpty(keyStore.NomicsApiKey)) { if (string.IsNullOrEmpty(Password) || string.IsNullOrEmpty(Password2)) { RawData = "Password not set."; } else { keyStore = new MongoAtlasStore(); keyStore.LogIn(Password, Password2); keyStore.GetApiKeys(); } } string cmcMarketCap = null; if (!string.IsNullOrEmpty(keyStore.CoinMarketCapApiKey)) { cmcMarketCap = await GlobalMetricsRequest.GetGlobalMetrics(this.cmcConn, keyStore.CoinMarketCapApiKey).ConfigureAwait(false); } string nomicsMarketCap = null; string nomicsGlobalVol = null; if (!string.IsNullOrEmpty(keyStore.NomicsApiKey)) { nomicsMarketCap = await MarketHistoryRequest.GetMarketCapHistory(this.nomicsConn, keyStore.NomicsApiKey).ConfigureAwait(false); nomicsGlobalVol = await MarketHistoryRequest.GetGlobalVolumeHistory(this.nomicsConn, keyStore.NomicsApiKey).ConfigureAwait(false); } if (!string.IsNullOrEmpty(cmcMarketCap)) { if (cmcMarketCap == "Unauthorized") { RawData = cmcMarketCap; } else { SetPropertiesFromCMCGlobalMetrics(GlobalMetrics.FromJson(cmcMarketCap)); } } if (!string.IsNullOrEmpty(nomicsMarketCap)) { if (nomicsMarketCap == "Unauthorized") { RawData = nomicsMarketCap; } else { SetPropertiesFromNomicsMarketCapHistory(MarketCapHistory.FromJson(nomicsMarketCap)); } } if (!string.IsNullOrEmpty(nomicsGlobalVol)) { if (nomicsGlobalVol == "Unauthorized") { RawData = nomicsGlobalVol; } else { SetPropertiesFromNomicsMarketVolHistory(GlobalVolHistory.FromJson(nomicsGlobalVol)); } } IsBusy = false; }