# 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.create_test_case_v3_response_result_customfields_inner import CreateTestCaseV3ResponseResultCustomfieldsInner
from typing import Optional, Set
from typing_extensions import Self

class CreateTestCaseV3ResponseResult(BaseModel):
    """
    CreateTestCaseV3ResponseResult
    """ # noqa: E501
    accomplished: Optional[StrictStr] = Field(default=None, description="完成时间")
    created: Optional[StrictStr] = Field(default=None, description="测试用例创建时间(UTC)")
    creator_id: Optional[StrictStr] = Field(default=None, description="创建者 ID", alias="creatorId")
    customfields: Optional[List[CreateTestCaseV3ResponseResultCustomfieldsInner]] = Field(default=None, description="自定义字段值集合")
    executor_id: Optional[StrictStr] = Field(default=None, description="执行者ID", alias="executorId")
    flowstatus_id: Optional[StrictStr] = Field(default=None, description="工作流状态 ID", alias="flowstatusId")
    from_hub_testcase_id: Optional[StrictStr] = Field(default=None, description="关联的基础用例ID", alias="fromHubTestcaseId")
    id: Optional[StrictStr] = Field(default=None, description="测试用例 ID")
    is_archived: Optional[StrictStr] = Field(default=None, description="是否归档", alias="isArchived")
    is_done: Optional[StrictBool] = Field(default=None, description="是否完成", alias="isDone")
    pos: Optional[StrictInt] = Field(default=None, description="用例位置")
    precondition: Optional[StrictStr] = Field(default=None, description="前置条件")
    project_id: Optional[StrictStr] = Field(default=None, description="项目 ID", alias="projectId")
    scenariofieldconfig_id: Optional[StrictStr] = Field(default=None, description="任务类型 ID", alias="scenariofieldconfigId")
    tag_ids: Optional[List[StrictStr]] = Field(default=None, description="标签", alias="tagIds")
    testplan_id: Optional[StrictStr] = Field(default=None, description="测试计划 ID", alias="testplanId")
    title: Optional[StrictStr] = Field(default=None, description="用例名称")
    unique_id: Optional[StrictInt] = Field(default=None, description="短ID", alias="uniqueId")
    updated: Optional[StrictStr] = Field(default=None, description="测试用例更新时间(UTC)")
    __properties: ClassVar[List[str]] = ["accomplished", "created", "creatorId", "customfields", "executorId", "flowstatusId", "fromHubTestcaseId", "id", "isArchived", "isDone", "pos", "precondition", "projectId", "scenariofieldconfigId", "tagIds", "testplanId", "title", "uniqueId", "updated"]

    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 CreateTestCaseV3ResponseResult 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 CreateTestCaseV3ResponseResult from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "accomplished": obj.get("accomplished"),
            "created": obj.get("created"),
            "creatorId": obj.get("creatorId"),
            "customfields": [CreateTestCaseV3ResponseResultCustomfieldsInner.from_dict(_item) for _item in obj["customfields"]] if obj.get("customfields") is not None else None,
            "executorId": obj.get("executorId"),
            "flowstatusId": obj.get("flowstatusId"),
            "fromHubTestcaseId": obj.get("fromHubTestcaseId"),
            "id": obj.get("id"),
            "isArchived": obj.get("isArchived"),
            "isDone": obj.get("isDone"),
            "pos": obj.get("pos"),
            "precondition": obj.get("precondition"),
            "projectId": obj.get("projectId"),
            "scenariofieldconfigId": obj.get("scenariofieldconfigId"),
            "tagIds": obj.get("tagIds"),
            "testplanId": obj.get("testplanId"),
            "title": obj.get("title"),
            "uniqueId": obj.get("uniqueId"),
            "updated": obj.get("updated")
        })
        return _obj


