from __future__ import annotations

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

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

from ..types import UNSET, Unset

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


@_attrs_define
class PkgRoutesCpNotice:
    """
    Attributes:
        date (str | Unset):
        downloaded (int | Unset):
        file (str | Unset):
        for_participant (bool | Unset):
        name (str | Unset):
        opened (int | Unset):
        task (str | Unset):
        total (int | Unset):
    """

    date: str | Unset = UNSET
    downloaded: int | Unset = UNSET
    file: str | Unset = UNSET
    for_participant: bool | Unset = UNSET
    name: str | Unset = UNSET
    opened: int | Unset = UNSET
    task: str | Unset = UNSET
    total: int | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

    def to_dict(self) -> dict[str, Any]:
        date = self.date

        downloaded = self.downloaded

        file = self.file

        for_participant = self.for_participant

        name = self.name

        opened = self.opened

        task = self.task

        total = self.total

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if date is not UNSET:
            field_dict["date"] = date
        if downloaded is not UNSET:
            field_dict["downloaded"] = downloaded
        if file is not UNSET:
            field_dict["file"] = file
        if for_participant is not UNSET:
            field_dict["for_participant"] = for_participant
        if name is not UNSET:
            field_dict["name"] = name
        if opened is not UNSET:
            field_dict["opened"] = opened
        if task is not UNSET:
            field_dict["task"] = task
        if total is not UNSET:
            field_dict["total"] = total

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        d = dict(src_dict)
        date = d.pop("date", UNSET)

        downloaded = d.pop("downloaded", UNSET)

        file = d.pop("file", UNSET)

        for_participant = d.pop("for_participant", UNSET)

        name = d.pop("name", UNSET)

        opened = d.pop("opened", UNSET)

        task = d.pop("task", UNSET)

        total = d.pop("total", UNSET)

        pkg_routes_cp_notice = cls(
            date=date,
            downloaded=downloaded,
            file=file,
            for_participant=for_participant,
            name=name,
            opened=opened,
            task=task,
            total=total,
        )

        pkg_routes_cp_notice.additional_properties = d
        return pkg_routes_cp_notice

    @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
