Files
EnvelopeGenerator/EnvelopeGenerator.ReceiverUI/Services/SignatureService.cs
TekH dec2b81afe Refactor to use SignatureDto and SignatureService
Replaced AnnotationDto and AnnotationService with SignatureDto
and SignatureService for handling signature data. Marked
AnnotationDto and AnnotationService as obsolete.

Added the SignatureDto class to represent signature data and
introduced the SignatureService class to fetch signature data
from the API. Updated EnvelopeViewer.razor to use
SignatureService, replacing AnnotationService, and added a
debug log for retrieved signatures.

Performed general refactoring to align with the new signature
data model and functionality.
2026-06-06 19:14:42 +02:00

25 lines
1.0 KiB
C#

using System.Net.Http.Json;
using System.Text.Json;
using EnvelopeGenerator.ReceiverUI.Models;
using EnvelopeGenerator.ReceiverUI.Options;
using Microsoft.Extensions.Options;
namespace EnvelopeGenerator.ReceiverUI.Services;
public class SignatureService(HttpClient http, IOptions<ApiOptions> apiOptions)
{
private static readonly JsonSerializerOptions _jsonOptions = new(JsonSerializerDefaults.Web);
public async Task<IReadOnlyList<SignatureDto>> GetAsync(string envelopeKey, CancellationToken cancel = default)
{
var url = $"{apiOptions.Value.BaseUrl}/api/Signature/{Uri.EscapeDataString(envelopeKey)}";
var response = await http.GetAsync(url, cancel);
if (!response.IsSuccessStatusCode)
throw new HttpRequestException($"Failed to retrieve signatures for envelope {envelopeKey}: {response.StatusCode} {response.ReasonPhrase}");
var result = await response.Content.ReadFromJsonAsync<List<SignatureDto>>(_jsonOptions, cancel);
return result ?? [];
}
}