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

from __future__ import annotations
from datetime import datetime
from factify.types import BaseModel, UNSET_SENTINEL
from pydantic import model_serializer
from typing import Dict, Optional
from typing_extensions import NotRequired, TypedDict


class ExportDocumentResponseTypedDict(TypedDict):
    r"""ExportDocumentResponse contains the download URL."""

    expires_at: datetime
    r"""Timestamp when the download URL expires."""
    url: str
    r"""Presigned URL to download the document PDF."""
    headers: NotRequired[Dict[str, str]]
    r"""HTTP headers to include when fetching the URL."""


class ExportDocumentResponse(BaseModel):
    r"""ExportDocumentResponse contains the download URL."""

    expires_at: datetime
    r"""Timestamp when the download URL expires."""

    url: str
    r"""Presigned URL to download the document PDF."""

    headers: Optional[Dict[str, str]] = None
    r"""HTTP headers to include when fetching the URL."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["headers"])
        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
