# 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.company_status import CompanyStatus
from ...generated_types.types.country import Country
from ...generated_types.types.risk import Risk
from .upstream_tiers import UpstreamTiers


class ProjectEntitiesFilter(pydantic_v1.BaseModel):
    risk: typing.Optional[typing.List[Risk]] = pydantic_v1.Field(default=None)
    """
    Filter by [risk factor](/sayari-library/ontology/risk-factors) ID.
    """

    upstream_risk: typing.Optional[typing.List[Risk]] = pydantic_v1.Field(default=None)
    """
    Filter by upstream (supply chain) [risk factor](/sayari-library/ontology/risk-factors) ID.
    """

    upstream_risk_tiers: typing.Optional[typing.List[UpstreamTiers]] = pydantic_v1.Field(default=None)
    """
    Filter by upstream (supply chain) tiers that has one or more risks
    """

    country: typing.Optional[typing.List[Country]] = pydantic_v1.Field(default=None)
    """
    Filter by [country](/sayari-library/ontology/enumerated-types#country).
    """

    upstream_country: typing.Optional[typing.List[Country]] = pydantic_v1.Field(default=None)
    """
    Filter by upstream (supply chain) [country](/sayari-library/ontology/enumerated-types#country).
    """

    upstream_country_tiers: typing.Optional[typing.List[UpstreamTiers]] = pydantic_v1.Field(default=None)
    """
    Filter by upstream (supply chain) tiers that has one or more countries
    """

    business_purpose: typing.Optional[typing.List[str]] = pydantic_v1.Field(default=None)
    """
    Filter by HS code, HS code description, or business description.
    """

    label_fuzzy: typing.Optional[typing.List[str]] = pydantic_v1.Field(alias="label.fuzzy", default=None)
    """
    Filter by entity label with fuzzy matching.
    """

    city_fuzzy: typing.Optional[typing.List[str]] = pydantic_v1.Field(alias="city.fuzzy", default=None)
    """
    Filter by entity city with fuzzy matching.
    """

    state_fuzzy: typing.Optional[typing.List[str]] = pydantic_v1.Field(alias="state.fuzzy", default=None)
    """
    Filter by entity address state with fuzzy matching.
    """

    identifier_fuzzy: typing.Optional[typing.List[str]] = pydantic_v1.Field(alias="identifier.fuzzy", default=None)
    """
    Filter by entity identifier attributes with fuzzy matching.
    """

    source_exact: typing.Optional[typing.List[str]] = pydantic_v1.Field(alias="source.exact", default=None)
    """
    Filter by entity source ID.
    """

    status_exact: typing.Optional[typing.List[CompanyStatus]] = pydantic_v1.Field(alias="status.exact", default=None)
    """
    Filter by entity [company status](/sayari-library/ontology/enumerated-types#company-status).
    """

    bounds: typing.Optional[str] = pydantic_v1.Field(default=None)
    """
    Filter by a geographical bounding box. The value is a pipe-delimited set of four values representing the top, left, bottom, and right sides of the bounding box, in that order. The pipes should be URL-encoded as `%7C`. The top coordinate must greater than the bottom coordinate, and the left coordinate must be less than the right coordinate. A sample is `55.680357237879136|-71.53607290158526|41.10876347746233|-40.963927098414736`
    """

    custom_field_name: typing.Optional[typing.List[str]] = pydantic_v1.Field(alias="custom_<field name>", default=None)
    """
    <Warning>This property is in beta and is subject to change. It is provided for early access and testing purposes only.</Warning> custom user key/value pairs (key must be prefixed with "custom\_" and value must be "string" type)
    """

    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
        allow_population_by_field_name = True
        populate_by_name = True
        extra = pydantic_v1.Extra.allow
        json_encoders = {dt.datetime: serialize_datetime}
