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

from __future__ import annotations
from .getintegrationsintegrationidintegrationfieldspositiveresponse import (
    GetIntegrationsIntegrationIDIntegrationFieldsPositiveResponse,
    GetIntegrationsIntegrationIDIntegrationFieldsPositiveResponseTypedDict,
)
from kombo.types import BaseModel, UNSET_SENTINEL
from kombo.utils import FieldMetadata, PathParamMetadata, QueryParamMetadata
from pydantic import model_serializer
from typing import Awaitable, Callable, Optional, Union
from typing_extensions import Annotated, NotRequired, TypedDict


class GetIntegrationsIntegrationIDIntegrationFieldsRequestTypedDict(TypedDict):
    integration_id: str
    r"""GET /integrations/:integration_id/integration-fields Parameter"""
    cursor: NotRequired[str]
    r"""An optional cursor string used for pagination. This can be retrieved from the `next` property of the previous page response."""
    page_size: NotRequired[int]
    r"""The number of results to return per page. Maximum is 2000."""


class GetIntegrationsIntegrationIDIntegrationFieldsRequest(BaseModel):
    integration_id: Annotated[
        str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
    ]
    r"""GET /integrations/:integration_id/integration-fields Parameter"""

    cursor: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""An optional cursor string used for pagination. This can be retrieved from the `next` property of the previous page response."""

    page_size: Annotated[
        Optional[int],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = 100
    r"""The number of results to return per page. Maximum is 2000."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["cursor", "page_size"])
        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 GetIntegrationsIntegrationIDIntegrationFieldsResponseTypedDict(TypedDict):
    result: GetIntegrationsIntegrationIDIntegrationFieldsPositiveResponseTypedDict


class GetIntegrationsIntegrationIDIntegrationFieldsResponse(BaseModel):
    next: Union[
        Callable[[], Optional[GetIntegrationsIntegrationIDIntegrationFieldsResponse]],
        Callable[
            [],
            Awaitable[Optional[GetIntegrationsIntegrationIDIntegrationFieldsResponse]],
        ],
    ]

    result: GetIntegrationsIntegrationIDIntegrationFieldsPositiveResponse
