Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 

108 rindas
2.7 KiB

  1. from collections.abc import Mapping
  2. from typing import Any, TypeVar, Union
  3. from uuid import UUID
  4. from attrs import define as _attrs_define
  5. from attrs import field as _attrs_field
  6. from app_types import UNSET, Unset
  7. T = TypeVar("T", bound="BuildingItem")
  8. @_attrs_define
  9. class BuildingItem:
  10. """A building or an area that groups together several plan
  11. Attributes:
  12. id (UUID): ID
  13. name (str): Name Example: Hospital.
  14. city (Union[Unset, str]): City
  15. address (Union[Unset, str]): Address
  16. latitude (Union[Unset, float]): Latitude
  17. longitude (Union[Unset, float]): Longitude
  18. """
  19. id: UUID
  20. name: str
  21. city: Union[Unset, str] = UNSET
  22. address: Union[Unset, str] = UNSET
  23. latitude: Union[Unset, float] = UNSET
  24. longitude: Union[Unset, float] = UNSET
  25. additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
  26. def to_dict(self) -> dict[str, Any]:
  27. id = str(self.id)
  28. name = self.name
  29. city = self.city
  30. address = self.address
  31. latitude = self.latitude
  32. longitude = self.longitude
  33. field_dict: dict[str, Any] = {}
  34. field_dict.update(self.additional_properties)
  35. field_dict.update(
  36. {
  37. "id": id,
  38. "name": name,
  39. }
  40. )
  41. if city is not UNSET:
  42. field_dict["city"] = city
  43. if address is not UNSET:
  44. field_dict["address"] = address
  45. if latitude is not UNSET:
  46. field_dict["latitude"] = latitude
  47. if longitude is not UNSET:
  48. field_dict["longitude"] = longitude
  49. return field_dict
  50. @classmethod
  51. def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
  52. d = dict(src_dict)
  53. id = UUID(d.pop("id"))
  54. name = d.pop("name")
  55. city = d.pop("city", UNSET)
  56. address = d.pop("address", UNSET)
  57. latitude = d.pop("latitude", UNSET)
  58. longitude = d.pop("longitude", UNSET)
  59. building_item = cls(
  60. id=id,
  61. name=name,
  62. city=city,
  63. address=address,
  64. latitude=latitude,
  65. longitude=longitude,
  66. )
  67. building_item.additional_properties = d
  68. return building_item
  69. @property
  70. def additional_keys(self) -> list[str]:
  71. return list(self.additional_properties.keys())
  72. def __getitem__(self, key: str) -> Any:
  73. return self.additional_properties[key]
  74. def __setitem__(self, key: str, value: Any) -> None:
  75. self.additional_properties[key] = value
  76. def __delitem__(self, key: str) -> None:
  77. del self.additional_properties[key]
  78. def __contains__(self, key: str) -> bool:
  79. return key in self.additional_properties