public override async Task <MetricData> GetDataAsync(CancellationToken cancellationToken = default) { var httpClient = new HttpClient(); var response = await httpClient.GetAsync($"https://api.bitbay.net/rest/trading/ticker", cancellationToken); if (response.IsSuccessStatusCode) { var responseDto = JsonSerializer.Deserialize <CryptoTickerDto>(await response.Content.ReadAsStringAsync()); return(new MetricData(decimal.Parse(responseDto.Items.LtcPln.Rate, CultureInfo.InvariantCulture), MetricType.Money, Status.OK)); } return(MetricData.Error($"Code: {response.StatusCode}")); }
public override async Task <MetricData> GetDataAsync(CancellationToken cancellationToken) { try { var azureDevOpsHelper = new AzureDevOpsHelper(ConfigProvider, RootConfig); var codeCoverageDetails = await azureDevOpsHelper.GetCodeCoverageResultForLastGreenBuildAsync(cancellationToken); if (codeCoverageDetails == null) { return(MetricData.NoUpdate()); } var linesCoverageData = codeCoverageDetails.CoverageData.First().CoverageStats.Single(x => x.Label == "Lines"); var percentageCoverage = Math.Round(100m * linesCoverageData.Covered / linesCoverageData.Total, 1); return(new MetricData(percentageCoverage, MetricType.Percentage, Status.OK)); } catch (Exception ex) { return(MetricData.Error(ex.Message)); } }