from typing import Any

from pydantic import BaseModel, Field


class AlpineBitsHandshakeRequest(BaseModel):
    """Model for AlpineBits handshake request data"""

    action: str = Field(
        ..., description="Action parameter, typically 'OTA_Ping:Handshaking'"
    )
    request_xml: str | None = Field(None, description="XML request document")


class ContactName(BaseModel):
    """Contact name structure"""

    first: str | None = None
    last: str | None = None


class ContactAddress(BaseModel):
    """Contact address structure"""

    street: str | None = None
    city: str | None = None
    state: str | None = None
    country: str | None = None
    postalCode: str | None = None


class Contact(BaseModel):
    """Contact information from Wix form"""

    name: ContactName | None = None
    email: str | None = None
    locale: str | None = None
    company: str | None = None
    birthdate: str | None = None
    labelKeys: dict[str, Any] | None = None
    contactId: str | None = None
    address: ContactAddress | None = None
    jobTitle: str | None = None
    imageUrl: str | None = None
    updatedDate: str | None = None
    phone: str | None = None
    createdDate: str | None = None


class SubmissionPdf(BaseModel):
    """PDF submission structure"""

    url: str | None = None
    filename: str | None = None


class WixFormSubmission(BaseModel):
    """Model for Wix form submission data"""

    formName: str
    submissions: list[dict[str, Any]] = Field(default_factory=list)
    submissionTime: str
    formFieldMask: list[str] = Field(default_factory=list)
    submissionId: str
    contactId: str
    submissionsLink: str
    submissionPdf: SubmissionPdf | None = None
    formId: str
    contact: Contact | None = None

    # Dynamic form fields - these will capture all field:* entries
    class Config:
        extra = "allow"  # Allow additional fields not defined in the model
