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.bt_id_translation_result_info import BTIdTranslationResultInfo


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


@_attrs_define
class BTIdTranslationInfo:
    """
    Attributes:
        document_id (str | Unset):
        element_id (str | Unset):
        ids (list[BTIdTranslationResultInfo] | Unset):
        source_document_microversion (str | Unset):
        target_document_microversion (str | Unset):
    """

    document_id: str | Unset = UNSET
    element_id: str | Unset = UNSET
    ids: list[BTIdTranslationResultInfo] | Unset = UNSET
    source_document_microversion: str | Unset = UNSET
    target_document_microversion: str | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

        element_id = self.element_id

        ids: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.ids, Unset):
            ids = []
            for ids_item_data in self.ids:
                ids_item = ids_item_data.to_dict()
                ids.append(ids_item)

        source_document_microversion = self.source_document_microversion

        target_document_microversion = self.target_document_microversion

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if document_id is not UNSET:
            field_dict["documentId"] = document_id
        if element_id is not UNSET:
            field_dict["elementId"] = element_id
        if ids is not UNSET:
            field_dict["ids"] = ids
        if source_document_microversion is not UNSET:
            field_dict["sourceDocumentMicroversion"] = source_document_microversion
        if target_document_microversion is not UNSET:
            field_dict["targetDocumentMicroversion"] = target_document_microversion

        return field_dict

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

        d = dict(src_dict)
        document_id = d.pop("documentId", UNSET)

        element_id = d.pop("elementId", UNSET)

        _ids = d.pop("ids", UNSET)
        ids: list[BTIdTranslationResultInfo] | Unset = UNSET
        if _ids is not UNSET:
            ids = []
            for ids_item_data in _ids:
                ids_item = BTIdTranslationResultInfo.from_dict(ids_item_data)

                ids.append(ids_item)

        source_document_microversion = d.pop("sourceDocumentMicroversion", UNSET)

        target_document_microversion = d.pop("targetDocumentMicroversion", UNSET)

        bt_id_translation_info = cls(
            document_id=document_id,
            element_id=element_id,
            ids=ids,
            source_document_microversion=source_document_microversion,
            target_document_microversion=target_document_microversion,
        )

        bt_id_translation_info.additional_properties = d
        return bt_id_translation_info

    @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
