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

from __future__ import annotations
from moovio_sdk.models.components import (
    createreversal as components_createreversal,
    reversal as components_reversal,
)
from moovio_sdk.types import BaseModel, UNSET_SENTINEL
from moovio_sdk.utils import (
    FieldMetadata,
    HeaderMetadata,
    PathParamMetadata,
    RequestMetadata,
)
import pydantic
from pydantic import model_serializer
from typing import Dict, List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class CreateReversalRequestTypedDict(TypedDict):
    x_idempotency_key: str
    r"""Prevents duplicate reversals from being created."""
    account_id: str
    r"""The Moov account ID."""
    transfer_id: str
    r"""The transfer ID to reverse."""
    create_reversal: NotRequired[components_createreversal.CreateReversalTypedDict]


class CreateReversalRequest(BaseModel):
    x_idempotency_key: Annotated[
        str,
        pydantic.Field(alias="x-idempotency-key"),
        FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
    ]
    r"""Prevents duplicate reversals from being created."""

    account_id: Annotated[
        str,
        pydantic.Field(alias="accountID"),
        FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
    ]
    r"""The Moov account ID."""

    transfer_id: Annotated[
        str,
        pydantic.Field(alias="transferID"),
        FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
    ]
    r"""The transfer ID to reverse."""

    create_reversal: Annotated[
        Optional[components_createreversal.CreateReversal],
        FieldMetadata(request=RequestMetadata(media_type="application/json")),
    ] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["CreateReversal"])
        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 CreateReversalResponseTypedDict(TypedDict):
    headers: Dict[str, List[str]]
    result: components_reversal.ReversalTypedDict


class CreateReversalResponse(BaseModel):
    headers: Dict[str, List[str]]

    result: components_reversal.Reversal
