Documentation
¶
Overview ¶
Package notifications provides base notification primitives and loan lifecycle notifiers. Consumers depend on the Notifier interface for transport and on contracts.LoanNotifier for loan-specific messaging.
Index ¶
- func FormatPhoneNumber(phoneNumber, countryCode string) string
- type AccountTemplates
- type LoanTemplates
- type NoOpAccountNotifier
- func (*NoOpAccountNotifier) NotifyAccountLocked(context.Context, contracts.AccountNotification) error
- func (*NoOpAccountNotifier) NotifyPINChangeFailed(context.Context, contracts.AccountNotification) error
- func (*NoOpAccountNotifier) NotifyPINChanged(context.Context, contracts.AccountNotification) error
- func (*NoOpAccountNotifier) NotifyPINReset(context.Context, contracts.AccountNotification) error
- func (*NoOpAccountNotifier) NotifyPINResetFailed(context.Context, contracts.AccountNotification) error
- func (*NoOpAccountNotifier) NotifyPINWrongAttempt(context.Context, contracts.AccountNotification) error
- func (*NoOpAccountNotifier) NotifyRegistrationFailed(context.Context, contracts.AccountNotification) error
- func (*NoOpAccountNotifier) NotifyRegistrationSuccess(context.Context, contracts.AccountNotification) error
- type NoOpLoanNotifier
- func (*NoOpLoanNotifier) NotifyLoanApproved(context.Context, contracts.LoanNotification) error
- func (*NoOpLoanNotifier) NotifyLoanDisbursed(context.Context, contracts.LoanNotification) error
- func (*NoOpLoanNotifier) NotifyLoanFailed(context.Context, contracts.LoanNotification) error
- func (*NoOpLoanNotifier) NotifyLoanRejected(context.Context, contracts.LoanNotification) error
- func (*NoOpLoanNotifier) NotifyRepaymentReceived(context.Context, contracts.LoanNotification) error
- func (*NoOpLoanNotifier) NotifyRepaymentReminder(context.Context, contracts.LoanNotification) error
- type NoOpNotifier
- type Notifier
- type SMSAccountNotifier
- func (s *SMSAccountNotifier) NotifyAccountLocked(ctx context.Context, n contracts.AccountNotification) error
- func (s *SMSAccountNotifier) NotifyPINChangeFailed(ctx context.Context, n contracts.AccountNotification) error
- func (s *SMSAccountNotifier) NotifyPINChanged(ctx context.Context, n contracts.AccountNotification) error
- func (s *SMSAccountNotifier) NotifyPINReset(ctx context.Context, n contracts.AccountNotification) error
- func (s *SMSAccountNotifier) NotifyPINResetFailed(ctx context.Context, n contracts.AccountNotification) error
- func (s *SMSAccountNotifier) NotifyPINWrongAttempt(ctx context.Context, n contracts.AccountNotification) error
- func (s *SMSAccountNotifier) NotifyRegistrationFailed(ctx context.Context, n contracts.AccountNotification) error
- func (s *SMSAccountNotifier) NotifyRegistrationSuccess(ctx context.Context, n contracts.AccountNotification) error
- type SMSLoanNotifier
- func (s *SMSLoanNotifier) NotifyLoanApproved(ctx context.Context, n contracts.LoanNotification) error
- func (s *SMSLoanNotifier) NotifyLoanDisbursed(ctx context.Context, n contracts.LoanNotification) error
- func (s *SMSLoanNotifier) NotifyLoanFailed(ctx context.Context, n contracts.LoanNotification) error
- func (s *SMSLoanNotifier) NotifyLoanRejected(ctx context.Context, n contracts.LoanNotification) error
- func (s *SMSLoanNotifier) NotifyRepaymentReceived(ctx context.Context, n contracts.LoanNotification) error
- func (s *SMSLoanNotifier) NotifyRepaymentReminder(ctx context.Context, n contracts.LoanNotification) error
- type SMSNotifier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatPhoneNumber ¶
FormatPhoneNumber cleans a phone number string and prepends a country code when one is not already present.
Types ¶
type AccountTemplates ¶
type AccountTemplates struct {
// RegistrationSuccess formats the welcome message after successful
// registration. Args: (FullName string).
RegistrationSuccess string
// RegistrationFailed formats the message when registration cannot be
// completed. Args: (Reason string).
RegistrationFailed string
// WrongAttempt formats the alert sent when an incorrect PIN is entered.
// Args: (RemainingAttempts int).
WrongAttempt string
// AccountLocked formats the security alert sent when the account is
// locked due to repeated failed PIN attempts. Args: (LockedUntil string).
AccountLocked string
// PINChanged formats the confirmation sent after a successful PIN change.
// No format args.
PINChanged string
// PINChangeFailed formats the alert sent when a PIN change attempt fails.
// Args: (Reason string).
PINChangeFailed string
// PINReset formats the confirmation sent after a successful PIN reset via
// the recovery flow. No format args.
PINReset string
// PINResetFailed formats the alert sent when a PIN reset attempt fails.
// Args: (Reason string).
PINResetFailed string
}
AccountTemplates contains fmt.Sprintf-style format strings for account and PIN lifecycle notification messages. Each field documents its expected arguments.
func DefaultAccountTemplates ¶
func DefaultAccountTemplates() *AccountTemplates
DefaultAccountTemplates returns sensible default templates for all account and PIN notification messages. Pass nil to NewSMSAccountNotifier to use these defaults.
type LoanTemplates ¶
type LoanTemplates struct {
// Approved: args = (DisplayCurrency, DisplayAmount, LoanNumber)
Approved string
// Rejected: args = (DisplayCurrency, DisplayAmount, Reason)
Rejected string
// Disbursed: args = (DisplayCurrency, DisplayAmount, LoanNumber)
Disbursed string
// Failed: args = (LoanNumber)
Failed string
// RepaymentReceived: args = (DisplayCurrency, DisplayAmount, LoanNumber, DisplayCurrency, RemainingBalance)
RepaymentReceived string
// RepaymentOverdue: args = (DisplayCurrency, DisplayAmount, LoanNumber)
RepaymentOverdue string
// RepaymentSoon: args = (DisplayCurrency, DisplayAmount, daysUntilDue, LoanNumber)
RepaymentSoon string
// RepaymentUpcoming: args = (DisplayCurrency, DisplayAmount, dueDateFormatted, LoanNumber)
RepaymentUpcoming string
}
LoanTemplates contains format strings for each loan lifecycle notification. Each template uses fmt.Sprintf-style verbs; the exact arguments are documented per-field.
func DefaultLoanTemplates ¶
func DefaultLoanTemplates() *LoanTemplates
DefaultLoanTemplates returns templates matching the current microvault-credit messages but parameterized for any currency.
type NoOpAccountNotifier ¶
type NoOpAccountNotifier struct{}
NoOpAccountNotifier silently discards all account notifications. It is useful for testing and environments where SMS delivery is not configured.
func (*NoOpAccountNotifier) NotifyAccountLocked ¶
func (*NoOpAccountNotifier) NotifyAccountLocked(context.Context, contracts.AccountNotification) error
func (*NoOpAccountNotifier) NotifyPINChangeFailed ¶
func (*NoOpAccountNotifier) NotifyPINChangeFailed(context.Context, contracts.AccountNotification) error
func (*NoOpAccountNotifier) NotifyPINChanged ¶
func (*NoOpAccountNotifier) NotifyPINChanged(context.Context, contracts.AccountNotification) error
func (*NoOpAccountNotifier) NotifyPINReset ¶
func (*NoOpAccountNotifier) NotifyPINReset(context.Context, contracts.AccountNotification) error
func (*NoOpAccountNotifier) NotifyPINResetFailed ¶
func (*NoOpAccountNotifier) NotifyPINResetFailed(context.Context, contracts.AccountNotification) error
func (*NoOpAccountNotifier) NotifyPINWrongAttempt ¶
func (*NoOpAccountNotifier) NotifyPINWrongAttempt(context.Context, contracts.AccountNotification) error
func (*NoOpAccountNotifier) NotifyRegistrationFailed ¶
func (*NoOpAccountNotifier) NotifyRegistrationFailed(context.Context, contracts.AccountNotification) error
func (*NoOpAccountNotifier) NotifyRegistrationSuccess ¶
func (*NoOpAccountNotifier) NotifyRegistrationSuccess(context.Context, contracts.AccountNotification) error
type NoOpLoanNotifier ¶
type NoOpLoanNotifier struct{}
NoOpLoanNotifier discards all loan notifications silently.
func (*NoOpLoanNotifier) NotifyLoanApproved ¶
func (*NoOpLoanNotifier) NotifyLoanApproved(context.Context, contracts.LoanNotification) error
func (*NoOpLoanNotifier) NotifyLoanDisbursed ¶
func (*NoOpLoanNotifier) NotifyLoanDisbursed(context.Context, contracts.LoanNotification) error
func (*NoOpLoanNotifier) NotifyLoanFailed ¶
func (*NoOpLoanNotifier) NotifyLoanFailed(context.Context, contracts.LoanNotification) error
func (*NoOpLoanNotifier) NotifyLoanRejected ¶
func (*NoOpLoanNotifier) NotifyLoanRejected(context.Context, contracts.LoanNotification) error
func (*NoOpLoanNotifier) NotifyRepaymentReceived ¶
func (*NoOpLoanNotifier) NotifyRepaymentReceived(context.Context, contracts.LoanNotification) error
func (*NoOpLoanNotifier) NotifyRepaymentReminder ¶
func (*NoOpLoanNotifier) NotifyRepaymentReminder(context.Context, contracts.LoanNotification) error
type NoOpNotifier ¶
type NoOpNotifier struct{}
NoOpNotifier silently discards all messages. Useful for testing and environments where notifications are not configured.
type Notifier ¶
Notifier is a thin send-only interface that decouples notification logic from the underlying transport (SMS, push, email, etc.).
type SMSAccountNotifier ¶
type SMSAccountNotifier struct {
// contains filtered or unexported fields
}
SMSAccountNotifier implements contracts.AccountNotifier by formatting notification messages from AccountTemplates and delivering them through a Notifier transport (typically SMS).
func NewSMSAccountNotifier ¶
func NewSMSAccountNotifier(notifier Notifier, templates *AccountTemplates) *SMSAccountNotifier
NewSMSAccountNotifier creates a new SMSAccountNotifier. If templates is nil, DefaultAccountTemplates is used.
func (*SMSAccountNotifier) NotifyAccountLocked ¶
func (s *SMSAccountNotifier) NotifyAccountLocked(ctx context.Context, n contracts.AccountNotification) error
NotifyAccountLocked sends a security alert when the account is locked.
func (*SMSAccountNotifier) NotifyPINChangeFailed ¶
func (s *SMSAccountNotifier) NotifyPINChangeFailed(ctx context.Context, n contracts.AccountNotification) error
NotifyPINChangeFailed sends an alert when a PIN change attempt is unsuccessful.
func (*SMSAccountNotifier) NotifyPINChanged ¶
func (s *SMSAccountNotifier) NotifyPINChanged(ctx context.Context, n contracts.AccountNotification) error
NotifyPINChanged sends a confirmation after a successful PIN change.
func (*SMSAccountNotifier) NotifyPINReset ¶
func (s *SMSAccountNotifier) NotifyPINReset(ctx context.Context, n contracts.AccountNotification) error
NotifyPINReset sends a confirmation after a successful PIN reset.
func (*SMSAccountNotifier) NotifyPINResetFailed ¶
func (s *SMSAccountNotifier) NotifyPINResetFailed(ctx context.Context, n contracts.AccountNotification) error
NotifyPINResetFailed sends an alert when a PIN reset attempt fails.
func (*SMSAccountNotifier) NotifyPINWrongAttempt ¶
func (s *SMSAccountNotifier) NotifyPINWrongAttempt(ctx context.Context, n contracts.AccountNotification) error
NotifyPINWrongAttempt sends a warning after an incorrect PIN entry.
func (*SMSAccountNotifier) NotifyRegistrationFailed ¶
func (s *SMSAccountNotifier) NotifyRegistrationFailed(ctx context.Context, n contracts.AccountNotification) error
NotifyRegistrationFailed sends an alert when registration cannot be completed.
func (*SMSAccountNotifier) NotifyRegistrationSuccess ¶
func (s *SMSAccountNotifier) NotifyRegistrationSuccess(ctx context.Context, n contracts.AccountNotification) error
NotifyRegistrationSuccess sends a welcome message after successful registration.
type SMSLoanNotifier ¶
type SMSLoanNotifier struct {
// contains filtered or unexported fields
}
SMSLoanNotifier implements contracts.LoanNotifier using a Notifier transport and configurable LoanTemplates.
func NewSMSLoanNotifier ¶
func NewSMSLoanNotifier(notifier Notifier, templates *LoanTemplates) *SMSLoanNotifier
NewSMSLoanNotifier creates a new SMSLoanNotifier. Pass nil for templates to use DefaultLoanTemplates().
func (*SMSLoanNotifier) NotifyLoanApproved ¶
func (s *SMSLoanNotifier) NotifyLoanApproved(ctx context.Context, n contracts.LoanNotification) error
func (*SMSLoanNotifier) NotifyLoanDisbursed ¶
func (s *SMSLoanNotifier) NotifyLoanDisbursed(ctx context.Context, n contracts.LoanNotification) error
func (*SMSLoanNotifier) NotifyLoanFailed ¶
func (s *SMSLoanNotifier) NotifyLoanFailed(ctx context.Context, n contracts.LoanNotification) error
func (*SMSLoanNotifier) NotifyLoanRejected ¶
func (s *SMSLoanNotifier) NotifyLoanRejected(ctx context.Context, n contracts.LoanNotification) error
func (*SMSLoanNotifier) NotifyRepaymentReceived ¶
func (s *SMSLoanNotifier) NotifyRepaymentReceived(ctx context.Context, n contracts.LoanNotification) error
func (*SMSLoanNotifier) NotifyRepaymentReminder ¶
func (s *SMSLoanNotifier) NotifyRepaymentReminder(ctx context.Context, n contracts.LoanNotification) error
type SMSNotifier ¶
type SMSNotifier struct {
// contains filtered or unexported fields
}
SMSNotifier implements Notifier by delegating to an sms.SMSProvider.
func NewSMSNotifier ¶
func NewSMSNotifier(provider sms.SMSProvider, from string) *SMSNotifier
NewSMSNotifier creates a new SMSNotifier.