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

from __future__ import annotations
from .cardscheme import CardScheme
from gr4vy.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
from pydantic import model_serializer
from typing import Dict
from typing_extensions import NotRequired, TypedDict


class MerchantAccountThreeDSConfigurationUpdateTypedDict(TypedDict):
    merchant_acquirer_bin: NotRequired[Nullable[str]]
    r"""Acquirer BIN to use when calling 3DS through this scheme."""
    merchant_acquirer_id: NotRequired[Nullable[str]]
    r"""Merchant ID to use when calling 3DS through this scheme."""
    merchant_name: NotRequired[Nullable[str]]
    merchant_country_code: NotRequired[Nullable[str]]
    r"""The merchant's ISO 3166-1 numeric country code."""
    merchant_category_code: NotRequired[Nullable[str]]
    r"""Merchant category code to use when calling 3DS through this scheme."""
    merchant_url: NotRequired[Nullable[str]]
    r"""URL to send when calling 3DS through this scheme."""
    scheme: NotRequired[Nullable[CardScheme]]
    r"""The card scheme for this 3DS configuration"""
    currency: NotRequired[Nullable[str]]
    r"""ISO 4217 currency code (3 characters). If left null, the configuration will apply to all currencies."""
    metadata: NotRequired[Nullable[Dict[str, str]]]
    r"""Any additional information about the 3DS configuration that you would like to store as key-value pairs."""


class MerchantAccountThreeDSConfigurationUpdate(BaseModel):
    merchant_acquirer_bin: OptionalNullable[str] = UNSET
    r"""Acquirer BIN to use when calling 3DS through this scheme."""

    merchant_acquirer_id: OptionalNullable[str] = UNSET
    r"""Merchant ID to use when calling 3DS through this scheme."""

    merchant_name: OptionalNullable[str] = UNSET

    merchant_country_code: OptionalNullable[str] = UNSET
    r"""The merchant's ISO 3166-1 numeric country code."""

    merchant_category_code: OptionalNullable[str] = UNSET
    r"""Merchant category code to use when calling 3DS through this scheme."""

    merchant_url: OptionalNullable[str] = UNSET
    r"""URL to send when calling 3DS through this scheme."""

    scheme: OptionalNullable[CardScheme] = UNSET
    r"""The card scheme for this 3DS configuration"""

    currency: OptionalNullable[str] = UNSET
    r"""ISO 4217 currency code (3 characters). If left null, the configuration will apply to all currencies."""

    metadata: OptionalNullable[Dict[str, str]] = UNSET
    r"""Any additional information about the 3DS configuration that you would like to store as key-value pairs."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "merchant_acquirer_bin",
                "merchant_acquirer_id",
                "merchant_name",
                "merchant_country_code",
                "merchant_category_code",
                "merchant_url",
                "scheme",
                "currency",
                "metadata",
            ]
        )
        nullable_fields = set(
            [
                "merchant_acquirer_bin",
                "merchant_acquirer_id",
                "merchant_name",
                "merchant_country_code",
                "merchant_category_code",
                "merchant_url",
                "scheme",
                "currency",
                "metadata",
            ]
        )
        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))
            is_nullable_and_explicitly_set = (
                k in nullable_fields
                and (self.__pydantic_fields_set__.intersection({n}))  # pylint: disable=no-member
            )

            if val != UNSET_SENTINEL:
                if (
                    val is not None
                    or k not in optional_fields
                    or is_nullable_and_explicitly_set
                ):
                    m[k] = val

        return m
