134 lines
3.3 KiB
Python
134 lines
3.3 KiB
Python
import datetime
|
|
from collections.abc import Mapping
|
|
from typing import Any, TypeVar
|
|
from uuid import UUID
|
|
|
|
from attrs import define as _attrs_define
|
|
from attrs import field as _attrs_field
|
|
from dateutil.parser import isoparse
|
|
|
|
T = TypeVar("T", bound="Comment")
|
|
|
|
|
|
@_attrs_define
|
|
class Comment:
|
|
"""
|
|
Attributes:
|
|
uuid (UUID):
|
|
user_uuid (UUID):
|
|
content (str):
|
|
likes_count (str):
|
|
dislikes_count (str):
|
|
user_reaction (str):
|
|
created_at (datetime.datetime):
|
|
updated_at (datetime.datetime):
|
|
ad (UUID):
|
|
replies (str):
|
|
"""
|
|
|
|
uuid: UUID
|
|
user_uuid: UUID
|
|
content: str
|
|
likes_count: str
|
|
dislikes_count: str
|
|
user_reaction: str
|
|
created_at: datetime.datetime
|
|
updated_at: datetime.datetime
|
|
ad: UUID
|
|
replies: str
|
|
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
|
|
def to_dict(self) -> dict[str, Any]:
|
|
uuid = str(self.uuid)
|
|
|
|
user_uuid = str(self.user_uuid)
|
|
|
|
content = self.content
|
|
|
|
likes_count = self.likes_count
|
|
|
|
dislikes_count = self.dislikes_count
|
|
|
|
user_reaction = self.user_reaction
|
|
|
|
created_at = self.created_at.isoformat()
|
|
|
|
updated_at = self.updated_at.isoformat()
|
|
|
|
ad = str(self.ad)
|
|
|
|
replies = self.replies
|
|
|
|
field_dict: dict[str, Any] = {}
|
|
field_dict.update(self.additional_properties)
|
|
field_dict.update(
|
|
{
|
|
"uuid": uuid,
|
|
"user_uuid": user_uuid,
|
|
"content": content,
|
|
"likes_count": likes_count,
|
|
"dislikes_count": dislikes_count,
|
|
"user_reaction": user_reaction,
|
|
"created_at": created_at,
|
|
"updated_at": updated_at,
|
|
"ad": ad,
|
|
"replies": replies,
|
|
}
|
|
)
|
|
|
|
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"))
|
|
|
|
user_uuid = UUID(d.pop("user_uuid"))
|
|
|
|
content = d.pop("content")
|
|
|
|
likes_count = d.pop("likes_count")
|
|
|
|
dislikes_count = d.pop("dislikes_count")
|
|
|
|
user_reaction = d.pop("user_reaction")
|
|
|
|
created_at = isoparse(d.pop("created_at"))
|
|
|
|
updated_at = isoparse(d.pop("updated_at"))
|
|
|
|
ad = UUID(d.pop("ad"))
|
|
|
|
replies = d.pop("replies")
|
|
|
|
comment = cls(
|
|
uuid=uuid,
|
|
user_uuid=user_uuid,
|
|
content=content,
|
|
likes_count=likes_count,
|
|
dislikes_count=dislikes_count,
|
|
user_reaction=user_reaction,
|
|
created_at=created_at,
|
|
updated_at=updated_at,
|
|
ad=ad,
|
|
replies=replies,
|
|
)
|
|
|
|
comment.additional_properties = d
|
|
return comment
|
|
|
|
@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
|