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.rc_info import RCInfo
    from ..models.read_info import ReadInfo


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


@_attrs_define
class DocumentJob:
    """
    Attributes:
        upload (str | Unset):
        working (bool | Unset):
        worker (str | Unset):
        status (str | Unset):
        success (bool | Unset):
        error (str | Unset):
        read (ReadInfo | Unset):
        rc (RCInfo | Unset):
    """

    upload: str | Unset = UNSET
    working: bool | Unset = UNSET
    worker: str | Unset = UNSET
    status: str | Unset = UNSET
    success: bool | Unset = UNSET
    error: str | Unset = UNSET
    read: ReadInfo | Unset = UNSET
    rc: RCInfo | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

        working = self.working

        worker = self.worker

        status = self.status

        success = self.success

        error = self.error

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

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

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if upload is not UNSET:
            field_dict["upload"] = upload
        if working is not UNSET:
            field_dict["working"] = working
        if worker is not UNSET:
            field_dict["worker"] = worker
        if status is not UNSET:
            field_dict["status"] = status
        if success is not UNSET:
            field_dict["success"] = success
        if error is not UNSET:
            field_dict["error"] = error
        if read is not UNSET:
            field_dict["read"] = read
        if rc is not UNSET:
            field_dict["rc"] = rc

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        from ..models.rc_info import RCInfo
        from ..models.read_info import ReadInfo

        d = dict(src_dict)
        upload = d.pop("upload", UNSET)

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

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

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

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

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

        _read = d.pop("read", UNSET)
        read: ReadInfo | Unset
        if isinstance(_read, Unset):
            read = UNSET
        else:
            read = ReadInfo.from_dict(_read)

        _rc = d.pop("rc", UNSET)
        rc: RCInfo | Unset
        if isinstance(_rc, Unset):
            rc = UNSET
        else:
            rc = RCInfo.from_dict(_rc)

        document_job = cls(
            upload=upload,
            working=working,
            worker=worker,
            status=status,
            success=success,
            error=error,
            read=read,
            rc=rc,
        )

        document_job.additional_properties = d
        return document_job

    @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
