from typing import Any, Dict, Type, TypeVar, Union

import attr

from ..types import UNSET, Unset

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


try:
    from ..models import simple_value_activity_item
except ImportError:
    import sys

    simple_value_activity_item = sys.modules[__package__ + "simple_value_activity_item"]


@attr.s(auto_attribs=True)
class UsesMarkupActivityItem(simple_value_activity_item.SimpleValueActivityItem):
    """Represents the change of the boolean flag that indicates whether YouTrack Wiki or Markdown
    is used in the target entity as a markup language. If "true", then the markdown is used.
    Otherwise, YouTrack Wiki markup."""

    removed: "Union[Unset, bool]" = UNSET
    added: "Union[Unset, bool]" = UNSET
    markup: "Union[Unset, str]" = UNSET

    def to_dict(self) -> Dict[str, Any]:
        removed = self.removed
        added = self.added
        markup = self.markup

        field_dict: Dict[str, Any] = {}
        _SimpleValueActivityItem_dict = super().to_dict()
        field_dict.update(_SimpleValueActivityItem_dict)
        field_dict.update({})
        if removed is not UNSET:
            field_dict["removed"] = removed
        if added is not UNSET:
            field_dict["added"] = added
        if markup is not UNSET:
            field_dict["markup"] = markup

        return field_dict

    @classmethod
    def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:

        d = src_dict.copy()

        _SimpleValueActivityItem_kwargs = super().from_dict(src_dict=d).to_dict()
        _SimpleValueActivityItem_kwargs.pop("$type")

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

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

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

        uses_markup_activity_item = cls(
            removed=removed,
            added=added,
            markup=markup,
            **_SimpleValueActivityItem_kwargs,
        )

        return uses_markup_activity_item
