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

from __future__ import annotations
from .note import Note, NoteTypedDict
from attio.types import BaseModel, UNSET_SENTINEL
from attio.utils import FieldMetadata, QueryParamMetadata
from pydantic import model_serializer
from typing import List, Literal, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class GetV2NotesRequestTypedDict(TypedDict):
    limit: NotRequired[int]
    offset: NotRequired[int]
    parent_object: NotRequired[str]
    parent_record_id: NotRequired[str]


class GetV2NotesRequest(BaseModel):
    limit: Annotated[
        Optional[int],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    offset: Annotated[
        Optional[int],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    parent_object: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    parent_record_id: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

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


GetV2NotesType = Literal["invalid_request_error",]


GetV2NotesCode = Literal["not_found",]


class GetV2NotesResponseTypedDict(TypedDict):
    r"""Success"""

    data: List[NoteTypedDict]


class GetV2NotesResponse(BaseModel):
    r"""Success"""

    data: List[Note]
