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

from ..core.unchecked_base_model import UncheckedBaseModel
import typing
from .search_orders_state_filter import SearchOrdersStateFilter
import pydantic
from .search_orders_date_time_filter import SearchOrdersDateTimeFilter
from .search_orders_fulfillment_filter import SearchOrdersFulfillmentFilter
from .search_orders_source_filter import SearchOrdersSourceFilter
from .search_orders_customer_filter import SearchOrdersCustomerFilter
from ..core.pydantic_utilities import IS_PYDANTIC_V2


class SearchOrdersFilter(UncheckedBaseModel):
    """
    Filtering criteria to use for a `SearchOrders` request. Multiple filters
    are ANDed together.
    """

    state_filter: typing.Optional[SearchOrdersStateFilter] = pydantic.Field(default=None)
    """
    Filter by [OrderState](entity:OrderState).
    """

    date_time_filter: typing.Optional[SearchOrdersDateTimeFilter] = pydantic.Field(default=None)
    """
    Filter for results within a time range.
    
    __Important:__ If you filter for orders by time range, you must set `SearchOrdersSort`
    to sort by the same field.
    [Learn more about filtering orders by time range.](https://developer.squareup.com/docs/orders-api/manage-orders/search-orders#important-note-about-filtering-orders-by-time-range)
    """

    fulfillment_filter: typing.Optional[SearchOrdersFulfillmentFilter] = pydantic.Field(default=None)
    """
    Filter by the fulfillment type or state.
    """

    source_filter: typing.Optional[SearchOrdersSourceFilter] = pydantic.Field(default=None)
    """
    Filter by the source of the order.
    """

    customer_filter: typing.Optional[SearchOrdersCustomerFilter] = pydantic.Field(default=None)
    """
    Filter by customers associated with the order.
    """

    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
