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_file import TypesFile
    from ..models.types_payroll_parse_result import TypesPayrollParseResult


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


@_attrs_define
class TypesPayrollReport:
    """
    Attributes:
        field_id (str | Unset):
        check_date (str | Unset):
        client (str | Unset):
        deleted_at (str | Unset):
        error (str | Unset):
        file (TypesFile | Unset):
        parse_result (TypesPayrollParseResult | Unset):
        parsed_at (str | Unset):
        parser (str | Unset):
        pay_period_end (str | Unset):
        pay_period_start (str | Unset):
        project (str | Unset):
        py (int | Unset):
        status (str | Unset):
        task (str | Unset): Keep track of the task and project of the task used to collect the report so any correction
            tasks can be added to the same project
        team (str | Unset):
        trace (str | Unset):
        type_ (str | Unset): This can be an actual payroll report or a census file: "payroll" or "census"
        uploaded_at (str | Unset):
        uploaded_by (str | Unset):
    """

    field_id: str | Unset = UNSET
    check_date: str | Unset = UNSET
    client: str | Unset = UNSET
    deleted_at: str | Unset = UNSET
    error: str | Unset = UNSET
    file: TypesFile | Unset = UNSET
    parse_result: TypesPayrollParseResult | Unset = UNSET
    parsed_at: str | Unset = UNSET
    parser: str | Unset = UNSET
    pay_period_end: str | Unset = UNSET
    pay_period_start: str | Unset = UNSET
    project: str | Unset = UNSET
    py: int | Unset = UNSET
    status: str | Unset = UNSET
    task: str | Unset = UNSET
    team: str | Unset = UNSET
    trace: str | Unset = UNSET
    type_: str | Unset = UNSET
    uploaded_at: str | Unset = UNSET
    uploaded_by: 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

        check_date = self.check_date

        client = self.client

        deleted_at = self.deleted_at

        error = self.error

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

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

        parsed_at = self.parsed_at

        parser = self.parser

        pay_period_end = self.pay_period_end

        pay_period_start = self.pay_period_start

        project = self.project

        py = self.py

        status = self.status

        task = self.task

        team = self.team

        trace = self.trace

        type_ = self.type_

        uploaded_at = self.uploaded_at

        uploaded_by = self.uploaded_by

        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 check_date is not UNSET:
            field_dict["check_date"] = check_date
        if client is not UNSET:
            field_dict["client"] = client
        if deleted_at is not UNSET:
            field_dict["deleted_at"] = deleted_at
        if error is not UNSET:
            field_dict["error"] = error
        if file is not UNSET:
            field_dict["file"] = file
        if parse_result is not UNSET:
            field_dict["parse_result"] = parse_result
        if parsed_at is not UNSET:
            field_dict["parsed_at"] = parsed_at
        if parser is not UNSET:
            field_dict["parser"] = parser
        if pay_period_end is not UNSET:
            field_dict["pay_period_end"] = pay_period_end
        if pay_period_start is not UNSET:
            field_dict["pay_period_start"] = pay_period_start
        if project is not UNSET:
            field_dict["project"] = project
        if py is not UNSET:
            field_dict["py"] = py
        if status is not UNSET:
            field_dict["status"] = status
        if task is not UNSET:
            field_dict["task"] = task
        if team is not UNSET:
            field_dict["team"] = team
        if trace is not UNSET:
            field_dict["trace"] = trace
        if type_ is not UNSET:
            field_dict["type"] = type_
        if uploaded_at is not UNSET:
            field_dict["uploaded_at"] = uploaded_at
        if uploaded_by is not UNSET:
            field_dict["uploaded_by"] = uploaded_by

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        from ..models.types_file import TypesFile
        from ..models.types_payroll_parse_result import TypesPayrollParseResult

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

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

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

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

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

        _file = d.pop("file", UNSET)
        file: TypesFile | Unset
        if isinstance(_file, Unset):
            file = UNSET
        else:
            file = TypesFile.from_dict(_file)

        _parse_result = d.pop("parse_result", UNSET)
        parse_result: TypesPayrollParseResult | Unset
        if isinstance(_parse_result, Unset):
            parse_result = UNSET
        else:
            parse_result = TypesPayrollParseResult.from_dict(_parse_result)

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

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

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

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

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

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

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

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

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

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

        type_ = d.pop("type", UNSET)

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

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

        types_payroll_report = cls(
            field_id=field_id,
            check_date=check_date,
            client=client,
            deleted_at=deleted_at,
            error=error,
            file=file,
            parse_result=parse_result,
            parsed_at=parsed_at,
            parser=parser,
            pay_period_end=pay_period_end,
            pay_period_start=pay_period_start,
            project=project,
            py=py,
            status=status,
            task=task,
            team=team,
            trace=trace,
            type_=type_,
            uploaded_at=uploaded_at,
            uploaded_by=uploaded_by,
        )

        types_payroll_report.additional_properties = d
        return types_payroll_report

    @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
