Introduced new models (`SignatureDto`, `SignatureCaptureDto`, `EnvelopeReceiverDto`) to support a signature-based workflow. Added services for handling API interactions (`SignatureService`, `AuthService`, `DocumentService`, `EnvelopeReceiverService`, `SignatureCacheService`). Enhanced configuration with `ApiOptions` and `PdfViewerOptions`. Integrated DevExpress features with custom data connection providers, in-memory report storage, and font loading utilities. Marked `AnnotationDto` and `AnnotationService` as `[Obsolete]` in favor of newer implementations. Added detailed documentation for coordinate systems, unit conversions, and usage scenarios.
41 lines
1.6 KiB
C#
41 lines
1.6 KiB
C#
using System.Net;
|
|
using System.Net.Http.Json;
|
|
using System.Text.Json;
|
|
using EnvelopeGenerator.WebUI.Client.Models;
|
|
using EnvelopeGenerator.WebUI.Client.Options;
|
|
using Microsoft.Extensions.Options;
|
|
|
|
namespace EnvelopeGenerator.WebUI.Client.Services;
|
|
|
|
/// <summary>
|
|
/// Retrieves the <see cref="EnvelopeReceiverDto"/> for the authenticated receiver
|
|
/// from <c>GET api/EnvelopeReceiver/{envelopeKey}</c>.
|
|
/// </summary>
|
|
public class EnvelopeReceiverService(HttpClient http, IOptions<ApiOptions> apiOptions)
|
|
{
|
|
private static readonly JsonSerializerOptions _jsonOptions = new(JsonSerializerDefaults.Web);
|
|
|
|
/// <summary>
|
|
/// Fetches the envelope receiver data for the given envelope key from the API.
|
|
/// Throws HttpRequestException on failure with appropriate status code.
|
|
/// </summary>
|
|
/// <exception cref="HttpRequestException">Thrown when the API request fails.</exception>
|
|
public async Task<EnvelopeReceiverDto?> GetAsync(string envelopeKey, CancellationToken cancel = default)
|
|
{
|
|
var url = $"{apiOptions.Value.BaseUrl}/api/EnvelopeReceiver/{Uri.EscapeDataString(envelopeKey)}";
|
|
var response = await http.GetAsync(url, cancel);
|
|
|
|
if (!response.IsSuccessStatusCode)
|
|
{
|
|
var statusCode = (int)response.StatusCode;
|
|
var reasonPhrase = response.ReasonPhrase ?? "Unknown error";
|
|
throw new HttpRequestException(
|
|
$"Failed to load envelope receiver data. Status: {statusCode} ({reasonPhrase})",
|
|
null,
|
|
response.StatusCode);
|
|
}
|
|
|
|
return await response.Content.ReadFromJsonAsync<EnvelopeReceiverDto>(_jsonOptions, cancel);
|
|
}
|
|
}
|