# 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, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from ninjapear.models.address import Address
from ninjapear.models.executive import Executive
from ninjapear.models.public_listing import PublicListing
from typing import Optional, Set
from typing_extensions import Self

class CompanyDetailsResponse(BaseModel):
    """
    CompanyDetailsResponse
    """ # noqa: E501
    websites: Optional[List[StrictStr]] = Field(default=None, description="List of all company website URLs")
    description: Optional[StrictStr] = Field(default=None, description="A brief description of the company")
    industry: Optional[StrictInt] = Field(default=None, description="GICS 8-digit industry code")
    company_type: Optional[StrictStr] = Field(default=None, description="Type of company")
    founded_year: Optional[StrictInt] = Field(default=None, description="Year the company was founded")
    specialties: Optional[List[StrictStr]] = Field(default=None, description="List of company specialties")
    name: Optional[StrictStr] = Field(default=None, description="Company name")
    tagline: Optional[StrictStr] = Field(default=None, description="Company tagline or slogan")
    logo_url: Optional[StrictStr] = Field(default=None, description="URL to the company logo endpoint")
    cover_pic_url: Optional[StrictStr] = Field(default=None, description="URL to the company's cover/banner image")
    facebook_url: Optional[StrictStr] = Field(default=None, description="Facebook profile URL")
    twitter_url: Optional[StrictStr] = Field(default=None, description="Twitter/X profile URL")
    instagram_url: Optional[StrictStr] = Field(default=None, description="Instagram profile URL")
    employee_count: Optional[StrictInt] = Field(default=None, description="Estimated number of employees")
    employee_count_range_min: Optional[StrictInt] = Field(default=None, description="Lower bound of employee count range (only with include_employee_count=true)")
    employee_count_range_max: Optional[StrictInt] = Field(default=None, description="Upper bound of employee count range (only with include_employee_count=true)")
    addresses: Optional[List[Address]] = Field(default=None, description="List of company addresses")
    executives: Optional[List[Executive]] = Field(default=None, description="List of company executives and board members")
    public_listing: Optional[PublicListing] = Field(default=None, description="Public company data. Null for private companies.")
    follower_count: Optional[StrictInt] = Field(default=None, description="Twitter/X follower count (only included when follower_count=include query param is used)")
    following_count: Optional[StrictInt] = Field(default=None, description="Twitter/X following count (only included when follower_count=include query param is used)")
    similar_companies: Optional[StrictStr] = Field(default=None, description="URL to the competitor listing endpoint for this company")
    updates: Optional[StrictStr] = Field(default=None, description="URL to the company updates endpoint for this company")
    funding: Optional[StrictStr] = Field(default=None, description="URL to the company funding endpoint for this company")
    __properties: ClassVar[List[str]] = ["websites", "description", "industry", "company_type", "founded_year", "specialties", "name", "tagline", "logo_url", "cover_pic_url", "facebook_url", "twitter_url", "instagram_url", "employee_count", "employee_count_range_min", "employee_count_range_max", "addresses", "executives", "public_listing", "follower_count", "following_count", "similar_companies", "updates", "funding"]

    @field_validator('company_type')
    def company_type_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['PUBLIC_COMPANY', 'PRIVATELY_HELD', 'GOVERNMENT_AGENCY', 'NON_PROFIT', 'EDUCATIONAL', 'PARTNERSHIP', 'SELF_EMPLOYED', 'SELF_OWNED']):
            raise ValueError("must be one of enum values ('PUBLIC_COMPANY', 'PRIVATELY_HELD', 'GOVERNMENT_AGENCY', 'NON_PROFIT', 'EDUCATIONAL', 'PARTNERSHIP', 'SELF_EMPLOYED', 'SELF_OWNED')")
        return value

    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 CompanyDetailsResponse 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 addresses (list)
        _items = []
        if self.addresses:
            for _item_addresses in self.addresses:
                if _item_addresses:
                    _items.append(_item_addresses.to_dict())
            _dict['addresses'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in executives (list)
        _items = []
        if self.executives:
            for _item_executives in self.executives:
                if _item_executives:
                    _items.append(_item_executives.to_dict())
            _dict['executives'] = _items
        # override the default output from pydantic by calling `to_dict()` of public_listing
        if self.public_listing:
            _dict['public_listing'] = self.public_listing.to_dict()
        # set to None if websites (nullable) is None
        # and model_fields_set contains the field
        if self.websites is None and "websites" in self.model_fields_set:
            _dict['websites'] = None

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        # set to None if public_listing (nullable) is None
        # and model_fields_set contains the field
        if self.public_listing is None and "public_listing" in self.model_fields_set:
            _dict['public_listing'] = 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 similar_companies (nullable) is None
        # and model_fields_set contains the field
        if self.similar_companies is None and "similar_companies" in self.model_fields_set:
            _dict['similar_companies'] = None

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "websites": obj.get("websites"),
            "description": obj.get("description"),
            "industry": obj.get("industry"),
            "company_type": obj.get("company_type"),
            "founded_year": obj.get("founded_year"),
            "specialties": obj.get("specialties"),
            "name": obj.get("name"),
            "tagline": obj.get("tagline"),
            "logo_url": obj.get("logo_url"),
            "cover_pic_url": obj.get("cover_pic_url"),
            "facebook_url": obj.get("facebook_url"),
            "twitter_url": obj.get("twitter_url"),
            "instagram_url": obj.get("instagram_url"),
            "employee_count": obj.get("employee_count"),
            "employee_count_range_min": obj.get("employee_count_range_min"),
            "employee_count_range_max": obj.get("employee_count_range_max"),
            "addresses": [Address.from_dict(_item) for _item in obj["addresses"]] if obj.get("addresses") is not None else None,
            "executives": [Executive.from_dict(_item) for _item in obj["executives"]] if obj.get("executives") is not None else None,
            "public_listing": PublicListing.from_dict(obj["public_listing"]) if obj.get("public_listing") is not None else None,
            "follower_count": obj.get("follower_count"),
            "following_count": obj.get("following_count"),
            "similar_companies": obj.get("similar_companies"),
            "updates": obj.get("updates"),
            "funding": obj.get("funding")
        })
        return _obj


