ifixkart-backend/app/schemas/NotificationGateway.py

69 lines
1.8 KiB
Python

from datetime import datetime
from typing import Optional, List
from pydantic import BaseModel, Field
class NotificationDispatchCreate(BaseModel):
recipient: str = Field(..., description="Phone number for WhatsApp/SMS or Email address")
channel: str = Field(..., description="WHATSAPP, EMAIL, or WEB_PUSH")
subject: Optional[str] = None
message_body: str
template_id: Optional[str] = None
class NotificationAttemptResponse(BaseModel):
attempt_id: str
notification_id: str
attempt_number: int
provider: str
request_id: Optional[str] = None
status: str
error_log: Optional[str] = None
created_at: datetime
class Config:
from_attributes = True
class NotificationResponse(BaseModel):
notification_id: str
tenant_id: str
event_id: Optional[str] = None
recipient: str
channel: str
template_id: Optional[str] = None
status: str
subject: Optional[str] = None
message_body: str
completed_at: Optional[datetime] = None
created_at: datetime
attempts: List[NotificationAttemptResponse] = []
class Config:
from_attributes = True
class DeadLetterNotificationResponse(BaseModel):
dlq_id: str
tenant_id: str
notification_id: str
reason: str
failed_at: datetime
is_resolved: bool
resolved_at: Optional[datetime] = None
class Config:
from_attributes = True
class WhatsAppSessionStatusResponse(BaseModel):
session_id: str
tenant_id: str
session_name: str
status: str
battery_level: Optional[int] = None
last_ping_at: Optional[datetime] = None
class Config:
from_attributes = True
class WhatsAppSessionQRResponse(BaseModel):
session_id: str
session_name: str
status: str
qr_code_base64: Optional[str] = None