"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from .listdocumentduplicatesresponse import (
    ListDocumentDuplicatesResponse,
    ListDocumentDuplicatesResponseTypedDict,
)
from factify.types import BaseModel, UNSET_SENTINEL
from factify.utils import FieldMetadata, PathParamMetadata, QueryParamMetadata
from pydantic import model_serializer
from typing import Dict, List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class ListDocumentDuplicatesRequestTypedDict(TypedDict):
    document_id: str
    r"""Document ID to check for duplicates."""
    file_contents_hash: NotRequired[str]
    r"""SHA256 hash of the document's visual content for duplicate matching."""


class ListDocumentDuplicatesRequest(BaseModel):
    document_id: Annotated[
        str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
    ]
    r"""Document ID to check for duplicates."""

    file_contents_hash: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""SHA256 hash of the document's visual content for duplicate matching."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["file_contents_hash"])
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k, serialized.get(n))

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


class ListDocumentDuplicatesResponseResponseTypedDict(TypedDict):
    headers: Dict[str, List[str]]
    result: ListDocumentDuplicatesResponseTypedDict


class ListDocumentDuplicatesResponseResponse(BaseModel):
    headers: Dict[str, List[str]]

    result: ListDocumentDuplicatesResponse
