< Summary

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

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
GetArcsByCampaignAsync()100%210%
GetArcAsync()100%210%
CreateArcAsync()100%210%
UpdateArcAsync()100%210%
DeleteArcAsync()100%210%
ActivateArcAsync()100%210%

File(s)

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

#LineLine coverage
 1using Chronicis.Shared.DTOs;
 2
 3namespace Chronicis.Client.Services;
 4
 5/// <summary>
 6/// Service for Arc API operations.
 7/// Uses HttpClientExtensions for consistent error handling and logging.
 8/// </summary>
 9public class ArcApiService : IArcApiService
 10{
 11    private readonly HttpClient _http;
 12    private readonly ILogger<ArcApiService> _logger;
 13
 014    public ArcApiService(HttpClient http, ILogger<ArcApiService> logger)
 15    {
 016        _http = http;
 017        _logger = logger;
 018    }
 19
 20    public async Task<List<ArcDto>> GetArcsByCampaignAsync(Guid campaignId)
 21    {
 022        return await _http.GetListAsync<ArcDto>(
 023            $"campaigns/{campaignId}/arcs",
 024            _logger,
 025            $"arcs for campaign {campaignId}");
 026    }
 27
 28    public async Task<ArcDto?> GetArcAsync(Guid arcId)
 29    {
 030        return await _http.GetEntityAsync<ArcDto>(
 031            $"arcs/{arcId}",
 032            _logger,
 033            $"arc {arcId}");
 034    }
 35
 36    public async Task<ArcDto?> CreateArcAsync(ArcCreateDto dto)
 37    {
 038        return await _http.PostEntityAsync<ArcDto>(
 039            "arcs",
 040            dto,
 041            _logger,
 042            "arc");
 043    }
 44
 45    public async Task<ArcDto?> UpdateArcAsync(Guid arcId, ArcUpdateDto dto)
 46    {
 047        return await _http.PutEntityAsync<ArcDto>(
 048            $"arcs/{arcId}",
 049            dto,
 050            _logger,
 051            $"arc {arcId}");
 052    }
 53
 54    public async Task<bool> DeleteArcAsync(Guid arcId)
 55    {
 056        return await _http.DeleteEntityAsync(
 057            $"arcs/{arcId}",
 058            _logger,
 059            $"arc {arcId}");
 060    }
 61
 62    public async Task<bool> ActivateArcAsync(Guid arcId)
 63    {
 64        try
 65        {
 066            var response = await _http.PostAsync($"arcs/{arcId}/activate", null);
 067            return response.IsSuccessStatusCode;
 68        }
 069        catch (Exception ex)
 70        {
 071            _logger.LogError(ex, "Error activating arc {ArcId}", arcId);
 072            return false;
 73        }
 074    }
 75}