from __future__ import annotations

from collections.abc import Mapping
from typing import Any, TypeVar

from attrs import define as _attrs_define
from attrs import field as _attrs_field

from ..types import UNSET, Unset

T = TypeVar("T", bound="LegacytypesAddress")


@_attrs_define
class LegacytypesAddress:
    """
    Attributes:
        attn (str | Unset):
        city (str | Unset):
        country (str | Unset):
        desc (str | Unset):
        state (str | Unset):
        street (str | Unset):
        unit (str | Unset):
        zip_ (str | Unset):
    """

    attn: str | Unset = UNSET
    city: str | Unset = UNSET
    country: str | Unset = UNSET
    desc: str | Unset = UNSET
    state: str | Unset = UNSET
    street: str | Unset = UNSET
    unit: str | Unset = UNSET
    zip_: str | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

    def to_dict(self) -> dict[str, Any]:
        attn = self.attn

        city = self.city

        country = self.country

        desc = self.desc

        state = self.state

        street = self.street

        unit = self.unit

        zip_ = self.zip_

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if attn is not UNSET:
            field_dict["attn"] = attn
        if city is not UNSET:
            field_dict["city"] = city
        if country is not UNSET:
            field_dict["country"] = country
        if desc is not UNSET:
            field_dict["desc"] = desc
        if state is not UNSET:
            field_dict["state"] = state
        if street is not UNSET:
            field_dict["street"] = street
        if unit is not UNSET:
            field_dict["unit"] = unit
        if zip_ is not UNSET:
            field_dict["zip"] = zip_

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        d = dict(src_dict)
        attn = d.pop("attn", UNSET)

        city = d.pop("city", UNSET)

        country = d.pop("country", UNSET)

        desc = d.pop("desc", UNSET)

        state = d.pop("state", UNSET)

        street = d.pop("street", UNSET)

        unit = d.pop("unit", UNSET)

        zip_ = d.pop("zip", UNSET)

        legacytypes_address = cls(
            attn=attn,
            city=city,
            country=country,
            desc=desc,
            state=state,
            street=street,
            unit=unit,
            zip_=zip_,
        )

        legacytypes_address.additional_properties = d
        return legacytypes_address

    @property
    def additional_keys(self) -> list[str]:
        return list(self.additional_properties.keys())

    def __getitem__(self, key: str) -> Any:
        return self.additional_properties[key]

    def __setitem__(self, key: str, value: Any) -> None:
        self.additional_properties[key] = value

    def __delitem__(self, key: str) -> None:
        del self.additional_properties[key]

    def __contains__(self, key: str) -> bool:
        return key in self.additional_properties
