# 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.

    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, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from ninjapear.models.customer_company import CustomerCompany
from typing import Optional, Set
from typing_extensions import Self

class CustomerListingResponse(BaseModel):
    """
    CustomerListingResponse
    """ # noqa: E501
    customers: Optional[List[CustomerCompany]] = Field(default=None, description="Companies that are probable customers of the target company")
    investors: Optional[List[CustomerCompany]] = Field(default=None, description="VC firms, PE funds, angel networks that have invested in the target company")
    partner_platforms: Optional[List[CustomerCompany]] = Field(default=None, description="Partners, platforms, or service providers the target company uses")
    next_page: Optional[StrictStr] = Field(default=None, description="Pagination URL for the next page of results")
    __properties: ClassVar[List[str]] = ["customers", "investors", "partner_platforms", "next_page"]

    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 CustomerListingResponse 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 customers (list)
        _items = []
        if self.customers:
            for _item_customers in self.customers:
                if _item_customers:
                    _items.append(_item_customers.to_dict())
            _dict['customers'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in investors (list)
        _items = []
        if self.investors:
            for _item_investors in self.investors:
                if _item_investors:
                    _items.append(_item_investors.to_dict())
            _dict['investors'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in partner_platforms (list)
        _items = []
        if self.partner_platforms:
            for _item_partner_platforms in self.partner_platforms:
                if _item_partner_platforms:
                    _items.append(_item_partner_platforms.to_dict())
            _dict['partner_platforms'] = _items
        # set to None if next_page (nullable) is None
        # and model_fields_set contains the field
        if self.next_page is None and "next_page" in self.model_fields_set:
            _dict['next_page'] = None

        return _dict

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

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

        _obj = cls.model_validate({
            "customers": [CustomerCompany.from_dict(_item) for _item in obj["customers"]] if obj.get("customers") is not None else None,
            "investors": [CustomerCompany.from_dict(_item) for _item in obj["investors"]] if obj.get("investors") is not None else None,
            "partner_platforms": [CustomerCompany.from_dict(_item) for _item in obj["partner_platforms"]] if obj.get("partner_platforms") is not None else None,
            "next_page": obj.get("next_page")
        })
        return _obj


