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

from __future__ import annotations
from .threedsecurescenarioconditions import (
    ThreeDSecureScenarioConditions,
    ThreeDSecureScenarioConditionsTypedDict,
)
from .threedsecurescenariooutcome import (
    ThreeDSecureScenarioOutcome,
    ThreeDSecureScenarioOutcomeTypedDict,
)
from datetime import datetime
from gr4vy.types import BaseModel, UNSET_SENTINEL
from gr4vy.utils import validate_const
import pydantic
from pydantic import model_serializer
from pydantic.functional_validators import AfterValidator
from typing import Literal, Optional
from typing_extensions import Annotated, TypedDict


class ThreeDSecureScenarioTypedDict(TypedDict):
    id: str
    r"""Unique identifier for the 3DS scenario"""
    merchant_account_id: str
    r"""ID of the associated merchant account"""
    created_at: datetime
    r"""The date and time when this 3DS scenario was first created in our system."""
    updated_at: datetime
    r"""The date and time when this 3DS scenario was last updated in our system."""
    conditions: ThreeDSecureScenarioConditionsTypedDict
    outcome: ThreeDSecureScenarioOutcomeTypedDict
    type: Literal["three-d-secure-scenario"]
    r"""Always `three-d-secure-scenario`."""


class ThreeDSecureScenario(BaseModel):
    id: str
    r"""Unique identifier for the 3DS scenario"""

    merchant_account_id: str
    r"""ID of the associated merchant account"""

    created_at: datetime
    r"""The date and time when this 3DS scenario was first created in our system."""

    updated_at: datetime
    r"""The date and time when this 3DS scenario was last updated in our system."""

    conditions: ThreeDSecureScenarioConditions

    outcome: ThreeDSecureScenarioOutcome

    TYPE: Annotated[
        Annotated[
            Optional[Literal["three-d-secure-scenario"]],
            AfterValidator(validate_const("three-d-secure-scenario")),
        ],
        pydantic.Field(alias="type"),
    ] = "three-d-secure-scenario"
    r"""Always `three-d-secure-scenario`."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["type"])
        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
