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

from __future__ import annotations
from .status import Status
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 DtoCustomerResponseTypedDict(TypedDict):
    r"""Customer response object containing all customer information"""

    address_city: NotRequired[str]
    r"""AddressCity is the city of the customer's address"""
    address_country: NotRequired[str]
    r"""AddressCountry is the country of the customer's address (ISO 3166-1 alpha-2)"""
    address_line1: NotRequired[str]
    r"""AddressLine1 is the first line of the customer's address"""
    address_line2: NotRequired[str]
    r"""AddressLine2 is the second line of the customer's address"""
    address_postal_code: NotRequired[str]
    r"""AddressPostalCode is the postal code of the customer's address"""
    address_state: NotRequired[str]
    r"""AddressState is the state of the customer's address"""
    created_at: NotRequired[str]
    created_by: NotRequired[str]
    email: NotRequired[str]
    r"""Email is the email of the customer"""
    environment_id: NotRequired[str]
    r"""EnvironmentID is the environment identifier for the customer"""
    external_id: NotRequired[str]
    r"""ExternalID is the external identifier for the customer"""
    id: NotRequired[str]
    r"""ID is the unique identifier for the customer"""
    metadata: NotRequired[Dict[str, str]]
    r"""Metadata"""
    name: NotRequired[str]
    r"""Name is the name of the customer"""
    parent_customer: NotRequired[DtoCustomerResponseTypedDict]
    r"""Customer response object containing all customer information"""
    parent_customer_id: NotRequired[str]
    r"""ParentCustomerID is the parent customer identifier for the customer"""
    status: NotRequired[Status]
    tenant_id: NotRequired[str]
    updated_at: NotRequired[str]
    updated_by: NotRequired[str]


class DtoCustomerResponse(BaseModel):
    r"""Customer response object containing all customer information"""

    address_city: Optional[str] = None
    r"""AddressCity is the city of the customer's address"""

    address_country: Optional[str] = None
    r"""AddressCountry is the country of the customer's address (ISO 3166-1 alpha-2)"""

    address_line1: Optional[str] = None
    r"""AddressLine1 is the first line of the customer's address"""

    address_line2: Optional[str] = None
    r"""AddressLine2 is the second line of the customer's address"""

    address_postal_code: Optional[str] = None
    r"""AddressPostalCode is the postal code of the customer's address"""

    address_state: Optional[str] = None
    r"""AddressState is the state of the customer's address"""

    created_at: Optional[str] = None

    created_by: Optional[str] = None

    email: Optional[str] = None
    r"""Email is the email of the customer"""

    environment_id: Optional[str] = None
    r"""EnvironmentID is the environment identifier for the customer"""

    external_id: Optional[str] = None
    r"""ExternalID is the external identifier for the customer"""

    id: Optional[str] = None
    r"""ID is the unique identifier for the customer"""

    metadata: Optional[Dict[str, str]] = None
    r"""Metadata"""

    name: Optional[str] = None
    r"""Name is the name of the customer"""

    parent_customer: Optional[DtoCustomerResponse] = None
    r"""Customer response object containing all customer information"""

    parent_customer_id: Optional[str] = None
    r"""ParentCustomerID is the parent customer identifier for the customer"""

    status: Optional[Status] = None

    tenant_id: Optional[str] = None

    updated_at: Optional[str] = None

    updated_by: Optional[str] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "address_city",
                "address_country",
                "address_line1",
                "address_line2",
                "address_postal_code",
                "address_state",
                "created_at",
                "created_by",
                "email",
                "environment_id",
                "external_id",
                "id",
                "metadata",
                "name",
                "parent_customer",
                "parent_customer_id",
                "status",
                "tenant_id",
                "updated_at",
                "updated_by",
            ]
        )
        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
