# coding: utf-8

"""
    Twenty Api

    Twenty is a customer relationship management (CRM) platform designed to help businesses manage their customer interactions and relationships effectively. The Twenty API provides programmatic access to the features and functionalities of the Twenty CRM platform, allowing developers to integrate and interact with the CRM data and operations.

    The version of the OpenAPI document: v0.1
    Contact: felix@twenty.com
    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, StrictInt
from typing import Any, ClassVar, Dict, List, Optional
from uuid import UUID
from typing import Optional, Set
from typing_extensions import Self
from pydantic_core import to_jsonable_python

class FavoriteForResponse(BaseModel):
    """
    A favorite
    """ # noqa: E501
    id: Optional[UUID] = Field(default=None, description="Id")
    created_at: Optional[datetime] = Field(default=None, description="Creation date", alias="createdAt")
    updated_at: Optional[datetime] = Field(default=None, description="Last time the record was changed", alias="updatedAt")
    deleted_at: Optional[datetime] = Field(default=None, description="Date when the record was deleted", alias="deletedAt")
    position: Optional[StrictInt] = Field(default=None, description="Favorite position")
    view_id: Optional[UUID] = Field(default=None, description="ViewId", alias="viewId")
    company_id: Optional[UUID] = Field(default=None, alias="companyId")
    dashboard_id: Optional[UUID] = Field(default=None, alias="dashboardId")
    for_workspace_member_id: Optional[UUID] = Field(default=None, alias="forWorkspaceMemberId")
    person_id: Optional[UUID] = Field(default=None, alias="personId")
    opportunity_id: Optional[UUID] = Field(default=None, alias="opportunityId")
    workflow_id: Optional[UUID] = Field(default=None, alias="workflowId")
    workflow_version_id: Optional[UUID] = Field(default=None, alias="workflowVersionId")
    workflow_run_id: Optional[UUID] = Field(default=None, alias="workflowRunId")
    task_id: Optional[UUID] = Field(default=None, alias="taskId")
    note_id: Optional[UUID] = Field(default=None, alias="noteId")
    favorite_folder_id: Optional[UUID] = Field(default=None, alias="favoriteFolderId")
    company: Optional[CompanyForResponse] = None
    dashboard: Optional[DashboardForResponse] = None
    for_workspace_member: Optional[WorkspaceMemberForResponse] = Field(default=None, alias="forWorkspaceMember")
    person: Optional[PersonForResponse] = None
    opportunity: Optional[OpportunityForResponse] = None
    workflow: Optional[WorkflowForResponse] = None
    workflow_version: Optional[WorkflowVersionForResponse] = Field(default=None, alias="workflowVersion")
    workflow_run: Optional[WorkflowRunForResponse] = Field(default=None, alias="workflowRun")
    task: Optional[TaskForResponse] = None
    note: Optional[NoteForResponse] = None
    favorite_folder: Optional[FavoriteFolderForResponse] = Field(default=None, alias="favoriteFolder")
    __properties: ClassVar[List[str]] = ["id", "createdAt", "updatedAt", "deletedAt", "position", "viewId", "companyId", "dashboardId", "forWorkspaceMemberId", "personId", "opportunityId", "workflowId", "workflowVersionId", "workflowRunId", "taskId", "noteId", "favoriteFolderId", "company", "dashboard", "forWorkspaceMember", "person", "opportunity", "workflow", "workflowVersion", "workflowRun", "task", "note", "favoriteFolder"]

    model_config = ConfigDict(
        validate_by_name=True,
        validate_by_alias=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"""
        return json.dumps(to_jsonable_python(self.to_dict()))

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of FavoriteForResponse 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 company
        if self.company:
            _dict['company'] = self.company.to_dict()
        # override the default output from pydantic by calling `to_dict()` of dashboard
        if self.dashboard:
            _dict['dashboard'] = self.dashboard.to_dict()
        # override the default output from pydantic by calling `to_dict()` of for_workspace_member
        if self.for_workspace_member:
            _dict['forWorkspaceMember'] = self.for_workspace_member.to_dict()
        # override the default output from pydantic by calling `to_dict()` of person
        if self.person:
            _dict['person'] = self.person.to_dict()
        # override the default output from pydantic by calling `to_dict()` of opportunity
        if self.opportunity:
            _dict['opportunity'] = self.opportunity.to_dict()
        # override the default output from pydantic by calling `to_dict()` of workflow
        if self.workflow:
            _dict['workflow'] = self.workflow.to_dict()
        # override the default output from pydantic by calling `to_dict()` of workflow_version
        if self.workflow_version:
            _dict['workflowVersion'] = self.workflow_version.to_dict()
        # override the default output from pydantic by calling `to_dict()` of workflow_run
        if self.workflow_run:
            _dict['workflowRun'] = self.workflow_run.to_dict()
        # override the default output from pydantic by calling `to_dict()` of task
        if self.task:
            _dict['task'] = self.task.to_dict()
        # override the default output from pydantic by calling `to_dict()` of note
        if self.note:
            _dict['note'] = self.note.to_dict()
        # override the default output from pydantic by calling `to_dict()` of favorite_folder
        if self.favorite_folder:
            _dict['favoriteFolder'] = self.favorite_folder.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of FavoriteForResponse 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"),
            "createdAt": obj.get("createdAt"),
            "updatedAt": obj.get("updatedAt"),
            "deletedAt": obj.get("deletedAt"),
            "position": obj.get("position"),
            "viewId": obj.get("viewId"),
            "companyId": obj.get("companyId"),
            "dashboardId": obj.get("dashboardId"),
            "forWorkspaceMemberId": obj.get("forWorkspaceMemberId"),
            "personId": obj.get("personId"),
            "opportunityId": obj.get("opportunityId"),
            "workflowId": obj.get("workflowId"),
            "workflowVersionId": obj.get("workflowVersionId"),
            "workflowRunId": obj.get("workflowRunId"),
            "taskId": obj.get("taskId"),
            "noteId": obj.get("noteId"),
            "favoriteFolderId": obj.get("favoriteFolderId"),
            "company": CompanyForResponse.from_dict(obj["company"]) if obj.get("company") is not None else None,
            "dashboard": DashboardForResponse.from_dict(obj["dashboard"]) if obj.get("dashboard") is not None else None,
            "forWorkspaceMember": WorkspaceMemberForResponse.from_dict(obj["forWorkspaceMember"]) if obj.get("forWorkspaceMember") is not None else None,
            "person": PersonForResponse.from_dict(obj["person"]) if obj.get("person") is not None else None,
            "opportunity": OpportunityForResponse.from_dict(obj["opportunity"]) if obj.get("opportunity") is not None else None,
            "workflow": WorkflowForResponse.from_dict(obj["workflow"]) if obj.get("workflow") is not None else None,
            "workflowVersion": WorkflowVersionForResponse.from_dict(obj["workflowVersion"]) if obj.get("workflowVersion") is not None else None,
            "workflowRun": WorkflowRunForResponse.from_dict(obj["workflowRun"]) if obj.get("workflowRun") is not None else None,
            "task": TaskForResponse.from_dict(obj["task"]) if obj.get("task") is not None else None,
            "note": NoteForResponse.from_dict(obj["note"]) if obj.get("note") is not None else None,
            "favoriteFolder": FavoriteFolderForResponse.from_dict(obj["favoriteFolder"]) if obj.get("favoriteFolder") is not None else None
        })
        return _obj

from twentycrm_client.models.company_for_response import CompanyForResponse
from twentycrm_client.models.dashboard_for_response import DashboardForResponse
from twentycrm_client.models.favorite_folder_for_response import FavoriteFolderForResponse
from twentycrm_client.models.note_for_response import NoteForResponse
from twentycrm_client.models.opportunity_for_response import OpportunityForResponse
from twentycrm_client.models.person_for_response import PersonForResponse
from twentycrm_client.models.task_for_response import TaskForResponse
from twentycrm_client.models.workflow_for_response import WorkflowForResponse
from twentycrm_client.models.workflow_run_for_response import WorkflowRunForResponse
from twentycrm_client.models.workflow_version_for_response import WorkflowVersionForResponse
from twentycrm_client.models.workspace_member_for_response import WorkspaceMemberForResponse
# TODO: Rewrite to not use raise_errors
FavoriteForResponse.model_rebuild(raise_errors=False)

