# coding: utf-8

"""
    FinancialReports API

     Welcome to the FinancialReports API.  ### Access Levels This API is tiered based on data granularity.  | Level | Name | Description | | :--- | :--- | :--- | | **Level 1** | **Standard Access** | Access to raw PDF/XBRL metadata, company profiles, ISIC classifications, reference data, and **point-in-time audit trails**. | | **Level 2** | **Processed Filings** | Access to converted content (Markdown/JSON) and full-text search capabilities. | | **Level 3** | **RAG / Agent** | Access to specific extracted financial line items (Revenue, EBITDA, etc.) mapped to standard taxonomies, and access to the conversational RAG agent. |  ### Rate Limiting To ensure stability, this API uses a dual-layer rate limit: 1.  **Burst Limit:** A short-term speed limit (e.g., 5 requests/second) to prevent system overload. 2.  **Quota Limit:** A monthly allowance of total requests based on your subscription plan.  Check the response headers `X-RateLimit-Burst-Limit` and `X-RateLimit-Monthly-Remaining` for your current status.  ### Authentication All API requests must be authenticated via the **X-API-Key** header. 

    The version of the OpenAPI document: 1.1.1
    Contact: api@financialreports.eu
    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 date, datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from financial_reports_generated_client.models.designated_sponsor import DesignatedSponsor
from financial_reports_generated_client.models.entity_legal_form import EntityLegalForm
from financial_reports_generated_client.models.isic_class import ISICClass
from financial_reports_generated_client.models.isic_division import ISICDivision
from financial_reports_generated_client.models.isic_group import ISICGroup
from financial_reports_generated_client.models.isic_section import ISICSection
from financial_reports_generated_client.models.jurisdiction import Jurisdiction
from financial_reports_generated_client.models.listed_stock_exchange import ListedStockExchange
from financial_reports_generated_client.models.stock_index import StockIndex
from typing import Optional, Set
from typing_extensions import Self
from pydantic_core import to_jsonable_python

class Company(BaseModel):
    """
    Company
    """ # noqa: E501
    id: StrictInt = Field(description="Unique identifier for the company.")
    name: StrictStr = Field(description="Company name.")
    tagline: StrictStr = Field(description="A short, one-liner describing the company's value proposition.")
    description: StrictStr = Field(description="A detailed description or 'About Us' text for the company.")
    description_last_updated: Optional[datetime] = Field(description="Timestamp of the last update to the company's description.")
    isins: List[StrictStr] = Field(description="List of International Securities Identification Numbers (ISINs) associated with the company.")
    lei: StrictStr = Field(description="Legal Entity Identifier (ISO 17442).")
    country_code: StrictStr = Field(description="ISO 3166-1 alpha-2 country code of the company's primary registration or headquarters.")
    address: StrictStr = Field(description="The company's primary street address.")
    city: StrictStr = Field(description="The city where the company's headquarters is located.")
    zip_code: StrictStr = Field(description="The postal or ZIP code for the company's address.")
    sector: Optional[ISICSection]
    industry_group: Optional[ISICDivision]
    industry: Optional[ISICGroup]
    sub_industry: Optional[ISICClass]
    ir_link: Optional[StrictStr] = Field(description="Link to the company's Investor Relations page.")
    homepage_link: Optional[StrictStr] = Field(description="Link to the company's main homepage.")
    logo: Optional[StrictStr] = Field(description="URL of the company's logo file.")
    date_public: Optional[date] = Field(description="Date the company first became public.")
    date_ipo: Optional[date] = Field(description="Date of the company's Initial Public Offering.")
    main_stock_exchange: Optional[StrictStr] = Field(description="Primary stock exchange where the company is listed.")
    is_listed: Optional[StrictBool] = Field(description="Indicates if the company is currently publicly listed.")
    social_facebook: Optional[StrictStr] = Field(description="Facebook profile/page identifier.")
    social_instagram: Optional[StrictStr] = Field(description="Instagram profile identifier.")
    social_twitter: Optional[StrictStr] = Field(description="Twitter handle (without @).")
    social_linkedin: Optional[StrictStr] = Field(description="LinkedIn company page identifier/URL path.")
    social_youtube: Optional[StrictStr] = Field(description="YouTube channel identifier.")
    social_tiktok: Optional[StrictStr] = Field(description="TikTok profile identifier.")
    social_pinterest: Optional[StrictStr] = Field(description="Pinterest profile identifier.")
    social_xing: Optional[StrictStr] = Field(description="Xing company profile identifier.")
    social_glassdoor: Optional[StrictStr] = Field(description="Glassdoor company identifier.")
    year_founded: Optional[date] = Field(description="Date the company was founded.")
    corporate_video_id: Optional[StrictStr] = Field(description="Identifier for a corporate video (e.g., YouTube ID).")
    served_area: Optional[StrictStr] = Field(description="Geographical area served by the company.")
    headcount: Optional[StrictInt] = Field(description="Approximate number of employees.")
    contact_email: Optional[StrictStr] = Field(description="General contact email address.")
    ticker: Optional[StrictStr] = Field(description="Primary stock ticker symbol.")
    local_company_id: StrictStr = Field(description="Local registration or jurisdiction-specific ID (e.g., HRB 24902, CIK 123456).")
    shares_outstanding: Optional[StrictInt] = Field(description="The total number of a corporation's stock shares that have been authorized and issued.")
    designated_sponsor: List[DesignatedSponsor] = Field(description="Financial institutions that act as market makers for the company's stock.")
    listed_stock_exchange: List[ListedStockExchange] = Field(description="A list of stock exchanges where the company is listed.")
    stock_index: List[StockIndex] = Field(description="A list of stock indices the company is a component of.")
    legal_status: StrictStr = Field(description="The operational and legal registration status sourced from GLEIF (e.g., ACTIVE, INACTIVE).")
    legal_form: Optional[EntityLegalForm]
    jurisdiction: Optional[Jurisdiction]
    legal_address: StrictStr = Field(description="The official registered legal address of the company sourced from GLEIF.")
    legal_city: StrictStr = Field(description="The city of the registered legal address sourced from GLEIF.")
    legal_zip_code: StrictStr = Field(description="The postal code of the registered legal address sourced from GLEIF.")
    __properties: ClassVar[List[str]] = ["id", "name", "tagline", "description", "description_last_updated", "isins", "lei", "country_code", "address", "city", "zip_code", "sector", "industry_group", "industry", "sub_industry", "ir_link", "homepage_link", "logo", "date_public", "date_ipo", "main_stock_exchange", "is_listed", "social_facebook", "social_instagram", "social_twitter", "social_linkedin", "social_youtube", "social_tiktok", "social_pinterest", "social_xing", "social_glassdoor", "year_founded", "corporate_video_id", "served_area", "headcount", "contact_email", "ticker", "local_company_id", "shares_outstanding", "designated_sponsor", "listed_stock_exchange", "stock_index", "legal_status", "legal_form", "jurisdiction", "legal_address", "legal_city", "legal_zip_code"]

    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 Company 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.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        """
        excluded_fields: Set[str] = set([
            "id",
            "name",
            "tagline",
            "description",
            "description_last_updated",
            "isins",
            "lei",
            "country_code",
            "address",
            "city",
            "zip_code",
            "sector",
            "industry_group",
            "industry",
            "sub_industry",
            "ir_link",
            "homepage_link",
            "logo",
            "date_public",
            "date_ipo",
            "main_stock_exchange",
            "is_listed",
            "social_facebook",
            "social_instagram",
            "social_twitter",
            "social_linkedin",
            "social_youtube",
            "social_tiktok",
            "social_pinterest",
            "social_xing",
            "social_glassdoor",
            "year_founded",
            "corporate_video_id",
            "served_area",
            "headcount",
            "contact_email",
            "ticker",
            "local_company_id",
            "shares_outstanding",
            "designated_sponsor",
            "listed_stock_exchange",
            "stock_index",
            "legal_status",
            "legal_form",
            "jurisdiction",
            "legal_address",
            "legal_city",
            "legal_zip_code",
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of sector
        if self.sector:
            _dict['sector'] = self.sector.to_dict()
        # override the default output from pydantic by calling `to_dict()` of industry_group
        if self.industry_group:
            _dict['industry_group'] = self.industry_group.to_dict()
        # override the default output from pydantic by calling `to_dict()` of industry
        if self.industry:
            _dict['industry'] = self.industry.to_dict()
        # override the default output from pydantic by calling `to_dict()` of sub_industry
        if self.sub_industry:
            _dict['sub_industry'] = self.sub_industry.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in designated_sponsor (list)
        _items = []
        if self.designated_sponsor:
            for _item_designated_sponsor in self.designated_sponsor:
                if _item_designated_sponsor:
                    _items.append(_item_designated_sponsor.to_dict())
            _dict['designated_sponsor'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in listed_stock_exchange (list)
        _items = []
        if self.listed_stock_exchange:
            for _item_listed_stock_exchange in self.listed_stock_exchange:
                if _item_listed_stock_exchange:
                    _items.append(_item_listed_stock_exchange.to_dict())
            _dict['listed_stock_exchange'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in stock_index (list)
        _items = []
        if self.stock_index:
            for _item_stock_index in self.stock_index:
                if _item_stock_index:
                    _items.append(_item_stock_index.to_dict())
            _dict['stock_index'] = _items
        # override the default output from pydantic by calling `to_dict()` of legal_form
        if self.legal_form:
            _dict['legal_form'] = self.legal_form.to_dict()
        # override the default output from pydantic by calling `to_dict()` of jurisdiction
        if self.jurisdiction:
            _dict['jurisdiction'] = self.jurisdiction.to_dict()
        # set to None if description_last_updated (nullable) is None
        # and model_fields_set contains the field
        if self.description_last_updated is None and "description_last_updated" in self.model_fields_set:
            _dict['description_last_updated'] = None

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of Company 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"),
            "name": obj.get("name"),
            "tagline": obj.get("tagline"),
            "description": obj.get("description"),
            "description_last_updated": obj.get("description_last_updated"),
            "isins": obj.get("isins"),
            "lei": obj.get("lei"),
            "country_code": obj.get("country_code"),
            "address": obj.get("address"),
            "city": obj.get("city"),
            "zip_code": obj.get("zip_code"),
            "sector": ISICSection.from_dict(obj["sector"]) if obj.get("sector") is not None else None,
            "industry_group": ISICDivision.from_dict(obj["industry_group"]) if obj.get("industry_group") is not None else None,
            "industry": ISICGroup.from_dict(obj["industry"]) if obj.get("industry") is not None else None,
            "sub_industry": ISICClass.from_dict(obj["sub_industry"]) if obj.get("sub_industry") is not None else None,
            "ir_link": obj.get("ir_link"),
            "homepage_link": obj.get("homepage_link"),
            "logo": obj.get("logo"),
            "date_public": obj.get("date_public"),
            "date_ipo": obj.get("date_ipo"),
            "main_stock_exchange": obj.get("main_stock_exchange"),
            "is_listed": obj.get("is_listed"),
            "social_facebook": obj.get("social_facebook"),
            "social_instagram": obj.get("social_instagram"),
            "social_twitter": obj.get("social_twitter"),
            "social_linkedin": obj.get("social_linkedin"),
            "social_youtube": obj.get("social_youtube"),
            "social_tiktok": obj.get("social_tiktok"),
            "social_pinterest": obj.get("social_pinterest"),
            "social_xing": obj.get("social_xing"),
            "social_glassdoor": obj.get("social_glassdoor"),
            "year_founded": obj.get("year_founded"),
            "corporate_video_id": obj.get("corporate_video_id"),
            "served_area": obj.get("served_area"),
            "headcount": obj.get("headcount"),
            "contact_email": obj.get("contact_email"),
            "ticker": obj.get("ticker"),
            "local_company_id": obj.get("local_company_id"),
            "shares_outstanding": obj.get("shares_outstanding"),
            "designated_sponsor": [DesignatedSponsor.from_dict(_item) for _item in obj["designated_sponsor"]] if obj.get("designated_sponsor") is not None else None,
            "listed_stock_exchange": [ListedStockExchange.from_dict(_item) for _item in obj["listed_stock_exchange"]] if obj.get("listed_stock_exchange") is not None else None,
            "stock_index": [StockIndex.from_dict(_item) for _item in obj["stock_index"]] if obj.get("stock_index") is not None else None,
            "legal_status": obj.get("legal_status"),
            "legal_form": EntityLegalForm.from_dict(obj["legal_form"]) if obj.get("legal_form") is not None else None,
            "jurisdiction": Jurisdiction.from_dict(obj["jurisdiction"]) if obj.get("jurisdiction") is not None else None,
            "legal_address": obj.get("legal_address"),
            "legal_city": obj.get("legal_city"),
            "legal_zip_code": obj.get("legal_zip_code")
        })
        return _obj


