< Summary

Information
Class: Chronicis.Client.Services.ArticleExternalLinkApiService
Assembly: Chronicis.Client
File(s): /home/runner/work/chronicis/chronicis/src/Chronicis.Client/Services/ArticleExternalLinkApiService.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 13
Coverable lines: 13
Total lines: 37
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
GetExternalLinksAsync()0%620%

File(s)

/home/runner/work/chronicis/chronicis/src/Chronicis.Client/Services/ArticleExternalLinkApiService.cs

#LineLine coverage
 1using System.Net.Http.Json;
 2using Chronicis.Shared.DTOs;
 3
 4namespace Chronicis.Client.Services;
 5
 6/// <summary>
 7/// Service for interacting with the Article External Links API.
 8/// </summary>
 9public class ArticleExternalLinkApiService : IArticleExternalLinkApiService
 10{
 11    private readonly HttpClient _httpClient;
 12    private readonly ILogger<ArticleExternalLinkApiService> _logger;
 13
 014    public ArticleExternalLinkApiService(
 015        HttpClient httpClient,
 016        ILogger<ArticleExternalLinkApiService> logger)
 17    {
 018        _httpClient = httpClient;
 019        _logger = logger;
 020    }
 21
 22    public async Task<List<ArticleExternalLinkDto>> GetExternalLinksAsync(Guid articleId)
 23    {
 24        try
 25        {
 026            var response = await _httpClient.GetFromJsonAsync<List<ArticleExternalLinkDto>>(
 027                $"articles/{articleId}/external-links");
 28
 029            return response ?? new List<ArticleExternalLinkDto>();
 30        }
 031        catch (Exception ex)
 32        {
 033            _logger.LogError(ex, "Error retrieving external links for article {ArticleId}", articleId);
 034            return new List<ArticleExternalLinkDto>();
 35        }
 036    }
 37}