# coding: utf-8

"""
    Synthetic Users

     **Description**: Synthetic Users provides AI-powered, human-like participants for user and market research, streamlining data collection and insight generation. With multi-agent architecture, it simulates realistic, scalable interactions, enabling efficient research through synthetic interviews and surveys.  **Features**: - **In-depth Interviews**: Interactive, AI-driven interviews with customizable follow-up options. - **Global Surveys**: Fast, quantitative data collection at scale. - **Customizable Synthetic Users**: Integrate proprietary data for tailored research. - **Multi-agent Framework**: Mimics real human interactions for accurate insights.  **Use Cases**: - **Product Testing**: Identify needs and refine concepts. - **Market Analysis**: Expand reach and enhance user satisfaction.    For more information, visit [Synthetic Users](https://www.syntheticusers.com).

    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 datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from syntheticusers.models.app_api_schemas_studies_sub_plan_type import AppApiSchemasStudiesSubPlanType
from syntheticusers.models.study_progress import StudyProgress
from typing import Optional, Set
from typing_extensions import Self

class StudyCreate(BaseModel):
    """
    StudyCreate
    """ # noqa: E501
    description: Optional[StrictStr] = None
    project_id: StrictStr = Field(alias="projectId")
    created_at: Optional[datetime] = Field(default=None, alias="createdAt")
    bookmarked: Optional[StrictBool] = None
    language: StrictStr
    audiences: List[StrictStr]
    problems: List[StrictStr]
    files: List[StrictStr]
    progress: Optional[StudyProgress] = None
    status: Optional[StrictStr] = None
    solution_id: Optional[StrictStr] = Field(default=None, alias="solutionId")
    research_goal_id: Optional[StrictStr] = Field(default=None, alias="researchGoalId")
    knowledge_graphs: Optional[List[StrictStr]] = Field(default=None, alias="knowledgeGraphs")
    strategy: AppApiSchemasStudiesSubPlanType
    interview_count: Optional[StrictInt] = Field(default=None, alias="interviewCount")
    custom_script: Optional[StrictStr] = Field(default=None, alias="customScript")
    guide: Optional[Dict[str, Any]] = None
    interviews: Optional[List[StrictStr]] = None
    __properties: ClassVar[List[str]] = ["description", "projectId", "createdAt", "bookmarked", "language", "audiences", "problems", "files", "progress", "status", "solutionId", "researchGoalId", "knowledgeGraphs", "strategy", "interviewCount", "guide", "customScript", "interviews"]

    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 StudyCreate 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 progress
        if self.progress:
            _dict['progress'] = self.progress.to_dict()
        # set to None if description (nullable) is None
        # and model_fields_set contains the field
        if self.description is None and "description" in self.model_fields_set:
            _dict['description'] = None

        # set to None if created_at (nullable) is None
        # and model_fields_set contains the field
        if self.created_at is None and "created_at" in self.model_fields_set:
            _dict['createdAt'] = None

        # set to None if bookmarked (nullable) is None
        # and model_fields_set contains the field
        if self.bookmarked is None and "bookmarked" in self.model_fields_set:
            _dict['bookmarked'] = None

        # set to None if progress (nullable) is None
        # and model_fields_set contains the field
        if self.progress is None and "progress" in self.model_fields_set:
            _dict['progress'] = None

        # set to None if status (nullable) is None
        # and model_fields_set contains the field
        if self.status is None and "status" in self.model_fields_set:
            _dict['status'] = None

        # set to None if solution_id (nullable) is None
        # and model_fields_set contains the field
        if self.solution_id is None and "solution_id" in self.model_fields_set:
            _dict['solutionId'] = None

        # set to None if research_goal_id (nullable) is None
        # and model_fields_set contains the field
        if self.research_goal_id is None and "research_goal_id" in self.model_fields_set:
            _dict['researchGoalId'] = None

        # set to None if knowledge_graphs (nullable) is None
        # and model_fields_set contains the field
        if self.knowledge_graphs is None and "knowledge_graphs" in self.model_fields_set:
            _dict['knowledgeGraphs'] = None

        # set to None if interview_count (nullable) is None
        # and model_fields_set contains the field
        if self.interview_count is None and "interview_count" in self.model_fields_set:
            _dict['interviewCount'] = None

        # set to None if custom_script (nullable) is None
        # and model_fields_set contains the field
        if self.custom_script is None and "custom_script" in self.model_fields_set:
            _dict['customScript'] = None
        # set to None if guide (nullable) is None
        # and model_fields_set contains the field
        if self.guide is None and "guide" in self.model_fields_set:
            _dict['guide'] = None

        # set to None if interviews (nullable) is None
        # and model_fields_set contains the field
        if self.interviews is None and "interviews" in self.model_fields_set:
            _dict['interviews'] = None

        return _dict

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

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

        _obj = cls.model_validate({
            "description": obj.get("description"),
            "projectId": obj.get("projectId"),
            "createdAt": obj.get("createdAt"),
            "bookmarked": obj.get("bookmarked"),
            "language": obj.get("language"),
            "audiences": obj.get("audiences"),
            "problems": obj.get("problems"),
            "files": obj.get("files"),
            "progress": StudyProgress.from_dict(obj["progress"]) if obj.get("progress") is not None else None,
            "status": obj.get("status"),
            "solutionId": obj.get("solutionId"),
            "researchGoalId": obj.get("researchGoalId"),
            "knowledgeGraphs": obj.get("knowledgeGraphs"),
            "strategy": obj.get("strategy"),
            "interviewCount": obj.get("interviewCount"),
            "customScript": obj.get("customScript"),
            "guide": obj.get("guide"),
            "interviews": obj.get("interviews")
        })
        return _obj


