# coding: utf-8

"""
    Teambition Open API

    Teambition Open API

    The version of the OpenAPI document: 1.0.0
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501



from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from teambition_oapi_sdk.model.put_v3_task_node_complete_response_result_done_opinions_inner import PutV3TaskNodeCompleteResponseResultDoneOpinionsInner
from typing import Optional, Set
from typing_extensions import Self

class PutV3TaskNodeCompleteResponseResult(BaseModel):
    """
    更新后的任务节点数据
    """ # noqa: E501
    id: Optional[StrictStr] = None
    task_id: Optional[StrictStr] = Field(default=None, alias="taskId")
    tfs_id: Optional[StrictStr] = Field(default=None, description="节点对应的工作流状态", alias="tfsId")
    status: Optional[StrictStr] = Field(default=None, description="节点当前状态 - ready 待开始 - begin 进行中 - finish 已完成 ")
    assignee_ids: Optional[List[StrictStr]] = Field(default=None, description="节点负责人列表", alias="assigneeIds")
    started: Optional[StrictStr] = Field(default=None, description="节点实际开始时间")
    accomplished: Optional[StrictStr] = Field(default=None, description="节点实际完成时间")
    start_date: Optional[StrictStr] = Field(default=None, description="节点计划开始时间", alias="startDate")
    due_date: Optional[StrictStr] = Field(default=None, description="节点计划完成时间", alias="dueDate")
    disable_create_subtask: Optional[StrictBool] = Field(default=None, description="是否禁止创建子任务", alias="disableCreateSubtask")
    is_auto_finish: Optional[StrictBool] = Field(default=None, description="是否自动完成", alias="isAutoFinish")
    name: Optional[StrictStr] = Field(default=None, description="节点名称")
    prev_ids: Optional[List[StrictStr]] = Field(default=None, description="前置节点ID列表", alias="prevIds")
    done_opinions: Optional[List[PutV3TaskNodeCompleteResponseResultDoneOpinionsInner]] = Field(default=None, alias="doneOpinions")
    __properties: ClassVar[List[str]] = ["id", "taskId", "tfsId", "status", "assigneeIds", "started", "accomplished", "startDate", "dueDate", "disableCreateSubtask", "isAutoFinish", "name", "prevIds", "doneOpinions"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of PutV3TaskNodeCompleteResponseResult from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of each item in done_opinions (list)
        _items = []
        if self.done_opinions:
            for _item_done_opinions in self.done_opinions:
                if _item_done_opinions:
                    _items.append(_item_done_opinions.to_dict())
            _dict['doneOpinions'] = _items
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of PutV3TaskNodeCompleteResponseResult from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "id": obj.get("id"),
            "taskId": obj.get("taskId"),
            "tfsId": obj.get("tfsId"),
            "status": obj.get("status"),
            "assigneeIds": obj.get("assigneeIds"),
            "started": obj.get("started"),
            "accomplished": obj.get("accomplished"),
            "startDate": obj.get("startDate"),
            "dueDate": obj.get("dueDate"),
            "disableCreateSubtask": obj.get("disableCreateSubtask"),
            "isAutoFinish": obj.get("isAutoFinish"),
            "name": obj.get("name"),
            "prevIds": obj.get("prevIds"),
            "doneOpinions": [PutV3TaskNodeCompleteResponseResultDoneOpinionsInner.from_dict(_item) for _item in obj["doneOpinions"]] if obj.get("doneOpinions") is not None else None
        })
        return _obj


