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

import datetime as dt
import typing

from ...base_types.types.paginated_response import PaginatedResponse
from ...core.datetime_utils import serialize_datetime
from ...core.pydantic_utilities import pydantic_v1
from .supplier_or_buyer import SupplierOrBuyer


class SupplierSearchResponse(PaginatedResponse):
    """
    OK
    ---
    from sayari import (
        HsCode,
        QualifiedCount,
        SourceCountInfo,
        SupplierMetadata,
        SupplierOrBuyer,
        SupplierSearchResponse,
    )

    SupplierSearchResponse(
        offset=0,
        limit=1,
        size=QualifiedCount(
            count=5541,
            qualifier="eq",
        ),
        next=True,
        data=[
            SupplierOrBuyer(
                id="LvKN1AA74GQ289vydvYgtg",
                label="RedbusAvto OU",
                degree=2523,
                entity_url="/v1/entity/LvKN1AA74GQ289vydvYgtg",
                pep=False,
                psa_count=0,
                sanctioned=False,
                closed=False,
                type="company",
                identifiers=[],
                addresses=[],
                countries=[],
                relationship_count={"shipper_of": 2522, "ships_to": 1},
                source_count={
                    "96c06a5a03b61b91324c7e05b3114fb6": SourceCountInfo(
                        count=2522,
                        label="Ukraine Imports & Exports (January 2023 - Present)",
                    )
                },
                risk={},
                user_attribute_count={},
                user_record_count=0,
                user_related_entities_count=0,
                user_relationship_count={},
                related_entities_count=2523,
                attribute_count={"name": 1},
                metadata=SupplierMetadata(
                    latest_shipment_date="2023-10-27",
                    shipments=2522,
                    hs_codes=[
                        HsCode(
                            key="870323",
                            doc_count=1292,
                            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=1288,
                            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=509,
                            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=508,
                            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=472,
                            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]

    def json(self, **kwargs: typing.Any) -> str:
        kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
        return super().json(**kwargs_with_defaults)

    def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
        kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
        return super().dict(**kwargs_with_defaults)

    class Config:
        frozen = True
        smart_union = True
        allow_population_by_field_name = True
        populate_by_name = True
        extra = pydantic_v1.Extra.allow
        json_encoders = {dt.datetime: serialize_datetime}
