feat: initial commit
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
"""Wysyłka powiadomień do klientów przez acme-sdk."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from acme import Client
|
||||
from acme.errors import AcmeError
|
||||
|
||||
WELCOME_BODY = "Witamy w serwisie. Twoje konto jest aktywne."
|
||||
|
||||
|
||||
def send_welcome(email: str, api_key: str, endpoint: str) -> str:
|
||||
"""Wysyła powiadomienie powitalne i zwraca identyfikator wiadomości."""
|
||||
client = Client(api_key=api_key, endpoint=endpoint)
|
||||
result = client.send(to=email, body=WELCOME_BODY)
|
||||
client.close()
|
||||
return result["id"]
|
||||
|
||||
|
||||
def send_reminder(email: str, api_key: str, endpoint: str, body: str) -> str | None:
|
||||
"""Wysyła przypomnienie. Zwraca None, gdy dostawca odrzucił wiadomość."""
|
||||
client = Client(api_key=api_key, endpoint=endpoint)
|
||||
try:
|
||||
result = client.send(to=email, body=body)
|
||||
except AcmeError:
|
||||
return None
|
||||
client.close()
|
||||
return result["id"]
|
||||
Reference in New Issue
Block a user