# 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 pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from uuid import UUID
from twentycrm_client.models.attachment_created_by import AttachmentCreatedBy
from twentycrm_client.models.attachment_file_inner import AttachmentFileInner
from twentycrm_client.models.attachment_updated_by import AttachmentUpdatedBy
from twentycrm_client.models.person_emails import PersonEmails
from twentycrm_client.models.person_linkedin_link import PersonLinkedinLink
from twentycrm_client.models.person_name import PersonName
from twentycrm_client.models.person_phones import PersonPhones
from twentycrm_client.models.person_x_link import PersonXLink
from typing import Optional, Set
from typing_extensions import Self
from pydantic_core import to_jsonable_python

class PersonForUpdate(BaseModel):
    """
    A person
    """ # noqa: E501
    name: Optional[PersonName] = None
    emails: Optional[PersonEmails] = None
    linkedin_link: Optional[PersonLinkedinLink] = Field(default=None, alias="linkedinLink")
    x_link: Optional[PersonXLink] = Field(default=None, alias="xLink")
    job_title: Optional[StrictStr] = Field(default=None, description="Contact's job title", alias="jobTitle")
    phones: Optional[PersonPhones] = None
    city: Optional[StrictStr] = Field(default=None, description="Contact's city")
    avatar_url: Optional[StrictStr] = Field(default=None, description="Contact's avatar", alias="avatarUrl")
    avatar_file: Optional[List[AttachmentFileInner]] = Field(default=None, description="Contact's avatar file", alias="avatarFile")
    position: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Person record Position")
    created_by: Optional[AttachmentCreatedBy] = Field(default=None, alias="createdBy")
    updated_by: Optional[AttachmentUpdatedBy] = Field(default=None, alias="updatedBy")
    company_id: Optional[UUID] = Field(default=None, alias="companyId")
    __properties: ClassVar[List[str]] = ["name", "emails", "linkedinLink", "xLink", "jobTitle", "phones", "city", "avatarUrl", "avatarFile", "position", "createdBy", "updatedBy", "companyId"]

    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 PersonForUpdate 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 name
        if self.name:
            _dict['name'] = self.name.to_dict()
        # override the default output from pydantic by calling `to_dict()` of emails
        if self.emails:
            _dict['emails'] = self.emails.to_dict()
        # override the default output from pydantic by calling `to_dict()` of linkedin_link
        if self.linkedin_link:
            _dict['linkedinLink'] = self.linkedin_link.to_dict()
        # override the default output from pydantic by calling `to_dict()` of x_link
        if self.x_link:
            _dict['xLink'] = self.x_link.to_dict()
        # override the default output from pydantic by calling `to_dict()` of phones
        if self.phones:
            _dict['phones'] = self.phones.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in avatar_file (list)
        _items = []
        if self.avatar_file:
            for _item_avatar_file in self.avatar_file:
                if _item_avatar_file:
                    _items.append(_item_avatar_file.to_dict())
            _dict['avatarFile'] = _items
        # override the default output from pydantic by calling `to_dict()` of created_by
        if self.created_by:
            _dict['createdBy'] = self.created_by.to_dict()
        # override the default output from pydantic by calling `to_dict()` of updated_by
        if self.updated_by:
            _dict['updatedBy'] = self.updated_by.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "name": PersonName.from_dict(obj["name"]) if obj.get("name") is not None else None,
            "emails": PersonEmails.from_dict(obj["emails"]) if obj.get("emails") is not None else None,
            "linkedinLink": PersonLinkedinLink.from_dict(obj["linkedinLink"]) if obj.get("linkedinLink") is not None else None,
            "xLink": PersonXLink.from_dict(obj["xLink"]) if obj.get("xLink") is not None else None,
            "jobTitle": obj.get("jobTitle"),
            "phones": PersonPhones.from_dict(obj["phones"]) if obj.get("phones") is not None else None,
            "city": obj.get("city"),
            "avatarUrl": obj.get("avatarUrl"),
            "avatarFile": [AttachmentFileInner.from_dict(_item) for _item in obj["avatarFile"]] if obj.get("avatarFile") is not None else None,
            "position": obj.get("position"),
            "createdBy": AttachmentCreatedBy.from_dict(obj["createdBy"]) if obj.get("createdBy") is not None else None,
            "updatedBy": AttachmentUpdatedBy.from_dict(obj["updatedBy"]) if obj.get("updatedBy") is not None else None,
            "companyId": obj.get("companyId")
        })
        return _obj


