import datetime from collections.abc import Mapping from typing import Any, TypeVar, Union, cast from uuid import UUID from attrs import define as _attrs_define from attrs import field as _attrs_field from dateutil.parser import isoparse from ..models.blank_enum import BlankEnum from ..models.education_degree_enum import EducationDegreeEnum from ..models.gender_enum import GenderEnum from ..types import UNSET, Unset T = TypeVar("T", bound="Account") @_attrs_define class Account: """ Attributes: uuid (UUID): email (str): phone_number (str): iban_verified (Union[None, bool]): province_name (str): city_name (str): username (Union[None, Unset, str]): Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only. first_name (Union[Unset, str]): last_name (Union[Unset, str]): name (Union[Unset, str]): avatar (Union[None, Unset, str]): gender (Union[BlankEnum, GenderEnum, None, Unset]): education_degree (Union[BlankEnum, EducationDegreeEnum, None, Unset]): education_field (Union[None, Unset, str]): birthdate (Union[None, Unset, datetime.date]): iban (Union[None, Unset, str]): province (Union[None, Unset, int]): city (Union[None, Unset, int]): postal_code (Union[None, Unset, str]): address (Union[None, Unset, str]): """ uuid: UUID email: str phone_number: str iban_verified: Union[None, bool] province_name: str city_name: str username: Union[None, Unset, str] = UNSET first_name: Union[Unset, str] = UNSET last_name: Union[Unset, str] = UNSET name: Union[Unset, str] = UNSET avatar: Union[None, Unset, str] = UNSET gender: Union[BlankEnum, GenderEnum, None, Unset] = UNSET education_degree: Union[BlankEnum, EducationDegreeEnum, None, Unset] = UNSET education_field: Union[None, Unset, str] = UNSET birthdate: Union[None, Unset, datetime.date] = UNSET iban: Union[None, Unset, str] = UNSET province: Union[None, Unset, int] = UNSET city: Union[None, Unset, int] = UNSET postal_code: Union[None, Unset, str] = UNSET address: Union[None, Unset, str] = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: uuid = str(self.uuid) email = self.email phone_number = self.phone_number iban_verified: Union[None, bool] iban_verified = self.iban_verified province_name = self.province_name city_name = self.city_name username: Union[None, Unset, str] if isinstance(self.username, Unset): username = UNSET else: username = self.username first_name = self.first_name last_name = self.last_name name = self.name avatar: Union[None, Unset, str] if isinstance(self.avatar, Unset): avatar = UNSET else: avatar = self.avatar gender: Union[None, Unset, str] if isinstance(self.gender, Unset): gender = UNSET elif isinstance(self.gender, GenderEnum): gender = self.gender.value elif isinstance(self.gender, BlankEnum): gender = self.gender.value else: gender = self.gender education_degree: Union[None, Unset, str] if isinstance(self.education_degree, Unset): education_degree = UNSET elif isinstance(self.education_degree, EducationDegreeEnum): education_degree = self.education_degree.value elif isinstance(self.education_degree, BlankEnum): education_degree = self.education_degree.value else: education_degree = self.education_degree education_field: Union[None, Unset, str] if isinstance(self.education_field, Unset): education_field = UNSET else: education_field = self.education_field birthdate: Union[None, Unset, str] if isinstance(self.birthdate, Unset): birthdate = UNSET elif isinstance(self.birthdate, datetime.date): birthdate = self.birthdate.isoformat() else: birthdate = self.birthdate iban: Union[None, Unset, str] if isinstance(self.iban, Unset): iban = UNSET else: iban = self.iban province: Union[None, Unset, int] if isinstance(self.province, Unset): province = UNSET else: province = self.province city: Union[None, Unset, int] if isinstance(self.city, Unset): city = UNSET else: city = self.city postal_code: Union[None, Unset, str] if isinstance(self.postal_code, Unset): postal_code = UNSET else: postal_code = self.postal_code address: Union[None, Unset, str] if isinstance(self.address, Unset): address = UNSET else: address = self.address field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { "uuid": uuid, "email": email, "phone_number": phone_number, "iban_verified": iban_verified, "province_name": province_name, "city_name": city_name, } ) if username is not UNSET: field_dict["username"] = username if first_name is not UNSET: field_dict["first_name"] = first_name if last_name is not UNSET: field_dict["last_name"] = last_name if name is not UNSET: field_dict["name"] = name if avatar is not UNSET: field_dict["avatar"] = avatar if gender is not UNSET: field_dict["gender"] = gender if education_degree is not UNSET: field_dict["education_degree"] = education_degree if education_field is not UNSET: field_dict["education_field"] = education_field if birthdate is not UNSET: field_dict["birthdate"] = birthdate if iban is not UNSET: field_dict["iban"] = iban if province is not UNSET: field_dict["province"] = province if city is not UNSET: field_dict["city"] = city if postal_code is not UNSET: field_dict["postal_code"] = postal_code if address is not UNSET: field_dict["address"] = address return field_dict @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) uuid = UUID(d.pop("uuid")) email = d.pop("email") phone_number = d.pop("phone_number") def _parse_iban_verified(data: object) -> Union[None, bool]: if data is None: return data return cast(Union[None, bool], data) iban_verified = _parse_iban_verified(d.pop("iban_verified")) province_name = d.pop("province_name") city_name = d.pop("city_name") def _parse_username(data: object) -> Union[None, Unset, str]: if data is None: return data if isinstance(data, Unset): return data return cast(Union[None, Unset, str], data) username = _parse_username(d.pop("username", UNSET)) first_name = d.pop("first_name", UNSET) last_name = d.pop("last_name", UNSET) name = d.pop("name", UNSET) def _parse_avatar(data: object) -> Union[None, Unset, str]: if data is None: return data if isinstance(data, Unset): return data return cast(Union[None, Unset, str], data) avatar = _parse_avatar(d.pop("avatar", UNSET)) def _parse_gender(data: object) -> Union[BlankEnum, GenderEnum, None, Unset]: if data is None: return data if isinstance(data, Unset): return data try: if not isinstance(data, str): raise TypeError() gender_type_0 = GenderEnum(data) return gender_type_0 except: # noqa: E722 pass try: if not isinstance(data, str): raise TypeError() gender_type_1 = BlankEnum(data) return gender_type_1 except: # noqa: E722 pass return cast(Union[BlankEnum, GenderEnum, None, Unset], data) gender = _parse_gender(d.pop("gender", UNSET)) def _parse_education_degree(data: object) -> Union[BlankEnum, EducationDegreeEnum, None, Unset]: if data is None: return data if isinstance(data, Unset): return data try: if not isinstance(data, str): raise TypeError() education_degree_type_0 = EducationDegreeEnum(data) return education_degree_type_0 except: # noqa: E722 pass try: if not isinstance(data, str): raise TypeError() education_degree_type_1 = BlankEnum(data) return education_degree_type_1 except: # noqa: E722 pass return cast(Union[BlankEnum, EducationDegreeEnum, None, Unset], data) education_degree = _parse_education_degree(d.pop("education_degree", UNSET)) def _parse_education_field(data: object) -> Union[None, Unset, str]: if data is None: return data if isinstance(data, Unset): return data return cast(Union[None, Unset, str], data) education_field = _parse_education_field(d.pop("education_field", UNSET)) def _parse_birthdate(data: object) -> Union[None, Unset, datetime.date]: if data is None: return data if isinstance(data, Unset): return data try: if not isinstance(data, str): raise TypeError() birthdate_type_0 = isoparse(data).date() return birthdate_type_0 except: # noqa: E722 pass return cast(Union[None, Unset, datetime.date], data) birthdate = _parse_birthdate(d.pop("birthdate", UNSET)) def _parse_iban(data: object) -> Union[None, Unset, str]: if data is None: return data if isinstance(data, Unset): return data return cast(Union[None, Unset, str], data) iban = _parse_iban(d.pop("iban", UNSET)) def _parse_province(data: object) -> Union[None, Unset, int]: if data is None: return data if isinstance(data, Unset): return data return cast(Union[None, Unset, int], data) province = _parse_province(d.pop("province", UNSET)) def _parse_city(data: object) -> Union[None, Unset, int]: if data is None: return data if isinstance(data, Unset): return data return cast(Union[None, Unset, int], data) city = _parse_city(d.pop("city", UNSET)) def _parse_postal_code(data: object) -> Union[None, Unset, str]: if data is None: return data if isinstance(data, Unset): return data return cast(Union[None, Unset, str], data) postal_code = _parse_postal_code(d.pop("postal_code", UNSET)) def _parse_address(data: object) -> Union[None, Unset, str]: if data is None: return data if isinstance(data, Unset): return data return cast(Union[None, Unset, str], data) address = _parse_address(d.pop("address", UNSET)) account = cls( uuid=uuid, email=email, phone_number=phone_number, iban_verified=iban_verified, province_name=province_name, city_name=city_name, username=username, first_name=first_name, last_name=last_name, name=name, avatar=avatar, gender=gender, education_degree=education_degree, education_field=education_field, birthdate=birthdate, iban=iban, province=province, city=city, postal_code=postal_code, address=address, ) account.additional_properties = d return account @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