# 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, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from teambition_oapi_sdk.model.search_project_tasks_v3_response_result_inner_customfields_inner import SearchProjectTasksV3ResponseResultInnerCustomfieldsInner
from typing import Optional, Set
from typing_extensions import Self

class SearchProjectTasksV3ResponseResultInner(BaseModel):
    """
    任务详情
    """ # noqa: E501
    id: Optional[StrictStr] = Field(default=None, description="任务ID")
    content: Optional[StrictStr] = Field(default=None, description="任务标题")
    note: Optional[StrictStr] = Field(default=None, description="任务备注")
    project_id: Optional[StrictStr] = Field(default=None, description="项目ID", alias="projectId")
    ancestor_ids: Optional[List[StrictStr]] = Field(default=None, description="祖先任务ID列表", alias="ancestorIds")
    parent_task_id: Optional[StrictStr] = Field(default=None, description="父任务ID", alias="parentTaskId")
    tfs_id: Optional[StrictStr] = Field(default=None, description="任务状态ID", alias="tfsId")
    tasklist_id: Optional[StrictStr] = Field(default=None, description="任务分组ID", alias="tasklistId")
    stage_id: Optional[StrictStr] = Field(default=None, description="任务列ID", alias="stageId")
    tag_ids: Optional[List[StrictStr]] = Field(default=None, description="标签ID集合", alias="tagIds")
    creator_id: Optional[StrictStr] = Field(default=None, description="创建人ID", alias="creatorId")
    executor_id: Optional[StrictStr] = Field(default=None, description="执行人ID", alias="executorId")
    involve_members: Optional[List[StrictStr]] = Field(default=None, description="参与者ID集合", alias="involveMembers")
    priority: Optional[StrictInt] = Field(default=None, description="任务优先级")
    story_point: Optional[StrictStr] = Field(default=None, description="StoryPoint", alias="storyPoint")
    recurrence: Optional[List[StrictStr]] = Field(default=None, description="重复规则列表")
    is_done: Optional[StrictBool] = Field(default=None, description="是否任务已完成", alias="isDone")
    is_archived: Optional[StrictBool] = Field(default=None, description="是否任务放入回收站", alias="isArchived")
    visible: Optional[StrictStr] = Field(default=None, description="任务隐私性，'involves'表达仅参与者可见; 'members'表达项目成员可见")
    unique_id: Optional[StrictStr] = Field(default=None, description="任务数字ID", alias="uniqueId")
    start_date: Optional[StrictStr] = Field(default=None, description="任务开始时间(UTC)", alias="startDate")
    due_date: Optional[StrictStr] = Field(default=None, description="任务截止时间(UTC)", alias="dueDate")
    accomplish_time: Optional[StrictStr] = Field(default=None, description="任务完成时间(UTC)", alias="accomplishTime")
    created: Optional[StrictStr] = Field(default=None, description="创建时间(UTC)")
    updated: Optional[StrictStr] = Field(default=None, description="更新时间(UTC)")
    sfc_id: Optional[StrictStr] = Field(default=None, description="任务类型ID", alias="sfcId")
    sprint_id: Optional[StrictStr] = Field(default=None, description="迭代ID", alias="sprintId")
    source_id: Optional[StrictStr] = Field(default=None, description="复制任务时，原任务的ID", alias="sourceId")
    progress: Optional[StrictInt] = Field(default=None, description="任务进度")
    pos: Optional[StrictInt] = Field(default=None, description="任务在父任务中的相对顺序")
    customfields: Optional[List[SearchProjectTasksV3ResponseResultInnerCustomfieldsInner]] = Field(default=None, description="自定义字段值集合")
    __properties: ClassVar[List[str]] = ["id", "content", "note", "projectId", "ancestorIds", "parentTaskId", "tfsId", "tasklistId", "stageId", "tagIds", "creatorId", "executorId", "involveMembers", "priority", "storyPoint", "recurrence", "isDone", "isArchived", "visible", "uniqueId", "startDate", "dueDate", "accomplishTime", "created", "updated", "sfcId", "sprintId", "sourceId", "progress", "pos", "customfields"]

    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 SearchProjectTasksV3ResponseResultInner 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 customfields (list)
        _items = []
        if self.customfields:
            for _item_customfields in self.customfields:
                if _item_customfields:
                    _items.append(_item_customfields.to_dict())
            _dict['customfields'] = _items
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of SearchProjectTasksV3ResponseResultInner 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"),
            "content": obj.get("content"),
            "note": obj.get("note"),
            "projectId": obj.get("projectId"),
            "ancestorIds": obj.get("ancestorIds"),
            "parentTaskId": obj.get("parentTaskId"),
            "tfsId": obj.get("tfsId"),
            "tasklistId": obj.get("tasklistId"),
            "stageId": obj.get("stageId"),
            "tagIds": obj.get("tagIds"),
            "creatorId": obj.get("creatorId"),
            "executorId": obj.get("executorId"),
            "involveMembers": obj.get("involveMembers"),
            "priority": obj.get("priority"),
            "storyPoint": obj.get("storyPoint"),
            "recurrence": obj.get("recurrence"),
            "isDone": obj.get("isDone"),
            "isArchived": obj.get("isArchived"),
            "visible": obj.get("visible"),
            "uniqueId": obj.get("uniqueId"),
            "startDate": obj.get("startDate"),
            "dueDate": obj.get("dueDate"),
            "accomplishTime": obj.get("accomplishTime"),
            "created": obj.get("created"),
            "updated": obj.get("updated"),
            "sfcId": obj.get("sfcId"),
            "sprintId": obj.get("sprintId"),
            "sourceId": obj.get("sourceId"),
            "progress": obj.get("progress"),
            "pos": obj.get("pos"),
            "customfields": [SearchProjectTasksV3ResponseResultInnerCustomfieldsInner.from_dict(_item) for _item in obj["customfields"]] if obj.get("customfields") is not None else None
        })
        return _obj


