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

from __future__ import annotations
from flexprice_py.types import BaseModel, UNSET_SENTINEL
from pydantic import model_serializer
from typing import Dict, Optional
from typing_extensions import NotRequired, TypedDict


class DtoUpdatePaymentRequestTypedDict(TypedDict):
    error_message: NotRequired[str]
    failed_at: NotRequired[str]
    gateway_payment_id: NotRequired[str]
    metadata: NotRequired[Dict[str, str]]
    payment_gateway: NotRequired[str]
    payment_method_id: NotRequired[str]
    payment_status: NotRequired[str]
    succeeded_at: NotRequired[str]


class DtoUpdatePaymentRequest(BaseModel):
    error_message: Optional[str] = None

    failed_at: Optional[str] = None

    gateway_payment_id: Optional[str] = None

    metadata: Optional[Dict[str, str]] = None

    payment_gateway: Optional[str] = None

    payment_method_id: Optional[str] = None

    payment_status: Optional[str] = None

    succeeded_at: Optional[str] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "error_message",
                "failed_at",
                "gateway_payment_id",
                "metadata",
                "payment_gateway",
                "payment_method_id",
                "payment_status",
                "succeeded_at",
            ]
        )
        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
