# coding: utf-8

"""
    NinjaPear API

    NinjaPear is a data platform that seeks to serve as the single source of truth for B2B data, be it to power your data-driven applications or your sales-driven workflow.  As a data client of NinjaPear API, you can: 1. Look up the customers, investors, and partners/platforms of any business globally. 2. (FREE) Retrieve the logo of any company. 3. (FREE) Find out the nature of an email address. 4. (FREE) Check your credit balance. 5. Monitor companies for updates (blog posts, X/Twitter posts, website changes) via RSS feeds. 6. Look up detailed company information (description, industry, executives, financials). 7. Get company funding history and investors. 8. Enrich person/employee professional profiles.

    The version of the OpenAPI document: 1.0.0
    Contact: hello@nubela.co
    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, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from ninjapear.models.education import Education
from ninjapear.models.work_experience import WorkExperience
from typing import Optional, Set
from typing_extensions import Self

class PersonProfileResponse(BaseModel):
    """
    PersonProfileResponse
    """ # noqa: E501
    id: Optional[StrictStr] = Field(default=None, description="Unique person identifier")
    slug: Optional[StrictStr] = Field(default=None, description="Person's slug identifier")
    profile_pic_url: Optional[StrictStr] = Field(default=None, description="Profile picture URL")
    first_name: Optional[StrictStr] = Field(default=None, description="First name")
    middle_name: Optional[StrictStr] = Field(default=None, description="Middle name")
    last_name: Optional[StrictStr] = Field(default=None, description="Last name")
    full_name: Optional[StrictStr] = Field(default=None, description="Full name")
    bio: Optional[StrictStr] = Field(default=None, description="Professional bio/summary")
    follower_count: Optional[StrictInt] = Field(default=None, description="X/Twitter follower count")
    following_count: Optional[StrictInt] = Field(default=None, description="X/Twitter following count")
    country: Optional[StrictStr] = Field(default=None, description="Country")
    city: Optional[StrictStr] = Field(default=None, description="City")
    state: Optional[StrictStr] = Field(default=None, description="State/province")
    x_handle: Optional[StrictStr] = Field(default=None, description="X/Twitter handle")
    x_profile_url: Optional[StrictStr] = Field(default=None, description="X/Twitter profile URL")
    personal_website: Optional[StrictStr] = Field(default=None, description="Personal website URL")
    work_experience: Optional[List[WorkExperience]] = Field(default=None, description="Work experience history")
    education: Optional[List[Education]] = Field(default=None, description="Education history")
    __properties: ClassVar[List[str]] = ["id", "slug", "profile_pic_url", "first_name", "middle_name", "last_name", "full_name", "bio", "follower_count", "following_count", "country", "city", "state", "x_handle", "x_profile_url", "personal_website", "work_experience", "education"]

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of PersonProfileResponse 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"),
            "slug": obj.get("slug"),
            "profile_pic_url": obj.get("profile_pic_url"),
            "first_name": obj.get("first_name"),
            "middle_name": obj.get("middle_name"),
            "last_name": obj.get("last_name"),
            "full_name": obj.get("full_name"),
            "bio": obj.get("bio"),
            "follower_count": obj.get("follower_count"),
            "following_count": obj.get("following_count"),
            "country": obj.get("country"),
            "city": obj.get("city"),
            "state": obj.get("state"),
            "x_handle": obj.get("x_handle"),
            "x_profile_url": obj.get("x_profile_url"),
            "personal_website": obj.get("personal_website"),
            "work_experience": [WorkExperience.from_dict(_item) for _item in obj["work_experience"]] if obj.get("work_experience") is not None else None,
            "education": [Education.from_dict(_item) for _item in obj["education"]] if obj.get("education") is not None else None
        })
        return _obj


