crm-backend/utils/clients/gooyal_advertising_client/models/check_in.py
2026-06-07 11:34:17 +03:30

124 lines
3.3 KiB
Python

from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
from uuid import UUID
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from ..types import UNSET, Unset
if TYPE_CHECKING:
from .check_in_location_type_0 import CheckInLocationType0
T = TypeVar("T", bound="CheckIn")
@_attrs_define
class CheckIn:
"""
Attributes:
user (UUID):
zone (UUID):
score (int):
zone_state (str):
location (Union['CheckInLocationType0', None, Unset]):
"""
user: UUID
zone: UUID
score: int
zone_state: str
location: Union["CheckInLocationType0", None, Unset] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
from .check_in_location_type_0 import CheckInLocationType0
user = str(self.user)
zone = str(self.zone)
score = self.score
zone_state = self.zone_state
location: Union[None, Unset, dict[str, Any]]
if isinstance(self.location, Unset):
location = UNSET
elif isinstance(self.location, CheckInLocationType0):
location = self.location.to_dict()
else:
location = self.location
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"user": user,
"zone": zone,
"score": score,
"zone_state": zone_state,
}
)
if location is not UNSET:
field_dict["location"] = location
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
from .check_in_location_type_0 import CheckInLocationType0
d = dict(src_dict)
user = UUID(d.pop("user"))
zone = UUID(d.pop("zone"))
score = d.pop("score")
zone_state = d.pop("zone_state")
def _parse_location(data: object) -> Union["CheckInLocationType0", None, Unset]:
if data is None:
return data
if isinstance(data, Unset):
return data
try:
if not isinstance(data, dict):
raise TypeError()
location_type_0 = CheckInLocationType0.from_dict(data)
return location_type_0
except: # noqa: E722
pass
return cast(Union["CheckInLocationType0", None, Unset], data)
location = _parse_location(d.pop("location", UNSET))
check_in = cls(
user=user,
zone=zone,
score=score,
zone_state=zone_state,
location=location,
)
check_in.additional_properties = d
return check_in
@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