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.gin_h import GinH
    from ..models.pkg_routes_dashboard_aggregation_result import PkgRoutesDashboardAggregationResult
    from ..models.pkg_routes_dashboard_client_email import PkgRoutesDashboardClientEmail
    from ..models.types_short_client import TypesShortClient
    from ..models.types_task import TypesTask


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


@_attrs_define
class PkgRoutesDashboardDashboardMeResponse:
    """
    Attributes:
        active_tasks (list[TypesTask] | Unset):
        activity (list[PkgRoutesDashboardAggregationResult] | Unset):
        client_emails (list[PkgRoutesDashboardClientEmail] | Unset):
        clients (list[TypesShortClient] | Unset):
        pulse (GinH | Unset):
        response_times (list[PkgRoutesDashboardAggregationResult] | Unset):
        work_logs (list[PkgRoutesDashboardAggregationResult] | Unset):
    """

    active_tasks: list[TypesTask] | Unset = UNSET
    activity: list[PkgRoutesDashboardAggregationResult] | Unset = UNSET
    client_emails: list[PkgRoutesDashboardClientEmail] | Unset = UNSET
    clients: list[TypesShortClient] | Unset = UNSET
    pulse: GinH | Unset = UNSET
    response_times: list[PkgRoutesDashboardAggregationResult] | Unset = UNSET
    work_logs: list[PkgRoutesDashboardAggregationResult] | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

        activity: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.activity, Unset):
            activity = []
            for activity_item_data in self.activity:
                activity_item = activity_item_data.to_dict()
                activity.append(activity_item)

        client_emails: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.client_emails, Unset):
            client_emails = []
            for client_emails_item_data in self.client_emails:
                client_emails_item = client_emails_item_data.to_dict()
                client_emails.append(client_emails_item)

        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)

        pulse: dict[str, Any] | Unset = UNSET
        if not isinstance(self.pulse, Unset):
            pulse = self.pulse.to_dict()

        response_times: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.response_times, Unset):
            response_times = []
            for response_times_item_data in self.response_times:
                response_times_item = response_times_item_data.to_dict()
                response_times.append(response_times_item)

        work_logs: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.work_logs, Unset):
            work_logs = []
            for work_logs_item_data in self.work_logs:
                work_logs_item = work_logs_item_data.to_dict()
                work_logs.append(work_logs_item)

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if active_tasks is not UNSET:
            field_dict["active_tasks"] = active_tasks
        if activity is not UNSET:
            field_dict["activity"] = activity
        if client_emails is not UNSET:
            field_dict["client_emails"] = client_emails
        if clients is not UNSET:
            field_dict["clients"] = clients
        if pulse is not UNSET:
            field_dict["pulse"] = pulse
        if response_times is not UNSET:
            field_dict["response_times"] = response_times
        if work_logs is not UNSET:
            field_dict["work_logs"] = work_logs

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        from ..models.gin_h import GinH
        from ..models.pkg_routes_dashboard_aggregation_result import PkgRoutesDashboardAggregationResult
        from ..models.pkg_routes_dashboard_client_email import PkgRoutesDashboardClientEmail
        from ..models.types_short_client import TypesShortClient
        from ..models.types_task import TypesTask

        d = dict(src_dict)
        _active_tasks = d.pop("active_tasks", UNSET)
        active_tasks: list[TypesTask] | Unset = UNSET
        if _active_tasks is not UNSET:
            active_tasks = []
            for active_tasks_item_data in _active_tasks:
                active_tasks_item = TypesTask.from_dict(active_tasks_item_data)

                active_tasks.append(active_tasks_item)

        _activity = d.pop("activity", UNSET)
        activity: list[PkgRoutesDashboardAggregationResult] | Unset = UNSET
        if _activity is not UNSET:
            activity = []
            for activity_item_data in _activity:
                activity_item = PkgRoutesDashboardAggregationResult.from_dict(activity_item_data)

                activity.append(activity_item)

        _client_emails = d.pop("client_emails", UNSET)
        client_emails: list[PkgRoutesDashboardClientEmail] | Unset = UNSET
        if _client_emails is not UNSET:
            client_emails = []
            for client_emails_item_data in _client_emails:
                client_emails_item = PkgRoutesDashboardClientEmail.from_dict(client_emails_item_data)

                client_emails.append(client_emails_item)

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

                clients.append(clients_item)

        _pulse = d.pop("pulse", UNSET)
        pulse: GinH | Unset
        if isinstance(_pulse, Unset):
            pulse = UNSET
        else:
            pulse = GinH.from_dict(_pulse)

        _response_times = d.pop("response_times", UNSET)
        response_times: list[PkgRoutesDashboardAggregationResult] | Unset = UNSET
        if _response_times is not UNSET:
            response_times = []
            for response_times_item_data in _response_times:
                response_times_item = PkgRoutesDashboardAggregationResult.from_dict(response_times_item_data)

                response_times.append(response_times_item)

        _work_logs = d.pop("work_logs", UNSET)
        work_logs: list[PkgRoutesDashboardAggregationResult] | Unset = UNSET
        if _work_logs is not UNSET:
            work_logs = []
            for work_logs_item_data in _work_logs:
                work_logs_item = PkgRoutesDashboardAggregationResult.from_dict(work_logs_item_data)

                work_logs.append(work_logs_item)

        pkg_routes_dashboard_dashboard_me_response = cls(
            active_tasks=active_tasks,
            activity=activity,
            client_emails=client_emails,
            clients=clients,
            pulse=pulse,
            response_times=response_times,
            work_logs=work_logs,
        )

        pkg_routes_dashboard_dashboard_me_response.additional_properties = d
        return pkg_routes_dashboard_dashboard_me_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
