from dataclasses import dataclass
from models.base import BaseModel

@dataclass
class Task(BaseModel):
    name: str
    points: int
    is_good: bool
    image_id: str | None = None

    @classmethod
    def from_dict(cls, d: dict):
        return cls(
            name=d.get('name'),
            points=d.get('points', 0),
            is_good=d.get('is_good', True),
            image_id=d.get('image_id'),
            id=d.get('id'),
            created_at=d.get('created_at'),
            updated_at=d.get('updated_at')
        )

    def to_dict(self):
        base = super().to_dict()
        base.update({
            'name': self.name,
            'points': self.points,
            'is_good': self.is_good,
            'image_id': self.image_id
        })
        return base
