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

import datetime as dt
import typing

from ...core.datetime_utils import serialize_datetime
from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
from ...generated_types.types.country import Country
from ...generated_types.types.relationships import Relationships
from .traversal_data import TraversalData


class TraversalResponse(pydantic_v1.BaseModel):
    """
    OK

    Examples
    --------
    from sayari import (
        EntityDetails,
        RelationshipInfo,
        RiskData,
        SourceCountInfo,
        TraversalData,
        TraversalPath,
        TraversalRelationshipData,
        TraversalResponse,
    )

    TraversalResponse(
        min_depth=1,
        max_depth=4,
        relationships=[],
        countries=[],
        types=[],
        name="",
        watchlist=False,
        psa=True,
        offset=0,
        limit=1,
        partial_results=False,
        next=True,
        explored_count=9999999,
        data=[
            TraversalData(
                source="mGq1lpuqKssNWTjIokuPeA",
                target=EntityDetails(
                    id="puXgX-Swu-Z8bCMW2_FSdQ",
                    label="MARIE LEBLANC",
                    degree=1,
                    entity_url="/v1/entity/puXgX-Swu-Z8bCMW2_FSdQ",
                    pep=False,
                    psa_count=0,
                    sanctioned=False,
                    closed=False,
                    trade_count={"sent": 0, "received": 0},
                    type="person",
                    identifiers=[],
                    addresses=[
                        "202 HAMMERSMITH ROAD UNITED KINGDOM",
                        "202 HAMMERSMITH ROAD BRITISH ISLES",
                    ],
                    countries=["USA", "GBR"],
                    relationship_count={"officer_of": 1},
                    source_count={
                        "a447a7b622c4ead6e1caf94983dc2337": SourceCountInfo(
                            count=6,
                            label="USA California Secretary of State",
                        )
                    },
                    risk={
                        "basel_aml": RiskData(
                            value=3.99,
                            metadata={"country": ["GBR"]},
                            level="relevant",
                        ),
                        "cpi_score": RiskData(
                            value=78.0,
                            metadata={"country": ["GBR"]},
                            level="relevant",
                        ),
                    },
                    user_attribute_count={},
                    user_record_count=0,
                    user_related_entities_count=0,
                    user_relationship_count={},
                    related_entities_count=1,
                    attribute_count={"name": 1, "address": 2, "country": 2},
                    reference_id="9139b58de1bdb0157a1a1e54e56df6d3/4781466/1649116800000:0ce01cbfaa586fcfb82164f0e5a010d5",
                ),
                path=[
                    TraversalPath(
                        field="has_officer",
                        entity=EntityDetails(
                            id="puXgX-Swu-Z8bCMW2_FSdQ",
                            label="MARIE LEBLANC",
                            degree=1,
                            entity_url="/v1/entity/puXgX-Swu-Z8bCMW2_FSdQ",
                            pep=False,
                            psa_count=0,
                            sanctioned=False,
                            closed=False,
                            trade_count={"sent": 0, "received": 0},
                            type="person",
                            identifiers=[],
                            addresses=[
                                "202 HAMMERSMITH ROAD UNITED KINGDOM",
                                "202 HAMMERSMITH ROAD BRITISH ISLES",
                            ],
                            countries=["USA", "GBR"],
                            relationship_count={"officer_of": 1},
                            source_count={
                                "a447a7b622c4ead6e1caf94983dc2337": SourceCountInfo(
                                    count=6,
                                    label="USA California Secretary of State",
                                )
                            },
                            risk={
                                "basel_aml": RiskData(
                                    value=3.99,
                                    metadata={"country": ["GBR"]},
                                    level="relevant",
                                ),
                                "cpi_score": RiskData(
                                    value=78.0,
                                    metadata={"country": ["GBR"]},
                                    level="relevant",
                                ),
                            },
                            user_attribute_count={},
                            user_record_count=0,
                            user_related_entities_count=0,
                            user_relationship_count={},
                            related_entities_count=1,
                            attribute_count={"name": 1, "address": 2, "country": 2},
                            reference_id="9139b58de1bdb0157a1a1e54e56df6d3/4781466/1649116800000:0ce01cbfaa586fcfb82164f0e5a010d5",
                        ),
                        relationships={
                            "has_officer": TraversalRelationshipData(
                                values=[
                                    RelationshipInfo(
                                        record="9139b58de1bdb0157a1a1e54e56df6d3/4781466/1649116800000",
                                        acquisition_date="2022-04-05",
                                        attributes={
                                            "position": [
                                                {"value": "Chief Executive Officer"}
                                            ]
                                        },
                                    ),
                                    RelationshipInfo(
                                        record="9139b58de1bdb0157a1a1e54e56df6d3/4781466/1678752000000",
                                        acquisition_date="2023-03-14",
                                        attributes={},
                                    ),
                                    RelationshipInfo(
                                        record="9139b58de1bdb0157a1a1e54e56df6d3/4781466/1685664000000",
                                        acquisition_date="2023-06-02",
                                        attributes={},
                                    ),
                                    RelationshipInfo(
                                        record="9139b58de1bdb0157a1a1e54e56df6d3/4781466/1693872000000",
                                        acquisition_date="2023-09-05",
                                        attributes={},
                                    ),
                                    RelationshipInfo(
                                        record="9139b58de1bdb0157a1a1e54e56df6d3/4781466/1701648000000",
                                        acquisition_date="2023-12-04",
                                        attributes={},
                                    ),
                                    RelationshipInfo(
                                        record="9139b58de1bdb0157a1a1e54e56df6d3/4781466/1709769600000",
                                        acquisition_date="2024-03-07",
                                        attributes={},
                                    ),
                                ],
                                last_observed="2024-03-07",
                            )
                        },
                    )
                ],
            )
        ],
    )
    """

    min_depth: int
    max_depth: int
    relationships: typing.List[Relationships]
    countries: typing.List[Country]
    types: typing.List[str]
    name: str
    watchlist: bool
    psa: bool
    offset: int
    limit: int
    next: bool
    partial_results: bool
    data: typing.List[TraversalData]
    sanctioned: typing.Optional[bool] = None
    pep: typing.Optional[bool] = None
    explored_count: int

    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_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
        kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs}

        return deep_union_pydantic_dicts(
            super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none)
        )

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