from dataclasses import dataclass
from typing import Dict

from ._BaseModel import BaseModel
from ._PathContentModel import PathContentModel
from ..utils import set_dict_path_value


@dataclass
class PathResponseModel(BaseModel):
    description: str
    contents: Dict[str, PathContentModel] | None = None

    def add_content(self, content_type: str, content: PathContentModel) -> None:
        if self.contents is None:
            self.contents = {}

        set_dict_path_value(
            dict_value=self.contents,
            path=[content_type],
            value=content
        )

    def to_dict(self) -> dict:
        return {
            "content": self.contents,
            "description": self.description,
        }
