API Reference
Auto-generated from source docstrings. All public symbols are importable from the
facades described below — you do not need to import from notificator.domain or
notificator.infra directly.
Root package
The notificator root re-exports the domain primitives you need in every call site:
from notificator import (
AsyncClosable,
EmailAddress,
NotificationClient,
NotificationContent,
NotificationError,
PhoneNumber,
)
notificator.domain.value_objects
Domain value objects used by notification clients.
NotificationContent
dataclass
A unified domain object representing the notification payload.
Source code in src/notificator/domain/value_objects.py
notificator.domain.types
Module containing static type markers used by notificator.
notificator.domain.ports
Domain-facing interfaces for notification delivery clients.
AsyncClosable
Bases: Protocol
Port for safely tearing down infrastructure adapters.
Source code in src/notificator/domain/ports.py
NotificationClient
Bases: Protocol
Protocol for notification transports (email, SMS, etc.).
Source code in src/notificator/domain/ports.py
notify(content, *, recipient)
async
Send a notification payload to a recipient.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
NotificationContent
|
Notification payload describing body, subject, and other metadata. |
required |
recipient
|
RecipientT
|
Transport-specific recipient identifier (email, phone, etc.). |
required |
Source code in src/notificator/domain/ports.py
notify_from_template(template, *, recipient, version=None, **variables)
async
Send a notification using a stored template and variables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
template
|
str
|
Provider template identifier. |
required |
recipient
|
RecipientT
|
Transport-specific recipient identifier (email, phone, etc.). |
required |
version
|
str | None
|
Optional provider template version alias or ID. |
None
|
**variables
|
str
|
Template variables to inject into the message. |
{}
|
Source code in src/notificator/domain/ports.py
notificator.domain.exceptions
Email — notificator.mail
notificator.infra.mail_clients.mailgun_client
Mailgun-backed email notification client implementation.
MailgunClient
Bases: NotificationClient[EmailAddress], AsyncClosable
Send email notifications via the Mailgun HTTP API.
Source code in src/notificator/infra/mail_clients/mailgun_client.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
__init__(domain, *, default_subject=None, api_key=None, base_url='https://api.eu.mailgun.net/v3', sender_email, sender_display_name, http_client=None)
Initialize a Mailgun-backed notification client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
domain
|
str
|
Mailgun domain used to send messages. |
required |
default_subject
|
str | None
|
Default subject line for emails without an explicit subject. |
None
|
api_key
|
str | None
|
Mailgun API key. Optional if |
None
|
base_url
|
str
|
Mailgun API base URL. |
'https://api.eu.mailgun.net/v3'
|
sender_email
|
str
|
Email address used in the From header. |
required |
sender_display_name
|
str
|
Display name used in the From header. |
required |
http_client
|
AsyncClient | None
|
Optional preconfigured |
None
|
Raises:
| Type | Description |
|---|---|
MissingClientAuthError
|
Raised when neither |
MalformedClientUrlError
|
Raised when |
Source code in src/notificator/infra/mail_clients/mailgun_client.py
aclose()
async
notify(content, *, recipient)
async
Send a plain email notification without templates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
NotificationContent
|
Notification payload with body and optional subject. |
required |
recipient
|
EmailAddress
|
Email address to receive the notification. |
required |
Source code in src/notificator/infra/mail_clients/mailgun_client.py
notify_from_template(template, *, recipient, version=None, **variables)
async
Send a Mailgun template-based email to a recipient.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
template
|
str
|
Mailgun template name. |
required |
recipient
|
EmailAddress
|
Email address to receive the notification. |
required |
version
|
str | None
|
Optional Mailgun template version. |
None
|
**variables
|
str
|
Template variables to interpolate. |
{}
|
Source code in src/notificator/infra/mail_clients/mailgun_client.py
notificator.infra.mail_clients.exceptions
Base module for mail clients exceptions.
EmailNotificationMissingSubjectError
Bases: MailNotificationError
Exception raised when an email notification is missing a subject.
Source code in src/notificator/infra/mail_clients/exceptions.py
__init__()
Initialize the error for missing notification subject.
Source code in src/notificator/infra/mail_clients/exceptions.py
MailAPIError
Bases: MailNotificationError
Exception raised when an error occurs while making an API call.
MailNotificationError
Bases: NotificationError
Base exception for mail clients errors.
MalformedClientUrlError
Bases: MailNotificationError
Exception raised when mail client base_url is malformed.
Source code in src/notificator/infra/mail_clients/exceptions.py
__init__(base_url)
Initialize the error with the invalid base URL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_url
|
str
|
The malformed base URL provided to the client. |
required |
Source code in src/notificator/infra/mail_clients/exceptions.py
MalformedRecipientEmailError
Bases: MailNotificationError
Exception raised when a recipient email is malformed.
Source code in src/notificator/infra/mail_clients/exceptions.py
__init__(recipient)
Initialize the error with the invalid recipient email.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
recipient
|
str
|
The invalid email address provided to the client. |
required |
Source code in src/notificator/infra/mail_clients/exceptions.py
MissingClientAuthError
Bases: MailNotificationError
Exception raised when a mailclient authorization is missing.
Source code in src/notificator/infra/mail_clients/exceptions.py
__init__()
Initialize the error for missing Mailgun authentication.
SMS — notificator.sms
notificator.infra.sms_clients.twilio_sms_client
Twilio-backed SMS notification client implementation.
TwilioSmsClient
Bases: NotificationClient[PhoneNumber], AsyncClosable
Send SMS notifications via Twilio's REST API.
Source code in src/notificator/infra/sms_clients/twilio_sms_client.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
__init__(account_sid, token, *, templates=None, twilio_http_client=None, messaging_service_sid=None, sender_phone_number=None)
Initialize a Twilio-backed SMS notification client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
account_sid
|
str
|
Twilio account SID. |
required |
token
|
str
|
Twilio auth token. |
required |
templates
|
list[TwilioSmsTemplate | str] | None
|
Optional list of templates, either str representing sid or TwilioSmsTemplate data objects, allowing custom versioning. |
None
|
twilio_http_client
|
AsyncHttpClient | None
|
Optional async HTTP client for Twilio. |
None
|
messaging_service_sid
|
str | None
|
Optional messaging service SID. |
None
|
sender_phone_number
|
PhoneNumber | None
|
Optional sender phone number in E.164 format. |
None
|
Raises:
| Type | Description |
|---|---|
TwilioMissingSenderIdError
|
Raised when neither sender phone number nor messaging service SID is provided. |
InvalidPhoneNumberFormatError
|
Raised when |
Source code in src/notificator/infra/sms_clients/twilio_sms_client.py
aclose()
async
Close the underlying Twilio HTTP client if it is async-aware.
notify(content, *, recipient)
async
Send a plain SMS message to a recipient.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
NotificationContent
|
Notification payload containing the message body. |
required |
recipient
|
PhoneNumber
|
E.164-compatible phone number to receive the SMS. |
required |
Source code in src/notificator/infra/sms_clients/twilio_sms_client.py
notify_from_template(template, *, recipient, version=None, **variables)
async
Send a Twilio Content API template with injected variables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
template
|
str
|
Template identifier registered in Twilio. |
required |
recipient
|
PhoneNumber
|
E.164-compatible phone number to receive the SMS. |
required |
version
|
str | None
|
Optional template version alias or ID to resolve. |
None
|
**variables
|
str
|
Template variables to inject into the message. |
{}
|
Source code in src/notificator/infra/sms_clients/twilio_sms_client.py
TwilioSmsTemplate
dataclass
Template metadata for Twilio Content API usage.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
Twilio Content SID for the template or a friendly name if using registry anyway. |
version_registry |
dict[str, str]
|
Optional mapping of friendly version names to Content SIDs. |
Source code in src/notificator/infra/sms_clients/twilio_sms_client.py
notificator.infra.sms_clients.exceptions
Base module for sms clients exceptions.
InvalidPhoneNumberFormatError
Bases: SmsNotificationError
Raised when a phone number format is invalid for a client.
Source code in src/notificator/infra/sms_clients/exceptions.py
__init__(phone_number, expected_format='E164')
Initialize the error with the invalid phone number and expected format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
phone_number
|
str
|
The provided phone number. |
required |
expected_format
|
str
|
The expected phone number format. |
'E164'
|
Source code in src/notificator/infra/sms_clients/exceptions.py
SmsAPIError
Bases: SmsNotificationError
Exception raised when an error occurs while making an API call.
SmsNotificationError
Bases: NotificationError
Base exception for sms notification errors.
TemplateNotProvidedError
Bases: SmsNotificationError
Raised when requested to use a template that is not available for this client.
Source code in src/notificator/infra/sms_clients/exceptions.py
__init__(template_name)
Initialize the error with the missing template name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
template_name
|
str
|
The template identifier not configured for this client. |
required |
Source code in src/notificator/infra/sms_clients/exceptions.py
TemplateVersionNotAvailableError
Bases: SmsNotificationError
Raised when a template version is not available.
Source code in src/notificator/infra/sms_clients/exceptions.py
__init__(template_name, version)
Initialize the error with the missing template version.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
template_name
|
str
|
Template identifier requested by the caller. |
required |
version
|
str
|
Template version that could not be resolved. |
required |
Source code in src/notificator/infra/sms_clients/exceptions.py
TwilioMissingSenderIdError
Bases: SmsNotificationError
Raised when a twilio client is missing a sender identity.
Source code in src/notificator/infra/sms_clients/exceptions.py
__init__()
Initialize the error for a missing sender identity.