# This file was auto-generated by Fern from our API Definition.

import typing

import pydantic
import typing_extensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2
from ..core.serialization import FieldMetadata
from ..core.unchecked_base_model import UncheckedBaseModel
from .country import Country


class Address(UncheckedBaseModel):
    """
    Represents a postal address in a country.
    For more information, see [Working with Addresses](https://developer.squareup.com/docs/build-basics/working-with-addresses).
    """

    address_line1: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="address_line_1"),
        pydantic.Field(
            alias="address_line_1",
            description="The first line of the address.\n\nFields that start with `address_line` provide the address's most specific\ndetails, like street number, street name, and building name. They do *not*\nprovide less specific details like city, state/province, or country (these\ndetails are provided in other fields).",
        ),
    ] = None
    address_line2: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="address_line_2"),
        pydantic.Field(alias="address_line_2", description="The second line of the address, if any."),
    ] = None
    address_line3: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="address_line_3"),
        pydantic.Field(alias="address_line_3", description="The third line of the address, if any."),
    ] = None
    locality: typing.Optional[str] = pydantic.Field(default=None)
    """
    The city or town of the address. For a full list of field meanings by country, see [Working with Addresses](https://developer.squareup.com/docs/build-basics/working-with-addresses).
    """

    sublocality: typing.Optional[str] = pydantic.Field(default=None)
    """
    A civil region within the address's `locality`, if any.
    """

    sublocality2: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="sublocality_2"),
        pydantic.Field(alias="sublocality_2", description="A civil region within the address's `sublocality`, if any."),
    ] = None
    sublocality3: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="sublocality_3"),
        pydantic.Field(
            alias="sublocality_3", description="A civil region within the address's `sublocality_2`, if any."
        ),
    ] = None
    administrative_district_level1: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="administrative_district_level_1"),
        pydantic.Field(
            alias="administrative_district_level_1",
            description="A civil entity within the address's country. In the US, this\nis the state. For a full list of field meanings by country, see [Working with Addresses](https://developer.squareup.com/docs/build-basics/working-with-addresses).",
        ),
    ] = None
    administrative_district_level2: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="administrative_district_level_2"),
        pydantic.Field(
            alias="administrative_district_level_2",
            description="A civil entity within the address's `administrative_district_level_1`.\nIn the US, this is the county.",
        ),
    ] = None
    administrative_district_level3: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="administrative_district_level_3"),
        pydantic.Field(
            alias="administrative_district_level_3",
            description="A civil entity within the address's `administrative_district_level_2`,\nif any.",
        ),
    ] = None
    postal_code: typing.Optional[str] = pydantic.Field(default=None)
    """
    The address's postal code. For a full list of field meanings by country, see [Working with Addresses](https://developer.squareup.com/docs/build-basics/working-with-addresses).
    """

    country: typing.Optional[Country] = pydantic.Field(default=None)
    """
    The address's country, in the two-letter format of ISO 3166. For example, `US` or `FR`.
    See [Country](#type-country) for possible values
    """

    first_name: typing.Optional[str] = pydantic.Field(default=None)
    """
    Optional first name when it's representing recipient.
    """

    last_name: typing.Optional[str] = pydantic.Field(default=None)
    """
    Optional last name when it's representing recipient.
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
