First Commit

This commit is contained in:
Jorge Luis caudillo esparza
2026-05-09 16:36:57 -07:00
parent 96ad4c0d3e
commit d0c284d9c0
131 changed files with 4009 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
namespace ADS.Helpers.NotifyCenter.Models;
public static class MessageSources
{
public const string NotifyCenter = "ADS.NotifyCenter";
public const string SmtpProvider = "ADS.NotifyCenter.Smtp";
}

View File

@@ -0,0 +1,13 @@
namespace ADS.Helpers.NotifyCenter.Models;
public static class NotifyCodes
{
public const string Ok = "NOTIFY_OK";
public const string NoProvider = "NOTIFY_NO_PROVIDER";
public const string InvalidMessage = "NOTIFY_INVALID_MESSAGE";
public const string SmtpNotConfigured = "SMTP_NOT_CONFIGURED";
public const string SmtpSendFailed = "SMTP_SEND_FAILED";
public const string TenantContextMissing = "TENANT_CONTEXT_MISSING";
}

View File

@@ -0,0 +1,11 @@
namespace ADS.Helpers.NotifyCenter.Models;
public enum NotificationChannel
{
SmtpEmail = 1,
SignalR = 2,
Sms = 3,
WhatsApp = 4,
Webhook = 5,
Push = 6
}

View File

@@ -0,0 +1,26 @@
namespace ADS.Helpers.NotifyCenter.Models;
public sealed class NotificationMessage
{
public required NotificationChannel Channel { get; init; }
// Generic recipients. Providers can interpret these as they need.
// For SMTP: To/Cc/Bcc are emails.
public List<string> To { get; init; } = new();
public List<string> Cc { get; init; } = new();
public List<string> Bcc { get; init; } = new();
public string? Subject { get; init; }
public string? BodyText { get; init; }
public string? BodyHtml { get; init; }
// Optional provider-specific metadata (e.g. phone numbers formatting, template ids, etc.)
public Dictionary<string, string> Metadata { get; init; } = new();
// Optional correlation id from caller
public string? TraceId { get; init; }
public string? Culture { get; init; }
}

View File

@@ -0,0 +1,57 @@
namespace ADS.Helpers.NotifyCenter.Models;
public sealed class NotificationResult
{
public bool Success { get; init; }
public string Source { get; init; } = ""; // quien emitió
public string Code { get; init; } = ""; // keyword estable
public string? Message { get; init; } // ya traducido (si se resolvió)
public string? DebugMessage { get; init; }
public string? ProviderName { get; init; }
public string? ProviderMessageId { get; init; }
public static NotificationResult Ok(
string providerName,
string source,
string code,
string? providerMessageId = null,
string? debugMessage = null)
=> new()
{
Success = true,
ProviderName = providerName,
Source = source,
Code = code,
ProviderMessageId = providerMessageId,
DebugMessage = debugMessage
};
public static NotificationResult Fail(
string providerName,
string source,
string code,
string? debugMessage = null)
=> new()
{
Success = false,
ProviderName = providerName,
Source = source,
Code = code,
DebugMessage = debugMessage
};
public NotificationResult WithMessage(string message)
=> new()
{
Success = Success,
ProviderName = ProviderName,
ProviderMessageId = ProviderMessageId,
Source = Source,
Code = Code,
DebugMessage = DebugMessage,
Message = message
};
}

View File

@@ -0,0 +1,10 @@
namespace ADS.Helpers.NotifyCenter.Models;
public sealed class NotifyCenterOptions
{
// If true, NotifyCenter will throw when no provider is registered for the requested channel.
public bool ThrowIfNoProvider { get; set; } = true;
// If true, NotifyCenter will validate basic fields and fail fast.
public bool ValidateMessage { get; set; } = true;
}