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.legacytypes_compliance_submission import LegacytypesComplianceSubmission


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


@_attrs_define
class PkgRoutesComplianceGetComplianceSubmissionResponse:
    """
    Attributes:
        active_submission (LegacytypesComplianceSubmission | Unset):
        prior_year_submission (LegacytypesComplianceSubmission | Unset):
        submissions (list[LegacytypesComplianceSubmission] | Unset):
    """

    active_submission: LegacytypesComplianceSubmission | Unset = UNSET
    prior_year_submission: LegacytypesComplianceSubmission | Unset = UNSET
    submissions: list[LegacytypesComplianceSubmission] | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

    def to_dict(self) -> dict[str, Any]:
        active_submission: dict[str, Any] | Unset = UNSET
        if not isinstance(self.active_submission, Unset):
            active_submission = self.active_submission.to_dict()

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

        submissions: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.submissions, Unset):
            submissions = []
            for submissions_item_data in self.submissions:
                submissions_item = submissions_item_data.to_dict()
                submissions.append(submissions_item)

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if active_submission is not UNSET:
            field_dict["active_submission"] = active_submission
        if prior_year_submission is not UNSET:
            field_dict["prior_year_submission"] = prior_year_submission
        if submissions is not UNSET:
            field_dict["submissions"] = submissions

        return field_dict

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

        d = dict(src_dict)
        _active_submission = d.pop("active_submission", UNSET)
        active_submission: LegacytypesComplianceSubmission | Unset
        if isinstance(_active_submission, Unset):
            active_submission = UNSET
        else:
            active_submission = LegacytypesComplianceSubmission.from_dict(_active_submission)

        _prior_year_submission = d.pop("prior_year_submission", UNSET)
        prior_year_submission: LegacytypesComplianceSubmission | Unset
        if isinstance(_prior_year_submission, Unset):
            prior_year_submission = UNSET
        else:
            prior_year_submission = LegacytypesComplianceSubmission.from_dict(_prior_year_submission)

        _submissions = d.pop("submissions", UNSET)
        submissions: list[LegacytypesComplianceSubmission] | Unset = UNSET
        if _submissions is not UNSET:
            submissions = []
            for submissions_item_data in _submissions:
                submissions_item = LegacytypesComplianceSubmission.from_dict(submissions_item_data)

                submissions.append(submissions_item)

        pkg_routes_compliance_get_compliance_submission_response = cls(
            active_submission=active_submission,
            prior_year_submission=prior_year_submission,
            submissions=submissions,
        )

        pkg_routes_compliance_get_compliance_submission_response.additional_properties = d
        return pkg_routes_compliance_get_compliance_submission_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
