feat(sms): NotificationType.Sms + recipient phone + SmsConfiguration + repo iface (S1)
This commit is contained in:
@@ -8,11 +8,13 @@ public class NotificationRecipient
|
||||
public int NotificationListId { get; set; }
|
||||
/// <summary>Gets or sets the display name of the recipient.</summary>
|
||||
public string Name { get; set; }
|
||||
/// <summary>Gets or sets the recipient's email address.</summary>
|
||||
public string EmailAddress { get; set; }
|
||||
/// <summary>Gets or sets the recipient's email address, or null for non-email recipients.</summary>
|
||||
public string? EmailAddress { get; set; }
|
||||
/// <summary>Gets or sets the recipient's phone number (E.164), or null for non-SMS recipients.</summary>
|
||||
public string? PhoneNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new <see cref="NotificationRecipient"/> with the required fields.
|
||||
/// Initializes a new <see cref="NotificationRecipient"/> with the required fields (email path).
|
||||
/// </summary>
|
||||
/// <param name="name">Display name of the recipient.</param>
|
||||
/// <param name="emailAddress">Email address of the recipient.</param>
|
||||
@@ -21,4 +23,59 @@ public class NotificationRecipient
|
||||
Name = name ?? throw new ArgumentNullException(nameof(name));
|
||||
EmailAddress = emailAddress ?? throw new ArgumentNullException(nameof(emailAddress));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an email recipient with the given name and email address; the phone number is left null.
|
||||
/// </summary>
|
||||
/// <param name="name">Display name of the recipient.</param>
|
||||
/// <param name="emailAddress">Email address of the recipient.</param>
|
||||
/// <returns>A new email <see cref="NotificationRecipient"/>.</returns>
|
||||
public static NotificationRecipient ForEmail(string name, string emailAddress)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
throw new ArgumentException("Name must not be empty.", nameof(name));
|
||||
}
|
||||
|
||||
if (emailAddress is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(emailAddress));
|
||||
}
|
||||
|
||||
return new NotificationRecipient(name, emailAddress);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an SMS recipient with the given name and phone number; the email address is left null.
|
||||
/// </summary>
|
||||
/// <param name="name">Display name of the recipient.</param>
|
||||
/// <param name="phoneNumber">Phone number (E.164) of the recipient.</param>
|
||||
/// <returns>A new SMS <see cref="NotificationRecipient"/>.</returns>
|
||||
public static NotificationRecipient ForSms(string name, string phoneNumber)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
throw new ArgumentException("Name must not be empty.", nameof(name));
|
||||
}
|
||||
|
||||
if (phoneNumber is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(phoneNumber));
|
||||
}
|
||||
|
||||
return new NotificationRecipient
|
||||
{
|
||||
Name = name,
|
||||
PhoneNumber = phoneNumber
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parameterless constructor used by EF Core materialization and the SMS factory, where the
|
||||
/// contact field is assigned via property setters rather than constructor parameters.
|
||||
/// </summary>
|
||||
private NotificationRecipient()
|
||||
{
|
||||
Name = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user