< Summary

Information
Class: Chronicis.Client.Services.UserApiService
Assembly: Chronicis.Client
File(s): /home/runner/work/chronicis/chronicis/src/Chronicis.Client/Services/UserApiService.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 18
Coverable lines: 18
Total lines: 51
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%
GetUserProfileAsync()100%210%
CompleteOnboardingAsync()100%210%

File(s)

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

#LineLine coverage
 1using System.Net.Http.Json;
 2using Chronicis.Shared.DTOs;
 3
 4namespace Chronicis.Client.Services;
 5
 6/// <summary>
 7/// Implementation of user profile API service.
 8/// </summary>
 9public class UserApiService : IUserApiService
 10{
 11    private readonly HttpClient _http;
 12    private readonly ILogger<UserApiService> _logger;
 13
 014    public UserApiService(HttpClient http, ILogger<UserApiService> logger)
 15    {
 016        _http = http;
 017        _logger = logger;
 018    }
 19
 20    public async Task<UserProfileDto?> GetUserProfileAsync()
 21    {
 22        try
 23        {
 024            return await _http.GetFromJsonAsync<UserProfileDto>("users/me");
 25        }
 026        catch (HttpRequestException ex) when (ex.StatusCode == System.Net.HttpStatusCode.NotFound)
 27        {
 028            _logger.LogWarning("User profile not found");
 029            return null;
 30        }
 031        catch (Exception ex)
 32        {
 033            _logger.LogError(ex, "Error fetching user profile");
 034            return null;
 35        }
 036    }
 37
 38    public async Task<bool> CompleteOnboardingAsync()
 39    {
 40        try
 41        {
 042            var response = await _http.PostAsync("users/me/complete-onboarding", null);
 043            return response.IsSuccessStatusCode;
 44        }
 045        catch (Exception ex)
 46        {
 047            _logger.LogError(ex, "Error completing onboarding");
 048            return false;
 49        }
 050    }
 51}