< Summary

Information
Class: Services.ApiServices.InterpartsPriceApi.InterpartsPriceHttpResult
Assembly: Services
File(s): /home/runner/work/Studio2Prod/Studio2Prod/AppRepository/ApiServices/InterpartsPriceApi/InterpartsPriceApiClient.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 1
Coverable lines: 1
Total lines: 44
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
get_StatusCode()100%210%

File(s)

/home/runner/work/Studio2Prod/Studio2Prod/AppRepository/ApiServices/InterpartsPriceApi/InterpartsPriceApiClient.cs

#LineLine coverage
 1using Microsoft.Extensions.Http;
 2using SlqStudio.Application.Services.EmailService;
 3using Services.ApiServices;
 4
 5namespace Services.ApiServices.InterpartsPriceApi;
 6
 7public class InterpartsPriceApiClient : BaseApiClient
 8{
 9    public InterpartsPriceApiClient(IHttpClientFactory httpClientFactory, IEmailService? emailService)
 10        : base(httpClientFactory, emailService, "InterpartsPriceApi", TimeSpan.FromSeconds(15))
 11    {
 12    }
 13
 14    public async Task<InterpartsPriceHttpResult> GetXmlAsync(string requestUrl, CancellationToken cancellationToken = de
 15    {
 16        try
 17        {
 18            var client = _httpClientFactory?.CreateClient(_clientName) ?? new HttpClient();
 19            client.Timeout = _timeout;
 20            SetHttpClientHeaders(client);
 21            using var response = await client.GetAsync(requestUrl, cancellationToken);
 22            var body = await response.Content.ReadAsStringAsync(cancellationToken);
 23            return new InterpartsPriceHttpResult((int)response.StatusCode, body,
 24                response.IsSuccessStatusCode ? null : $"Interparts Price вернул HTTP {(int)response.StatusCode} ({respon
 25        }
 26        catch (TaskCanceledException ex)
 27        {
 28            return new InterpartsPriceHttpResult(null, null, $"Таймаут Interparts Price: {ex.Message}");
 29        }
 30        catch (HttpRequestException ex)
 31        {
 32            return new InterpartsPriceHttpResult(ex.StatusCode is null ? null : (int)ex.StatusCode, null, $"Ошибка сети 
 33        }
 34    }
 35
 36    public override Task<bool> GetTestRequest(string businessId, string apiKey)
 37    {
 38        // Здесь нет полноценного тестового эндпоинта, считаем что клиент "работает",
 39        // пока запросы не падают в менеджере.
 40        return Task.FromResult(true);
 41    }
 42}
 43
 044public sealed record InterpartsPriceHttpResult(int? StatusCode, string? Body, string? ErrorMessage);

Methods/Properties

get_StatusCode()