# This file was auto-generated by Fern from our API Definition.

from __future__ import annotations
from ...base_types.types.paginated_response import PaginatedResponse
from ...shared_types.types.entity_details import EntityDetails
from ...shared_types.types.entity_relationships import EntityRelationships
from ...shared_types.types.relationship_data import RelationshipData
import typing
from .supplier_or_buyer import SupplierOrBuyer
from ...core.pydantic_utilities import IS_PYDANTIC_V2
import pydantic
from ...core.pydantic_utilities import update_forward_refs


class BuyerSearchResponse(PaginatedResponse):
    """
    OK

    Examples
    --------
    from sayari.base_types import QualifiedCount
    from sayari.shared_types import Identifier, SourceCountInfo
    from sayari.trade import (
        BuyerSearchResponse,
        HsCode,
        SupplierMetadata,
        SupplierOrBuyer,
    )

    BuyerSearchResponse(
        offset=0,
        limit=1,
        size=QualifiedCount(
            count=5974,
            qualifier="eq",
        ),
        next=True,
        data=[
            SupplierOrBuyer(
                id="VRttegVx-TLCsNHKfNe1Cw",
                label='Товариство з обмеженою відповідальністю "ВЕСТ-СПРИНТ"',
                degree=4333,
                entity_url="/v1/entity/VRttegVx-TLCsNHKfNe1Cw",
                pep=False,
                psa_count=0,
                sanctioned=False,
                closed=False,
                translated_label="VOLYN LIMITED LIABILITY COMPANY VOLYN INSTITUTE OF INFORMATION TECHNOLOGIES",
                company_type="АДВОКАТСЬКЕ БЮРО",
                registration_date="Registered 2021-02-02",
                type="company",
                identifiers=[
                    Identifier(
                        value="44102648",
                        type="ukr_edrpou",
                        label="Ukr Edrpou",
                    ),
                    Identifier(
                        value="43994030",
                        type="ukr_edrpou",
                        label="Ukr Edrpou",
                    ),
                    Identifier(
                        value="43913941",
                        type="ukr_edrpou",
                        label="Ukr Edrpou",
                    ),
                    Identifier(
                        value="44154434",
                        type="ukr_edrpou",
                        label="Ukr Edrpou",
                    ),
                    Identifier(
                        value="10019810200000131",
                        type="ukr_reg_num",
                        label="Ukr Reg Num",
                    ),
                ],
                addresses=[
                    ".",
                    "Україна, 43020, Волинська обл., місто Луцьк, вул.Рівненська, будинок 48",
                    "Україна, 43020, Волинська обл., місто Луцьк, вул.Електроапаратна, будинок 17",
                ],
                countries=["UKR"],
                relationship_count={
                    "receiver_of": 4142,
                    "has_beneficial_owner": 73,
                    "has_officer": 65,
                    "has_shareholder": 75,
                    "has_founder": 78,
                    "receives_from": 98,
                    "has_legal_representative": 4,
                },
                trade_count={"sent": 0, "received": 150},
                source_count={
                    "96c06a5a03b61b91324c7e05b3114fb6": SourceCountInfo(
                        count=4142,
                        label="Ukraine Imports & Exports (January 2023 - Present)",
                    ),
                    "d1bce737c158efddbef5048d63aaf124": SourceCountInfo(
                        count=241,
                        label="Ukraine Ministry of Justice Registry of Companies",
                    ),
                },
                risk={},
                user_attribute_count={},
                user_record_count=0,
                user_related_entities_count=0,
                user_relationship_count={},
                related_entities_count=4333,
                attribute_count={
                    "company_type": 6,
                    "name": 77,
                    "business_purpose": 100,
                    "identifier": 70,
                    "additional_information": 56,
                    "country": 2,
                    "contact": 27,
                    "status": 70,
                    "address": 14,
                },
                metadata=SupplierMetadata(
                    latest_shipment_date="2023-10-28",
                    shipments=4142,
                    hs_codes=[
                        HsCode(
                            key="870323",
                            doc_count=1492,
                            value="Vehicles; with only spark-ignition internal combustion reciprocating piston engine, cylinder capacity over 1500 but not over 3000cc",
                            value_simple="Cars & Passenger Vehicles",
                        ),
                        HsCode(
                            key="8703239013",
                            doc_count=1477,
                            value="Vehicles; with only spark-ignition internal combustion reciprocating piston engine, cylinder capacity over 1500 but not over 3000cc",
                            value_simple="Cars & Passenger Vehicles",
                        ),
                        HsCode(
                            key="870332",
                            doc_count=897,
                            value="Vehicles; with only compression-ignition internal combustion piston engine (diesel or semi-diesel), cylinder capacity over 1500 but not over 2500cc",
                            value_simple="Cars & Passenger Vehicles",
                        ),
                        HsCode(
                            key="8703329030",
                            doc_count=830,
                            value="Vehicles; with only compression-ignition internal combustion piston engine (diesel or semi-diesel), cylinder capacity over 1500 but not over 2500cc",
                            value_simple="Cars & Passenger Vehicles",
                        ),
                        HsCode(
                            key="870322",
                            doc_count=551,
                            value="Vehicles; with only spark-ignition internal combustion piston engine, cylinder capacity over 1000 but not over 1500cc",
                            value_simple="Cars & Passenger Vehicles",
                        ),
                    ],
                ),
            )
        ],
    )
    """

    offset: int
    next: bool
    data: typing.List[SupplierOrBuyer]

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow


update_forward_refs(EntityDetails, BuyerSearchResponse=BuyerSearchResponse)
update_forward_refs(EntityRelationships, BuyerSearchResponse=BuyerSearchResponse)
update_forward_refs(RelationshipData, BuyerSearchResponse=BuyerSearchResponse)
