from __future__ import annotations

from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, TypeVar

from attrs import define as _attrs_define
from attrs import field as _attrs_field

from ..types import UNSET, Unset

if TYPE_CHECKING:
    from ..models.pkg_routes_dashboard_template_group import PkgRoutesDashboardTemplateGroup
    from ..models.types_client import TypesClient
    from ..models.types_project import TypesProject
    from ..models.types_retirement_plan import TypesRetirementPlan
    from ..models.types_task import TypesTask


T = TypeVar("T", bound="PkgRoutesDashboardToDoDashboardResponse")


@_attrs_define
class PkgRoutesDashboardToDoDashboardResponse:
    """
    Attributes:
        clients (list[TypesClient] | Unset):
        plans (list[TypesRetirementPlan] | Unset):
        standalone_tasks (list[TypesTask] | Unset):
        starred_projects (list[TypesProject] | Unset):
        templates (list[PkgRoutesDashboardTemplateGroup] | Unset):
    """

    clients: list[TypesClient] | Unset = UNSET
    plans: list[TypesRetirementPlan] | Unset = UNSET
    standalone_tasks: list[TypesTask] | Unset = UNSET
    starred_projects: list[TypesProject] | Unset = UNSET
    templates: list[PkgRoutesDashboardTemplateGroup] | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

    def to_dict(self) -> dict[str, Any]:
        clients: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.clients, Unset):
            clients = []
            for clients_item_data in self.clients:
                clients_item = clients_item_data.to_dict()
                clients.append(clients_item)

        plans: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.plans, Unset):
            plans = []
            for plans_item_data in self.plans:
                plans_item = plans_item_data.to_dict()
                plans.append(plans_item)

        standalone_tasks: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.standalone_tasks, Unset):
            standalone_tasks = []
            for standalone_tasks_item_data in self.standalone_tasks:
                standalone_tasks_item = standalone_tasks_item_data.to_dict()
                standalone_tasks.append(standalone_tasks_item)

        starred_projects: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.starred_projects, Unset):
            starred_projects = []
            for starred_projects_item_data in self.starred_projects:
                starred_projects_item = starred_projects_item_data.to_dict()
                starred_projects.append(starred_projects_item)

        templates: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.templates, Unset):
            templates = []
            for templates_item_data in self.templates:
                templates_item = templates_item_data.to_dict()
                templates.append(templates_item)

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if clients is not UNSET:
            field_dict["clients"] = clients
        if plans is not UNSET:
            field_dict["plans"] = plans
        if standalone_tasks is not UNSET:
            field_dict["standalone_tasks"] = standalone_tasks
        if starred_projects is not UNSET:
            field_dict["starred_projects"] = starred_projects
        if templates is not UNSET:
            field_dict["templates"] = templates

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        from ..models.pkg_routes_dashboard_template_group import PkgRoutesDashboardTemplateGroup
        from ..models.types_client import TypesClient
        from ..models.types_project import TypesProject
        from ..models.types_retirement_plan import TypesRetirementPlan
        from ..models.types_task import TypesTask

        d = dict(src_dict)
        _clients = d.pop("clients", UNSET)
        clients: list[TypesClient] | Unset = UNSET
        if _clients is not UNSET:
            clients = []
            for clients_item_data in _clients:
                clients_item = TypesClient.from_dict(clients_item_data)

                clients.append(clients_item)

        _plans = d.pop("plans", UNSET)
        plans: list[TypesRetirementPlan] | Unset = UNSET
        if _plans is not UNSET:
            plans = []
            for plans_item_data in _plans:
                plans_item = TypesRetirementPlan.from_dict(plans_item_data)

                plans.append(plans_item)

        _standalone_tasks = d.pop("standalone_tasks", UNSET)
        standalone_tasks: list[TypesTask] | Unset = UNSET
        if _standalone_tasks is not UNSET:
            standalone_tasks = []
            for standalone_tasks_item_data in _standalone_tasks:
                standalone_tasks_item = TypesTask.from_dict(standalone_tasks_item_data)

                standalone_tasks.append(standalone_tasks_item)

        _starred_projects = d.pop("starred_projects", UNSET)
        starred_projects: list[TypesProject] | Unset = UNSET
        if _starred_projects is not UNSET:
            starred_projects = []
            for starred_projects_item_data in _starred_projects:
                starred_projects_item = TypesProject.from_dict(starred_projects_item_data)

                starred_projects.append(starred_projects_item)

        _templates = d.pop("templates", UNSET)
        templates: list[PkgRoutesDashboardTemplateGroup] | Unset = UNSET
        if _templates is not UNSET:
            templates = []
            for templates_item_data in _templates:
                templates_item = PkgRoutesDashboardTemplateGroup.from_dict(templates_item_data)

                templates.append(templates_item)

        pkg_routes_dashboard_to_do_dashboard_response = cls(
            clients=clients,
            plans=plans,
            standalone_tasks=standalone_tasks,
            starred_projects=starred_projects,
            templates=templates,
        )

        pkg_routes_dashboard_to_do_dashboard_response.additional_properties = d
        return pkg_routes_dashboard_to_do_dashboard_response

    @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
