from pydantic import BaseModel from typing import Dict, Any, Optional from datetime import datetime from app.models.integration import WebhookStatus, IntegrationType class WebhookEventCreate(BaseModel): external_id: str event_type: str payload: Dict[str, Any] integration_type: IntegrationType organization_id: int class WebhookEventResponse(BaseModel): id: int organization_id: int integration_id: int external_id: str event_type: str payload: Dict[str, Any] status: WebhookStatus retry_count: int max_retries: int error_message: Optional[str] = None processed_at: Optional[datetime] = None created_at: datetime updated_at: Optional[datetime] = None class Config: from_attributes = True class WebhookPayloadBase(BaseModel): """Base webhook payload structure""" event_id: str event_type: str timestamp: datetime data: Dict[str, Any] class UserWebhookPayload(WebhookPayloadBase): """User management service webhook payload""" pass class PaymentWebhookPayload(WebhookPayloadBase): """Payment service webhook payload""" pass class CommunicationWebhookPayload(WebhookPayloadBase): """Communication service webhook payload""" pass