"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
# @generated-id: ae6e0af73d2b

from __future__ import annotations
from .creditor_bank_account_response import (
    CreditorBankAccountResponse,
    CreditorBankAccountResponseTypedDict,
)
from .verification_result_enum import VerificationResultEnum
from mollie import models
from mollie.types import BaseModel, UNSET_SENTINEL
import pydantic
from pydantic import field_serializer, model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class VerificationOfPayeeResponseVerificationResultTypedDict(TypedDict):
    outcome: VerificationResultEnum
    r"""The result of the Verification of Payee check."""
    account_holder_name: NotRequired[str]
    r"""The corrected name if the verification result is `close_match`."""


class VerificationOfPayeeResponseVerificationResult(BaseModel):
    outcome: VerificationResultEnum
    r"""The result of the Verification of Payee check."""

    account_holder_name: Annotated[
        Optional[str], pydantic.Field(alias="accountHolderName")
    ] = None
    r"""The corrected name if the verification result is `close_match`."""

    @field_serializer("outcome")
    def serialize_outcome(self, value):
        if isinstance(value, str):
            try:
                return models.VerificationResultEnum(value)
            except ValueError:
                return value
        return value

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["accountHolderName"])
        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 VerificationOfPayeeResponseTypedDict(TypedDict):
    r"""The Verification of Payee response object. Contains the result of verifying the creditor's
    account holder name against the records held by the receiving bank.
    """

    resource: str
    r"""Indicates the response contains a payee verification object. Will always contain the string
    `business-account-payee-verification` for this endpoint.
    """
    creditor_bank_account: CreditorBankAccountResponseTypedDict
    r"""The bank account details of the creditor (recipient) for Verification of Payee."""
    verification_result: VerificationOfPayeeResponseVerificationResultTypedDict
    created_at: str
    r"""The entity's date and time of creation, in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format."""


class VerificationOfPayeeResponse(BaseModel):
    r"""The Verification of Payee response object. Contains the result of verifying the creditor's
    account holder name against the records held by the receiving bank.
    """

    resource: str
    r"""Indicates the response contains a payee verification object. Will always contain the string
    `business-account-payee-verification` for this endpoint.
    """

    creditor_bank_account: Annotated[
        CreditorBankAccountResponse, pydantic.Field(alias="creditorBankAccount")
    ]
    r"""The bank account details of the creditor (recipient) for Verification of Payee."""

    verification_result: Annotated[
        VerificationOfPayeeResponseVerificationResult,
        pydantic.Field(alias="verificationResult"),
    ]

    created_at: Annotated[str, pydantic.Field(alias="createdAt")]
    r"""The entity's date and time of creation, in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format."""


try:
    VerificationOfPayeeResponseVerificationResult.model_rebuild()
except NameError:
    pass
try:
    VerificationOfPayeeResponse.model_rebuild()
except NameError:
    pass
