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

from __future__ import annotations
from .disputewithcustomer import DisputeWithCustomer, DisputeWithCustomerTypedDict
from paygentic_sdk.types import BaseModel, UNSET_SENTINEL
from paygentic_sdk.utils import FieldMetadata, QueryParamMetadata
import pydantic
from pydantic import model_serializer
from typing import List, Literal, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


ListDisputesStatus = Literal[
    "pending",
    "accepted",
    "declined",
]
r"""Filter by dispute status"""


class ListDisputesRequestTypedDict(TypedDict):
    consumer_id: NotRequired[str]
    r"""Filter disputes for a specific consumer. At least one of merchantId, customerId, or consumerId must be provided."""
    customer_id: NotRequired[str]
    r"""Filter disputes for a specific customer. At least one of merchantId, customerId, or consumerId must be provided."""
    limit: NotRequired[int]
    r"""Number of disputes to return"""
    merchant_id: NotRequired[str]
    r"""Filter disputes for a specific merchant. At least one of merchantId, customerId, or consumerId must be provided."""
    offset: NotRequired[int]
    r"""Number of disputes to skip"""
    status: NotRequired[ListDisputesStatus]
    r"""Filter by dispute status"""


class ListDisputesRequest(BaseModel):
    consumer_id: Annotated[
        Optional[str],
        pydantic.Field(alias="consumerId"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Filter disputes for a specific consumer. At least one of merchantId, customerId, or consumerId must be provided."""

    customer_id: Annotated[
        Optional[str],
        pydantic.Field(alias="customerId"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Filter disputes for a specific customer. At least one of merchantId, customerId, or consumerId must be provided."""

    limit: Annotated[
        Optional[int],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = 10
    r"""Number of disputes to return"""

    merchant_id: Annotated[
        Optional[str],
        pydantic.Field(alias="merchantId"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Filter disputes for a specific merchant. At least one of merchantId, customerId, or consumerId must be provided."""

    offset: Annotated[
        Optional[int],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = 0
    r"""Number of disputes to skip"""

    status: Annotated[
        Optional[ListDisputesStatus],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Filter by dispute status"""

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


ListDisputesObject = Literal["list",]


class ListDisputesPaginationTypedDict(TypedDict):
    limit: int
    offset: int
    total: int
    has_more: bool


class ListDisputesPagination(BaseModel):
    limit: int

    offset: int

    total: int

    has_more: Annotated[bool, pydantic.Field(alias="hasMore")]


class ListDisputesResponseTypedDict(TypedDict):
    r"""Disputes retrieved successfully"""

    object: ListDisputesObject
    data: List[DisputeWithCustomerTypedDict]
    pagination: ListDisputesPaginationTypedDict


class ListDisputesResponse(BaseModel):
    r"""Disputes retrieved successfully"""

    object: ListDisputesObject

    data: List[DisputeWithCustomer]

    pagination: ListDisputesPagination


try:
    ListDisputesPagination.model_rebuild()
except NameError:
    pass
