"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from apideck_unify import models, utils
from apideck_unify.types import BaseModel
from apideck_unify.utils import FieldMetadata, validate_open_enum
from datetime import datetime
from enum import Enum
from pydantic import field_serializer
from pydantic.functional_validators import PlainValidator
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class ExpenseReportsFilterStatus(str, Enum, metaclass=utils.OpenEnumMeta):
    DRAFT = "draft"
    SUBMITTED = "submitted"
    APPROVED = "approved"
    REIMBURSED = "reimbursed"
    REJECTED = "rejected"
    REVERSED = "reversed"
    VOIDED = "voided"


class ExpenseReportsFilterTypedDict(TypedDict):
    updated_since: NotRequired[datetime]
    status: NotRequired[ExpenseReportsFilterStatus]
    employee_id: NotRequired[str]
    r"""Filter by employee ID"""


class ExpenseReportsFilter(BaseModel):
    updated_since: Annotated[Optional[datetime], FieldMetadata(query=True)] = None

    status: Annotated[
        Annotated[
            Optional[ExpenseReportsFilterStatus],
            PlainValidator(validate_open_enum(False)),
        ],
        FieldMetadata(query=True),
    ] = None

    employee_id: Annotated[Optional[str], FieldMetadata(query=True)] = None
    r"""Filter by employee ID"""

    @field_serializer("status")
    def serialize_status(self, value):
        if isinstance(value, str):
            try:
                return models.ExpenseReportsFilterStatus(value)
            except ValueError:
                return value
        return value
