diff --git a/EnvelopeGenerator.Application/Common/Interfaces/Services/Notification/DocumentSharedNotification.cs b/EnvelopeGenerator.Application/Common/Interfaces/Services/Notification/DocumentSharedNotification.cs new file mode 100644 index 00000000..7f3161d9 --- /dev/null +++ b/EnvelopeGenerator.Application/Common/Interfaces/Services/Notification/DocumentSharedNotification.cs @@ -0,0 +1,57 @@ +using EnvelopeGenerator.Application.Common.Extensions; +using EnvelopeGenerator.Domain.Constants; + +namespace EnvelopeGenerator.Application.Common.Interfaces.Services.Notification; + +/// +/// Payload for template. +/// +public record DocumentSharedNotification : EnvelopeNotificationBase +{ + /// + /// Replaces [DOCUMENT_TITLE] in mail subject/body. + /// + public required string DocumentTitle { get; init; } + + /// + /// Replaces [NAME_RECEIVER] in mail body. + /// + public required string NameReceiver { get; init; } + + /// + /// Base host used to build document link placeholders. + /// + public required Uri Origin { private get; init; } + + /// + /// Read-only share identifier used to build link placeholders. + /// + public required long ReadOnlyId { private get; init; } + + private Uri EnvelopeUrl => new(Origin, $"EnvelopeKey/{ReadOnlyId.ToEnvelopeKey()}"); + + /// + /// Replaces [LINK_TO_DOCUMENT] in mail body. + /// + public string LinkToDocument => EnvelopeUrl.AbsoluteUri; + + /// + /// Replaces [LINK_TO_DOCUMENT_TEXT] in mail body. + /// + public string LinkToDocumentText + { + get + { + var urlText = EnvelopeUrl.ToString(); + return $"{urlText[..Math.Min(urlText.Length, 40)]}.."; + } + } + + /// + /// Replaces [NAME_PORTAL] in mail body. + /// + public string NamePortal { get; init; } = "signFLOW Portal"; + + /// + public override EmailTemplateType GetTemplateType() => EmailTemplateType.DocumentShared; +}