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_cp_client_request import PkgRoutesCpClientRequest
    from ..models.pkg_routes_cp_client_request_form import PkgRoutesCpClientRequestForm
    from ..models.pkg_routes_cp_notice import PkgRoutesCpNotice
    from ..models.types_message import TypesMessage
    from ..models.types_task import TypesTask


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


@_attrs_define
class PkgRoutesCpClientPortalHomeResponse:
    """
    Attributes:
        messages (list[TypesMessage] | Unset):
        notices (list[PkgRoutesCpNotice] | Unset):
        request_forms (list[PkgRoutesCpClientRequestForm] | Unset):
        requests (list[PkgRoutesCpClientRequest] | Unset):
        tasks (list[TypesTask] | Unset):
    """

    messages: list[TypesMessage] | Unset = UNSET
    notices: list[PkgRoutesCpNotice] | Unset = UNSET
    request_forms: list[PkgRoutesCpClientRequestForm] | Unset = UNSET
    requests: list[PkgRoutesCpClientRequest] | Unset = UNSET
    tasks: list[TypesTask] | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

        notices: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.notices, Unset):
            notices = []
            for notices_item_data in self.notices:
                notices_item = notices_item_data.to_dict()
                notices.append(notices_item)

        request_forms: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.request_forms, Unset):
            request_forms = []
            for request_forms_item_data in self.request_forms:
                request_forms_item = request_forms_item_data.to_dict()
                request_forms.append(request_forms_item)

        requests: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.requests, Unset):
            requests = []
            for requests_item_data in self.requests:
                requests_item = requests_item_data.to_dict()
                requests.append(requests_item)

        tasks: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.tasks, Unset):
            tasks = []
            for tasks_item_data in self.tasks:
                tasks_item = tasks_item_data.to_dict()
                tasks.append(tasks_item)

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if messages is not UNSET:
            field_dict["messages"] = messages
        if notices is not UNSET:
            field_dict["notices"] = notices
        if request_forms is not UNSET:
            field_dict["request_forms"] = request_forms
        if requests is not UNSET:
            field_dict["requests"] = requests
        if tasks is not UNSET:
            field_dict["tasks"] = tasks

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        from ..models.pkg_routes_cp_client_request import PkgRoutesCpClientRequest
        from ..models.pkg_routes_cp_client_request_form import PkgRoutesCpClientRequestForm
        from ..models.pkg_routes_cp_notice import PkgRoutesCpNotice
        from ..models.types_message import TypesMessage
        from ..models.types_task import TypesTask

        d = dict(src_dict)
        _messages = d.pop("messages", UNSET)
        messages: list[TypesMessage] | Unset = UNSET
        if _messages is not UNSET:
            messages = []
            for messages_item_data in _messages:
                messages_item = TypesMessage.from_dict(messages_item_data)

                messages.append(messages_item)

        _notices = d.pop("notices", UNSET)
        notices: list[PkgRoutesCpNotice] | Unset = UNSET
        if _notices is not UNSET:
            notices = []
            for notices_item_data in _notices:
                notices_item = PkgRoutesCpNotice.from_dict(notices_item_data)

                notices.append(notices_item)

        _request_forms = d.pop("request_forms", UNSET)
        request_forms: list[PkgRoutesCpClientRequestForm] | Unset = UNSET
        if _request_forms is not UNSET:
            request_forms = []
            for request_forms_item_data in _request_forms:
                request_forms_item = PkgRoutesCpClientRequestForm.from_dict(request_forms_item_data)

                request_forms.append(request_forms_item)

        _requests = d.pop("requests", UNSET)
        requests: list[PkgRoutesCpClientRequest] | Unset = UNSET
        if _requests is not UNSET:
            requests = []
            for requests_item_data in _requests:
                requests_item = PkgRoutesCpClientRequest.from_dict(requests_item_data)

                requests.append(requests_item)

        _tasks = d.pop("tasks", UNSET)
        tasks: list[TypesTask] | Unset = UNSET
        if _tasks is not UNSET:
            tasks = []
            for tasks_item_data in _tasks:
                tasks_item = TypesTask.from_dict(tasks_item_data)

                tasks.append(tasks_item)

        pkg_routes_cp_client_portal_home_response = cls(
            messages=messages,
            notices=notices,
            request_forms=request_forms,
            requests=requests,
            tasks=tasks,
        )

        pkg_routes_cp_client_portal_home_response.additional_properties = d
        return pkg_routes_cp_client_portal_home_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
