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

from __future__ import annotations
from .membertype import MemberType
from enum import Enum
from owasp_nest.types import (
    BaseModel,
    Nullable,
    OptionalNullable,
    UNSET,
    UNSET_SENTINEL,
)
from owasp_nest.utils import FieldMetadata, QueryParamMetadata
from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class ListSponsorsOrdering(str, Enum):
    r"""Ordering field"""

    NAME = "name"
    MINUS_NAME = "-name"


class ListSponsorsRequestTypedDict(TypedDict):
    is_member: NotRequired[Nullable[bool]]
    r"""Member status of the sponsor"""
    member_type: NotRequired[Nullable[MemberType]]
    r"""Member type of the sponsor"""
    sponsor_type: NotRequired[Nullable[str]]
    r"""Filter by the type of sponsorship (e.g., Gold, Silver, Platinum)."""
    ordering: NotRequired[Nullable[ListSponsorsOrdering]]
    r"""Ordering field"""
    page: NotRequired[int]
    r"""Page number"""
    page_size: NotRequired[int]
    r"""Number of items per page"""


class ListSponsorsRequest(BaseModel):
    is_member: Annotated[
        OptionalNullable[bool],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = UNSET
    r"""Member status of the sponsor"""

    member_type: Annotated[
        OptionalNullable[MemberType],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = UNSET
    r"""Member type of the sponsor"""

    sponsor_type: Annotated[
        OptionalNullable[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = UNSET
    r"""Filter by the type of sponsorship (e.g., Gold, Silver, Platinum)."""

    ordering: Annotated[
        OptionalNullable[ListSponsorsOrdering],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = UNSET
    r"""Ordering field"""

    page: Annotated[
        Optional[int],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = 1
    r"""Page number"""

    page_size: Annotated[
        Optional[int],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = 100
    r"""Number of items per page"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "is_member",
                "member_type",
                "sponsor_type",
                "ordering",
                "page",
                "page_size",
            ]
        )
        nullable_fields = set(["is_member", "member_type", "sponsor_type", "ordering"])
        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))
            is_nullable_and_explicitly_set = (
                k in nullable_fields
                and (self.__pydantic_fields_set__.intersection({n}))  # pylint: disable=no-member
            )

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

        return m
