using MediatR;
using EnvelopeGenerator.Application.Common.Dto;
using EnvelopeGenerator.Application.Common.Dto.EnvelopeReceiver;
using EnvelopeGenerator.Application.Common.Extensions;
using EnvelopeGenerator.Domain.Constants;
namespace EnvelopeGenerator.Application.Signatures.Commands;
///
/// Command to sign a document by a receiver.
///
public record SignCommand : IRequest
{
///
/// The envelope receiver information.
///
public required EnvelopeReceiverDto EnvelopeReceiver { get; init; }
///
/// The PSPDFKit annotation data.
///
[Obsolete("This notification is deprecated. Use Signature.Commands.SignCommand instead.")]
public PsPdfKitAnnotation? PsPdfKitAnnotation { get; init; }
///
/// Gets the email address of the receiver.
///
public string EmailAddress => EnvelopeReceiver.Receiver?.EmailAddress
?? throw new InvalidOperationException($"Receiver is null." +
$"DocSignedNotification:\n{this.ToJson(Format.Json.ForDiagnostics)}");
}
///
/// Handles the sign command. The actual work is done by SignCommandBehavior pipeline.
///
public class SignCommandHandler : IRequestHandler
{
///
/// Executes the signing command. Pipeline behaviors handle the actual processing.
///
///
///
///
public Task Handle(SignCommand request, CancellationToken cancellationToken = default)
{
return Task.CompletedTask;
}
}