# 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 SupplierSearchResponse(PaginatedResponse):
    """
    OK

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

    SupplierSearchResponse(
        offset=0,
        limit=1,
        size=QualifiedCount(
            count=4,
            qualifier="eq",
        ),
        next=True,
        data=[
            SupplierOrBuyer(
                id="yNwunHdFInERKig0Thusgg",
                label="ERBE ELEKTROMEDIZIN GMBH",
                degree=6349,
                entity_url="/v1/entity/yNwunHdFInERKig0Thusgg",
                pep=False,
                psa_id="4904853096420",
                psa_count=1,
                sanctioned=False,
                closed=False,
                type="company",
                identifiers=[
                    Identifier(
                        value="52990027L4WYH1AZ2T91",
                        type="lei",
                        label="Lei",
                    ),
                    Identifier(
                        value="26.035.445/0001-09",
                        type="bra_cnpj",
                        label="Bra Cnpj",
                    ),
                ],
                addresses=[
                    "WALDHOERNLESTRASSE 17 72072 TUEBINGEN 0 GERMANY",
                    "72072, , TUEBINGEN, WALDHOERNLESTRASSE 17,",
                ],
                countries=["USA", "SWE", "BEL", "MEX", "ITA", "DEU"],
                relationship_count={
                    "linked_to": 2,
                    "officer_of": 1,
                    "has_officer": 5,
                    "shareholder_of": 3,
                    "has_shareholder": 1,
                    "ships_to": 30,
                    "receives_from": 3,
                },
                trade_count={"sent": 6278, "received": 5},
                source_count={
                    "ee100f9b5dfdae8991ba43f5de6e1854": SourceCountInfo(
                        count=8,
                        label="Panama Imports & Exports (January 2022 - Present)",
                    ),
                    "26a8072830039f470287902c1530ef79": SourceCountInfo(
                        count=6,
                        label="Belgium Crossroads Bank for Enterprises",
                    ),
                },
                risk={
                    "basel_aml": RiskData(
                        value=5.07,
                        metadata={"country": ["ECU"]},
                        level="relevant",
                    ),
                    "exports_bis_high_priority_items_critical_components": RiskData(
                        value=1.0,
                        metadata={"origin_shipment_product": ["854231"]},
                        level="high",
                    ),
                },
                user_attribute_count={},
                user_record_count=0,
                user_related_entities_count=0,
                user_relationship_count={},
                related_entities_count=6349,
                attribute_count={
                    "company_type": 6,
                    "name": 2,
                    "business_purpose": 11,
                    "identifier": 8,
                },
                metadata=SupplierMetadata(
                    latest_shipment_date="2024-07-10",
                    shipments=6,
                    hs_codes=[
                        HsCode(
                            key="854231",
                            doc_count=6,
                            value="Electronic integrated circuits; processors and controllers, whether or not combined with memories, converters, logic circuits, amplifiers, clock and timing circuits, or other circuits",
                            value_simple="Integrated Circuits",
                        )
                    ],
                ),
            )
        ],
    )
    """

    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, SupplierSearchResponse=SupplierSearchResponse)
update_forward_refs(EntityRelationships, SupplierSearchResponse=SupplierSearchResponse)
update_forward_refs(RelationshipData, SupplierSearchResponse=SupplierSearchResponse)
