# 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 typing import Optional, Set
from typing_extensions import Self

class PublicListing(BaseModel):
    """
    Public company financial data. Only present for public companies.
    """ # noqa: E501
    stock_symbol: Optional[StrictStr] = Field(default=None, description="Stock ticker symbol")
    ipo_date: Optional[StrictStr] = Field(default=None, description="IPO date in ISO format")
    isin: Optional[StrictStr] = Field(default=None, description="International Securities Identification Number")
    figi: Optional[StrictStr] = Field(default=None, description="Financial Instrument Global Identifier")
    cusip: Optional[StrictStr] = Field(default=None, description="CUSIP identifier")
    lei: Optional[StrictStr] = Field(default=None, description="Legal Entity Identifier")
    cik: Optional[StrictStr] = Field(default=None, description="SEC Central Index Key")
    sic_code: Optional[StrictStr] = Field(default=None, description="SEC Standard Industrial Classification code")
    revenue_usd: Optional[StrictInt] = Field(default=None, description="Annual revenue in USD")
    revenue_captured_at: Optional[StrictStr] = Field(default=None, description="Date when revenue data was captured (ISO format)")
    ebitda_usd: Optional[StrictInt] = Field(default=None, description="EBITDA in USD")
    ebitda_captured_at: Optional[StrictStr] = Field(default=None, description="Date when EBITDA data was captured (ISO format)")
    __properties: ClassVar[List[str]] = ["stock_symbol", "ipo_date", "isin", "figi", "cusip", "lei", "cik", "sic_code", "revenue_usd", "revenue_captured_at", "ebitda_usd", "ebitda_captured_at"]

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

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

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "stock_symbol": obj.get("stock_symbol"),
            "ipo_date": obj.get("ipo_date"),
            "isin": obj.get("isin"),
            "figi": obj.get("figi"),
            "cusip": obj.get("cusip"),
            "lei": obj.get("lei"),
            "cik": obj.get("cik"),
            "sic_code": obj.get("sic_code"),
            "revenue_usd": obj.get("revenue_usd"),
            "revenue_captured_at": obj.get("revenue_captured_at"),
            "ebitda_usd": obj.get("ebitda_usd"),
            "ebitda_captured_at": obj.get("ebitda_captured_at")
        })
        return _obj


