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

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


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(default=None)
    )
    """
    The first line of the address.
    
    Fields that start with `address_line` provide the address's most specific
    details, like street number, street name, and building name. They do *not*
    provide less specific details like city, state/province, or country (these
    details are provided in other fields).
    """

    address_line2: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="address_line_2")] = (
        pydantic.Field(default=None)
    )
    """
    The second line of the address, if any.
    """

    address_line3: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="address_line_3")] = (
        pydantic.Field(default=None)
    )
    """
    The third line of the address, if any.
    """

    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(default=None)
    )
    """
    A civil region within the address's `sublocality`, if any.
    """

    sublocality3: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="sublocality_3")] = (
        pydantic.Field(default=None)
    )
    """
    A civil region within the address's `sublocality_2`, if any.
    """

    administrative_district_level1: typing_extensions.Annotated[
        typing.Optional[str], FieldMetadata(alias="administrative_district_level_1")
    ] = pydantic.Field(default=None)
    """
    A civil entity within the address's country. In the US, this
    is 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).
    """

    administrative_district_level2: typing_extensions.Annotated[
        typing.Optional[str], FieldMetadata(alias="administrative_district_level_2")
    ] = pydantic.Field(default=None)
    """
    A civil entity within the address's `administrative_district_level_1`.
    In the US, this is the county.
    """

    administrative_district_level3: typing_extensions.Annotated[
        typing.Optional[str], FieldMetadata(alias="administrative_district_level_3")
    ] = pydantic.Field(default=None)
    """
    A civil entity within the address's `administrative_district_level_2`,
    if any.
    """

    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
