• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

moconnell / yolo / 18294711331

06 Oct 2025 09:15PM UTC coverage: 58.251% (-4.3%) from 62.562%
18294711331

push

github

web-flow
Merge pull request #32 from moconnell/feat/31-unravel-integration

Feature: Unravel integration

99 of 192 branches covered (51.56%)

Branch coverage included in aggregate %.

17 of 48 new or added lines in 5 files covered. (35.42%)

254 of 414 relevant lines covered (61.35%)

26.26 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/YoloAbstractions/Extensions/HttpClientExtensions.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Net.Http;
4
using System.Net.Http.Json;
5
using System.Threading;
6
using System.Threading.Tasks;
7
using YoloAbstractions.Exceptions;
8
using YoloAbstractions.Interfaces;
9

10
namespace YoloAbstractions.Extensions;
11

12
public static class HttpClientExtensions
13
{
14
    public static async Task<T> GetAsync<T, TData>(
15
        this HttpClient httpClient,
16
        string url,
17
        IReadOnlyDictionary<string, string>? headers = null,
18
        CancellationToken cancellationToken = default)
19
        where T : IApiResponse<TData>
NEW
20
    {
×
NEW
21
        ArgumentNullException.ThrowIfNull(httpClient, nameof(httpClient));
×
NEW
22
        ArgumentException.ThrowIfNullOrEmpty(url, nameof(url));
×
23

NEW
24
        var request = new HttpRequestMessage(HttpMethod.Get, url);
×
NEW
25
        if (headers != null)
×
NEW
26
        {
×
NEW
27
            foreach (var header in headers)
×
NEW
28
            {
×
NEW
29
                request.Headers.Add(header.Key, header.Value);
×
NEW
30
            }
×
NEW
31
        }
×
32

NEW
33
        using var response = await httpClient.SendAsync(request, cancellationToken);
×
34

NEW
35
        if (!response.IsSuccessStatusCode)
×
NEW
36
        {
×
NEW
37
            throw new ApiException(
×
NEW
38
                $"Could not fetch from API: {await response.Content.ReadAsStringAsync(cancellationToken)} ({response.StatusCode}: {response.ReasonPhrase})");
×
39
        }
40

NEW
41
        var apiResponse = await response.Content.ReadFromJsonAsync<T>(cancellationToken: cancellationToken);
×
42

NEW
43
        if (apiResponse is null || apiResponse.Data is null || apiResponse.Data.Count == 0)
×
NEW
44
        {
×
NEW
45
            throw new ApiException("Invalid response");
×
46
        }
47

NEW
48
        return apiResponse;
×
NEW
49
    }
×
50
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc