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.types_payroll_sheet_parser import TypesPayrollSheetParser


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


@_attrs_define
class TypesPayrollReportParser:
    """
    Attributes:
        field_id (str | Unset):
        client (str | Unset):
        created_at (str | Unset): Time tracking
        created_by (str | Unset): User ID
        deleted_at (str | Unset):
        name (str | Unset): Optional (only use if there is more than 1 parser for a client)
        sheets (list[TypesPayrollSheetParser] | Unset):
        team (str | Unset):
    """

    field_id: str | Unset = UNSET
    client: str | Unset = UNSET
    created_at: str | Unset = UNSET
    created_by: str | Unset = UNSET
    deleted_at: str | Unset = UNSET
    name: str | Unset = UNSET
    sheets: list[TypesPayrollSheetParser] | Unset = UNSET
    team: str | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

        client = self.client

        created_at = self.created_at

        created_by = self.created_by

        deleted_at = self.deleted_at

        name = self.name

        sheets: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.sheets, Unset):
            sheets = []
            for sheets_item_data in self.sheets:
                sheets_item = sheets_item_data.to_dict()
                sheets.append(sheets_item)

        team = self.team

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if field_id is not UNSET:
            field_dict["_id"] = field_id
        if client is not UNSET:
            field_dict["client"] = client
        if created_at is not UNSET:
            field_dict["created_at"] = created_at
        if created_by is not UNSET:
            field_dict["created_by"] = created_by
        if deleted_at is not UNSET:
            field_dict["deleted_at"] = deleted_at
        if name is not UNSET:
            field_dict["name"] = name
        if sheets is not UNSET:
            field_dict["sheets"] = sheets
        if team is not UNSET:
            field_dict["team"] = team

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        from ..models.types_payroll_sheet_parser import TypesPayrollSheetParser

        d = dict(src_dict)
        field_id = d.pop("_id", UNSET)

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

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

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

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

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

        _sheets = d.pop("sheets", UNSET)
        sheets: list[TypesPayrollSheetParser] | Unset = UNSET
        if _sheets is not UNSET:
            sheets = []
            for sheets_item_data in _sheets:
                sheets_item = TypesPayrollSheetParser.from_dict(sheets_item_data)

                sheets.append(sheets_item)

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

        types_payroll_report_parser = cls(
            field_id=field_id,
            client=client,
            created_at=created_at,
            created_by=created_by,
            deleted_at=deleted_at,
            name=name,
            sheets=sheets,
            team=team,
        )

        types_payroll_report_parser.additional_properties = d
        return types_payroll_report_parser

    @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
