"""
DSR (Data Subject Request) schemas — Betroffenenanfragen nach DSGVO Art. 15-21.

Phase 1 Step 4: extracted from ``compliance.api.dsr_routes``.
"""

from typing import Any, Dict, List, Optional

from pydantic import BaseModel


class DSRCreate(BaseModel):
    request_type: str = "access"
    requester_name: str
    requester_email: str
    requester_phone: Optional[str] = None
    requester_address: Optional[str] = None
    requester_customer_id: Optional[str] = None
    source: str = "email"
    source_details: Optional[str] = None
    request_text: Optional[str] = None
    priority: Optional[str] = "normal"
    notes: Optional[str] = None


class DSRUpdate(BaseModel):
    priority: Optional[str] = None
    notes: Optional[str] = None
    internal_notes: Optional[str] = None
    assigned_to: Optional[str] = None
    request_text: Optional[str] = None
    affected_systems: Optional[List[str]] = None
    erasure_checklist: Optional[List[Dict[str, Any]]] = None
    rectification_details: Optional[Dict[str, Any]] = None
    objection_details: Optional[Dict[str, Any]] = None


class StatusChange(BaseModel):
    status: str
    comment: Optional[str] = None


class VerifyIdentity(BaseModel):
    method: str
    notes: Optional[str] = None
    document_ref: Optional[str] = None


class AssignRequest(BaseModel):
    assignee_id: str


class ExtendDeadline(BaseModel):
    reason: str
    days: Optional[int] = 60


class CompleteDSR(BaseModel):
    summary: Optional[str] = None
    result_data: Optional[Dict[str, Any]] = None


class RejectDSR(BaseModel):
    reason: str
    legal_basis: Optional[str] = None


class SendCommunication(BaseModel):
    communication_type: str = "outgoing"
    channel: str = "email"
    subject: Optional[str] = None
    content: str
    template_used: Optional[str] = None


class UpdateExceptionCheck(BaseModel):
    applies: bool
    notes: Optional[str] = None


class CreateTemplateVersion(BaseModel):
    version: str = "1.0"
    language: Optional[str] = "de"
    subject: str
    body_html: str
    body_text: Optional[str] = None


__all__ = [
    "DSRCreate",
    "DSRUpdate",
    "StatusChange",
    "VerifyIdentity",
    "AssignRequest",
    "ExtendDeadline",
    "CompleteDSR",
    "RejectDSR",
    "SendCommunication",
    "UpdateExceptionCheck",
    "CreateTemplateVersion",
]
