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

from __future__ import annotations
from datetime import datetime
from moovio_sdk.models.components import (
    issuedcardtransaction as components_issuedcardtransaction,
)
from moovio_sdk.types import BaseModel, UNSET_SENTINEL
from moovio_sdk.utils import FieldMetadata, PathParamMetadata, QueryParamMetadata
import pydantic
from pydantic import model_serializer
from typing import Dict, List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class ListIssuedCardTransactionsRequestTypedDict(TypedDict):
    account_id: str
    r"""The Moov business account for which cards have been issued."""
    skip: NotRequired[int]
    count: NotRequired[int]
    issued_card_id: NotRequired[str]
    r"""Optional ID of the issued card to filter results."""
    start_date_time: NotRequired[datetime]
    r"""Optional date-time which inclusively filters all card transactions created after this date-time."""
    end_date_time: NotRequired[datetime]
    r"""Optional date-time which exclusively filters all card transactions created before this date-time."""


class ListIssuedCardTransactionsRequest(BaseModel):
    account_id: Annotated[
        str,
        pydantic.Field(alias="accountID"),
        FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
    ]
    r"""The Moov business account for which cards have been issued."""

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

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

    issued_card_id: Annotated[
        Optional[str],
        pydantic.Field(alias="issuedCardID"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=False)),
    ] = None
    r"""Optional ID of the issued card to filter results."""

    start_date_time: Annotated[
        Optional[datetime],
        pydantic.Field(alias="startDateTime"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=False)),
    ] = None
    r"""Optional date-time which inclusively filters all card transactions created after this date-time."""

    end_date_time: Annotated[
        Optional[datetime],
        pydantic.Field(alias="endDateTime"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=False)),
    ] = None
    r"""Optional date-time which exclusively filters all card transactions created before this date-time."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            ["skip", "count", "issuedCardID", "startDateTime", "endDateTime"]
        )
        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


class ListIssuedCardTransactionsResponseTypedDict(TypedDict):
    headers: Dict[str, List[str]]
    result: List[components_issuedcardtransaction.IssuedCardTransactionTypedDict]


class ListIssuedCardTransactionsResponse(BaseModel):
    headers: Dict[str, List[str]]

    result: List[components_issuedcardtransaction.IssuedCardTransaction]
