# 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.summary_message import SummaryMessage
from syntheticusers.models.summary_section import SummarySection
from typing import Optional, Set
from typing_extensions import Self

class Summary(BaseModel):
    """
    Summary
    """ # noqa: E501
    id: StrictStr
    content: Optional[StrictStr] = None
    sections: List[SummarySection]
    project_id: StrictStr = Field(alias="projectId")
    created_at: datetime = Field(alias="createdAt")
    status: StrictStr
    user_interviews: List[StrictStr] = Field(alias="userInterviews")
    problems: List[StrictStr]
    solution: Optional[StrictStr] = None
    research_goal: Optional[StrictStr] = Field(default=None, alias="researchGoal")
    audiences: List[StrictStr]
    user_interviews_count: StrictInt = Field(alias="userInterviewsCount")
    saved: StrictBool
    study_id: Optional[StrictStr] = Field(default=None, alias="studyId")
    synthetic_users: List[StrictStr] = Field(alias="syntheticUsers")
    messages: Optional[List[SummaryMessage]] = None
    summarization_focus: Optional[StrictStr] = Field(default=None, alias="summarizationFocus")
    __properties: ClassVar[List[str]] = ["id", "content", "sections", "projectId", "createdAt", "status", "userInterviews", "problems", "solution", "researchGoal", "audiences", "userInterviewsCount", "saved", "studyId", "syntheticUsers", "messages", "summarizationFocus"]

    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 Summary 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 sections (list)
        _items = []
        if self.sections:
            for _item_sections in self.sections:
                if _item_sections:
                    _items.append(_item_sections.to_dict())
            _dict['sections'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in messages (list)
        _items = []
        if self.messages:
            for _item_messages in self.messages:
                if _item_messages:
                    _items.append(_item_messages.to_dict())
            _dict['messages'] = _items
        # set to None if content (nullable) is None
        # and model_fields_set contains the field
        if self.content is None and "content" in self.model_fields_set:
            _dict['content'] = None

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

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

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

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

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of Summary 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"),
            "sections": [SummarySection.from_dict(_item) for _item in obj["sections"]] if obj.get("sections") is not None else None,
            "projectId": obj.get("projectId"),
            "createdAt": obj.get("createdAt"),
            "status": obj.get("status"),
            "userInterviews": obj.get("userInterviews"),
            "problems": obj.get("problems"),
            "solution": obj.get("solution"),
            "researchGoal": obj.get("researchGoal"),
            "audiences": obj.get("audiences"),
            "userInterviewsCount": obj.get("userInterviewsCount"),
            "saved": obj.get("saved"),
            "studyId": obj.get("studyId"),
            "syntheticUsers": obj.get("syntheticUsers"),
            "messages": [SummaryMessage.from_dict(_item) for _item in obj["messages"]] if obj.get("messages") is not None else None,
            "summarizationFocus": obj.get("summarizationFocus")
        })
        return _obj


