diff --git a/EnvelopeGenerator.Application/Signature/Commands/SignCommand.cs b/EnvelopeGenerator.Application/Signature/Commands/SignCommand.cs new file mode 100644 index 00000000..46cc8a22 --- /dev/null +++ b/EnvelopeGenerator.Application/Signature/Commands/SignCommand.cs @@ -0,0 +1,52 @@ +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.Signature.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. + /// + public PsPdfKitAnnotation? PsPdfKitAnnotation { get; init; } + + /// + /// Gets the email template type. + /// + public EmailTemplateType TemplateType => EmailTemplateType.DocumentSigned; + + /// + /// 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; + } +} \ No newline at end of file