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

from __future__ import annotations
from flexprice.types import BaseModel, UNSET_SENTINEL
from flexprice.utils import FieldMetadata, PathParamMetadata, QueryParamMetadata
import pydantic
from pydantic import model_serializer
from typing import Literal, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


GetWalletTransactionsOrder = Literal[
    "asc",
    "desc",
]


GetWalletTransactionsStatus = Literal[
    "published",
    "deleted",
    "archived",
]


GetWalletTransactionsTransactionReason = Literal[
    "INVOICE_PAYMENT",
    "FREE_CREDIT_GRANT",
    "SUBSCRIPTION_CREDIT_GRANT",
    "PURCHASED_CREDIT_INVOICED",
    "PURCHASED_CREDIT_DIRECT",
    "CREDIT_NOTE",
    "CREDIT_EXPIRED",
    "WALLET_TERMINATION",
    "MANUAL_BALANCE_DEBIT",
    "CREDIT_ADJUSTMENT",
    "INVOICE_VOID_REFUND",
]


GetWalletTransactionsTransactionStatus = Literal[
    "pending",
    "completed",
    "failed",
]


Type = Literal[
    "credit",
    "debit",
]


class GetWalletTransactionsRequestTypedDict(TypedDict):
    id_path_parameter: str
    r"""Wallet ID"""
    created_by: NotRequired[str]
    credits_available_gt: NotRequired[float]
    end_time: NotRequired[str]
    expand: NotRequired[str]
    expiry_date_after: NotRequired[str]
    expiry_date_before: NotRequired[str]
    id_query_parameter: NotRequired[str]
    limit: NotRequired[int]
    offset: NotRequired[int]
    order: NotRequired[GetWalletTransactionsOrder]
    priority: NotRequired[int]
    reference_id: NotRequired[str]
    reference_type: NotRequired[str]
    start_time: NotRequired[str]
    status: NotRequired[GetWalletTransactionsStatus]
    transaction_reason: NotRequired[GetWalletTransactionsTransactionReason]
    transaction_status: NotRequired[GetWalletTransactionsTransactionStatus]
    type: NotRequired[Type]


class GetWalletTransactionsRequest(BaseModel):
    id_path_parameter: Annotated[
        str,
        pydantic.Field(alias="id"),
        FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
    ]
    r"""Wallet ID"""

    created_by: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    credits_available_gt: Annotated[
        Optional[float],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    end_time: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    expand: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    expiry_date_after: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    expiry_date_before: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    id_query_parameter: Annotated[
        Optional[str],
        pydantic.Field(alias="id"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    limit: Annotated[
        Optional[int],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    offset: Annotated[
        Optional[int],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    order: Annotated[
        Optional[GetWalletTransactionsOrder],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    priority: Annotated[
        Optional[int],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    reference_id: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    reference_type: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    start_time: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    status: Annotated[
        Optional[GetWalletTransactionsStatus],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    transaction_reason: Annotated[
        Optional[GetWalletTransactionsTransactionReason],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    transaction_status: Annotated[
        Optional[GetWalletTransactionsTransactionStatus],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    type: Annotated[
        Optional[Type],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "created_by",
                "credits_available_gt",
                "end_time",
                "expand",
                "expiry_date_after",
                "expiry_date_before",
                "idQueryParameter",
                "limit",
                "offset",
                "order",
                "priority",
                "reference_id",
                "reference_type",
                "start_time",
                "status",
                "transaction_reason",
                "transaction_status",
                "type",
            ]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k, serialized.get(n))

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m
