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

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


class IssuingMerchantDataTypedDict(TypedDict):
    network_id: str
    r"""External identifier used to identify the merchant with the card brand."""
    country: str
    r"""Two-letter country code."""
    mcc: str
    r"""The Merchant Category Code."""
    name: NotRequired[str]
    r"""Name of the merchant."""
    city: NotRequired[str]
    r"""The merchant's location."""
    postal_code: NotRequired[str]
    r"""The merchant's five-digit postal code."""
    state: NotRequired[str]
    r"""The merchant's two-letter state abbreviation."""


class IssuingMerchantData(BaseModel):
    network_id: Annotated[str, pydantic.Field(alias="networkID")]
    r"""External identifier used to identify the merchant with the card brand."""

    country: str
    r"""Two-letter country code."""

    mcc: str
    r"""The Merchant Category Code."""

    name: Optional[str] = None
    r"""Name of the merchant."""

    city: Optional[str] = None
    r"""The merchant's location."""

    postal_code: Annotated[Optional[str], pydantic.Field(alias="postalCode")] = None
    r"""The merchant's five-digit postal code."""

    state: Optional[str] = None
    r"""The merchant's two-letter state abbreviation."""

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


try:
    IssuingMerchantData.model_rebuild()
except NameError:
    pass
