- New models: WarrantyModel, WalletModel, SystemConfigModel - New schemas: WarrantySchema, RefundSchema, SystemConfig, CrmTaskCalendar, NotificationTemplate, NotificationGateway, RepairErp, ReviewModeration, InventoryPos, MultiDashboard, BillingFinance - New services: WarrantyService, RefundService, CrmService, CrmTaskCalendarService, DeliveryService, EmailTemplateService, InventoryPosService, MultiDashboardService, NotificationGatewayService, RepairErpService, ReviewModerationService, SystemConfigService, TemplateService, CreditService - Updated routers: AdminOrder, BillingFinance, Cart, Catalog, Checkout, Crm, InventoryPos, NotificationGateway, RolePermission, ServiceJob, Settings, Storefront, UserCreation - Updated models: Inventory, Notification, Order, Product, Service, Setting, SystemConfig, User - Updated core: database init, invoice generator, main app - Added WarrantyRouter with full CRUD and claim flow
85 lines
2.6 KiB
Python
85 lines
2.6 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 EntityNotificationDispatchCreate(BaseModel):
|
|
channel: str = Field(..., description="EMAIL, WHATSAPP, or BOTH")
|
|
notification_type: str = Field(..., description="QUOTATION, INVOICE, REPAIR_TICKET, LEAD_QUALIFIED")
|
|
entity_id: str = Field(..., description="Primary key or quote number, e.g., SQ-2026-001")
|
|
idempotency_key: Optional[str] = Field(None, description="Explicit client or backend idempotency key")
|
|
custom_note: Optional[str] = Field(None, description="Optional custom note or staff instruction")
|
|
|
|
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
|
|
notification_type: Optional[str] = None
|
|
entity_id: Optional[str] = None
|
|
idempotency_key: Optional[str] = None
|
|
recipient: str
|
|
channel: str
|
|
template_id: Optional[str] = None
|
|
status: str
|
|
subject: Optional[str] = None
|
|
message_body: str
|
|
attempt_count: int = 0
|
|
last_attempt_at: Optional[datetime] = None
|
|
next_retry_at: Optional[datetime] = None
|
|
last_error: Optional[str] = None
|
|
provider_response: Optional[str] = None
|
|
is_duplicate: bool = False
|
|
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
|