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

from __future__ import annotations
from .usageevent import UsageEvent, UsageEventTypedDict
from paygentic_sdk.types import BaseModel
import pydantic
from typing import List, Literal
from typing_extensions import Annotated, TypedDict


BatchUsageEventResponseObject = Literal["batchUsageEvents",]


class FailedTypedDict(TypedDict):
    error: str
    r"""Error message describing why the event failed"""
    idempotency_key: str
    r"""Idempotency key of the failed event for identification"""
    index: int
    r"""Index of the failed event in the original request array"""


class Failed(BaseModel):
    error: str
    r"""Error message describing why the event failed"""

    idempotency_key: Annotated[str, pydantic.Field(alias="idempotencyKey")]
    r"""Idempotency key of the failed event for identification"""

    index: int
    r"""Index of the failed event in the original request array"""


class SummaryTypedDict(TypedDict):
    r"""Summary of batch processing results"""

    failed: int
    r"""Number of events that failed to be created"""
    successful: int
    r"""Number of successfully created events"""
    total: int
    r"""Total number of events in the batch"""


class Summary(BaseModel):
    r"""Summary of batch processing results"""

    failed: int
    r"""Number of events that failed to be created"""

    successful: int
    r"""Number of successfully created events"""

    total: int
    r"""Total number of events in the batch"""


class BatchUsageEventResponseTypedDict(TypedDict):
    object: BatchUsageEventResponseObject
    failed: List[FailedTypedDict]
    r"""Array of events that failed to be created with error details"""
    successful: List[UsageEventTypedDict]
    r"""Array of successfully created usage events"""
    summary: SummaryTypedDict
    r"""Summary of batch processing results"""


class BatchUsageEventResponse(BaseModel):
    object: BatchUsageEventResponseObject

    failed: List[Failed]
    r"""Array of events that failed to be created with error details"""

    successful: List[UsageEvent]
    r"""Array of successfully created usage events"""

    summary: Summary
    r"""Summary of batch processing results"""


try:
    Failed.model_rebuild()
except NameError:
    pass
