"""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 AccountingEmployeesFilterStatus(str, Enum, metaclass=utils.OpenEnumMeta):
    ACTIVE = "active"
    INACTIVE = "inactive"
    TERMINATED = "terminated"


class AccountingEmployeesFilterTypedDict(TypedDict):
    updated_since: NotRequired[datetime]
    status: NotRequired[AccountingEmployeesFilterStatus]


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

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

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