# coding: utf-8

"""
    Fastify Template API

    API documentation using Swagger

    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, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from keplar_api.models.brief_document_version import BriefDocumentVersion
from keplar_api.models.project_audience import ProjectAudience
from keplar_api.models.project_brief import ProjectBrief
from keplar_api.models.project_kind import ProjectKind
from keplar_api.models.screener_question import ScreenerQuestion
from typing import Optional, Set
from typing_extensions import Self

class ProjectConfig(BaseModel):
    """
    ProjectConfig
    """ # noqa: E501
    project_kind: Optional[ProjectKind] = Field(default=None, alias="projectKind")
    prompt_variables: Dict[str, Any] = Field(alias="promptVariables")
    learning_plan: StrictStr = Field(alias="learningPlan")
    brief: Optional[ProjectBrief] = None
    current_brief_version: Optional[BriefDocumentVersion] = Field(default=None, alias="currentBriefVersion")
    brief_document: Optional[StrictStr] = Field(default=None, alias="briefDocument")
    screener_questions: Optional[List[ScreenerQuestion]] = Field(default=None, alias="screenerQuestions")
    audience_settings: Optional[ProjectAudience] = Field(default=None, alias="audienceSettings")
    __properties: ClassVar[List[str]] = ["projectKind", "promptVariables", "learningPlan", "brief", "currentBriefVersion", "briefDocument", "screenerQuestions", "audienceSettings"]

    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 ProjectConfig 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 brief
        if self.brief:
            _dict['brief'] = self.brief.to_dict()
        # override the default output from pydantic by calling `to_dict()` of current_brief_version
        if self.current_brief_version:
            _dict['currentBriefVersion'] = self.current_brief_version.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in screener_questions (list)
        _items = []
        if self.screener_questions:
            for _item_screener_questions in self.screener_questions:
                if _item_screener_questions:
                    _items.append(_item_screener_questions.to_dict())
            _dict['screenerQuestions'] = _items
        # override the default output from pydantic by calling `to_dict()` of audience_settings
        if self.audience_settings:
            _dict['audienceSettings'] = self.audience_settings.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "projectKind": obj.get("projectKind"),
            "promptVariables": obj.get("promptVariables"),
            "learningPlan": obj.get("learningPlan"),
            "brief": ProjectBrief.from_dict(obj["brief"]) if obj.get("brief") is not None else None,
            "currentBriefVersion": BriefDocumentVersion.from_dict(obj["currentBriefVersion"]) if obj.get("currentBriefVersion") is not None else None,
            "briefDocument": obj.get("briefDocument"),
            "screenerQuestions": [ScreenerQuestion.from_dict(_item) for _item in obj["screenerQuestions"]] if obj.get("screenerQuestions") is not None else None,
            "audienceSettings": ProjectAudience.from_dict(obj["audienceSettings"]) if obj.get("audienceSettings") is not None else None
        })
        return _obj


