# 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 .shipment import Shipment


class ShipmentSearchResponse(PaginatedResponse):
    """
    OK
    ---
    from sayari import (
        DataSource,
        QualifiedCount,
        Shipment,
        ShipmentAddress,
        ShipmentIdentifier,
        ShipmentSearchResponse,
        SourceOrDestinationEntity,
        Weight,
    )

    ShipmentSearchResponse(
        offset=0,
        limit=1,
        size=QualifiedCount(
            count=10000,
            qualifier="gte",
        ),
        next=True,
        data=[
            Shipment(
                id="KIB4wNCMtzLhG-onltADgQ",
                type="shipment",
                buyer=[
                    SourceOrDestinationEntity(
                        id="M_vGQfA6PWYdNkj5a_XMNQ",
                        names=["HEMINGWAY RUM COMPANY LLC"],
                        risks={"basel_aml": 4.63, "cpi_score": 67},
                        countries=["USA"],
                        business_purpose=[],
                    )
                ],
                supplier=[
                    SourceOrDestinationEntity(
                        id="9NQnfZhEFrRnp4YWk5yAVQ",
                        names=["FOURSQUARE RUM DISTILLERY FOURSQUARE"],
                        risks={
                            "eu_high_risk_third": true,
                            "basel_aml": 5.81,
                            "cpi_score": 65,
                        },
                        countries=["BRB"],
                        business_purpose=[],
                    )
                ],
                arrival_date="2022-05-25",
                departure_date="2022-05",
                departure_address=ShipmentAddress(
                    x=-79.4861,
                    city="ALAMANCE",
                    state="NC",
                    y=36.035,
                    value="27201",
                ),
                monetary_value=[],
                weight=[
                    Weight(
                        value=5388.0,
                        unit="kilogram",
                        type="gross_weight",
                    )
                ],
                identifier=[
                    ShipmentIdentifier(
                        value="TSCW15541208",
                        type="bill_of_lading",
                    )
                ],
                sources=[
                    DataSource(
                        id="16a4cc2d0f467fa993b28587d542a25d",
                        label="USA Imports (2021 - Present)",
                    )
                ],
                hs_codes=[],
                product_descriptions=["0000000006FOURSQUARE 5YR OLD RUM"],
                record="16a4cc2d0f467fa993b28587d542a25d/TSCW15541208/1653523200000/0",
            )
        ],
    )
    """

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

    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}
