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.
34 lines
1.3 KiB
C#
34 lines
1.3 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;
|
|
|
|
/// <summary>
|
|
/// Retrieves annotation positions from the API.
|
|
/// The URL is composed as <c>{BaseUrl}/api/Annotation/{envelopeKey}</c>.
|
|
/// During development, <c>BaseUrl</c> is empty so the request resolves to the
|
|
/// YARP-proxied route on the same origin, which currently serves
|
|
/// <c>fake-data/annotations.json</c>. To switch to real data, update the
|
|
/// YARP route in <c>yarp.json</c> — no code change required.
|
|
/// </summary>
|
|
[Obsolete("Use SignatureService.")]
|
|
public class AnnotationService(HttpClient http, IOptions<ApiOptions> apiOptions)
|
|
{
|
|
private static readonly JsonSerializerOptions _jsonOptions = new(JsonSerializerDefaults.Web);
|
|
|
|
public async Task<IReadOnlyList<AnnotationDto>> GetAnnotationsAsync(string envelopeKey, CancellationToken cancel = default)
|
|
{
|
|
var url = $"{apiOptions.Value.BaseUrl}/api/Annotation/{Uri.EscapeDataString(envelopeKey)}";
|
|
var response = await http.GetAsync(url, cancel);
|
|
|
|
if (!response.IsSuccessStatusCode)
|
|
return [];
|
|
|
|
var result = await response.Content.ReadFromJsonAsync<List<AnnotationDto>>(_jsonOptions, cancel);
|
|
return result ?? [];
|
|
}
|
|
}
|