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

from __future__ import annotations
from paygentic_sdk.types import BaseModel, UNSET_SENTINEL
from paygentic_sdk.utils import FieldMetadata, PathParamMetadata, RequestMetadata
import pydantic
from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class BulkApproveSourceEventsRequestBodyTypedDict(TypedDict):
    event_ids: List[str]
    r"""IDs of events to approve"""


class BulkApproveSourceEventsRequestBody(BaseModel):
    event_ids: Annotated[List[str], pydantic.Field(alias="eventIds")]
    r"""IDs of events to approve"""


class BulkApproveSourceEventsRequestTypedDict(TypedDict):
    id: str
    request_body: BulkApproveSourceEventsRequestBodyTypedDict


class BulkApproveSourceEventsRequest(BaseModel):
    id: Annotated[
        str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
    ]

    request_body: Annotated[
        BulkApproveSourceEventsRequestBody,
        FieldMetadata(request=RequestMetadata(media_type="application/json")),
    ]


class BulkApproveSourceEventsFailedTypedDict(TypedDict):
    id: NotRequired[str]
    error: NotRequired[str]


class BulkApproveSourceEventsFailed(BaseModel):
    id: Optional[str] = None

    error: Optional[str] = None

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

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

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

        return m


class BulkApproveSourceEventsDetailsTypedDict(TypedDict):
    processed: NotRequired[List[str]]
    r"""IDs of successfully processed events"""
    failed: NotRequired[List[BulkApproveSourceEventsFailedTypedDict]]
    r"""Failed events with error messages"""


class BulkApproveSourceEventsDetails(BaseModel):
    processed: Optional[List[str]] = None
    r"""IDs of successfully processed events"""

    failed: Optional[List[BulkApproveSourceEventsFailed]] = None
    r"""Failed events with error messages"""

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

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

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

        return m


class BulkApproveSourceEventsResponseTypedDict(TypedDict):
    r"""Bulk approval results"""

    processed: NotRequired[int]
    r"""Number of successfully approved events"""
    failed: NotRequired[int]
    r"""Number of events that failed to process"""
    details: NotRequired[BulkApproveSourceEventsDetailsTypedDict]


class BulkApproveSourceEventsResponse(BaseModel):
    r"""Bulk approval results"""

    processed: Optional[int] = None
    r"""Number of successfully approved events"""

    failed: Optional[int] = None
    r"""Number of events that failed to process"""

    details: Optional[BulkApproveSourceEventsDetails] = None

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

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

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

        return m


try:
    BulkApproveSourceEventsRequestBody.model_rebuild()
except NameError:
    pass
