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

from __future__ import annotations
from .cardacceptancemethods import CardAcceptanceMethods, CardAcceptanceMethodsTypedDict
from .estimatedactivity import EstimatedActivity, EstimatedActivityTypedDict
from .fulfillment import Fulfillment, FulfillmentTypedDict
from .refundpolicy import RefundPolicy
from moovio_sdk.types import BaseModel, UNSET_SENTINEL
import pydantic
from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class CollectFundsCardPaymentsTypedDict(TypedDict):
    card_acceptance_methods: NotRequired[CardAcceptanceMethodsTypedDict]
    r"""Describes the distribution of card transactions by payment method."""
    currently_accepts_cards: NotRequired[bool]
    estimated_activity: NotRequired[EstimatedActivityTypedDict]
    fulfillment: NotRequired[FulfillmentTypedDict]
    refund_policy: NotRequired[RefundPolicy]


class CollectFundsCardPayments(BaseModel):
    card_acceptance_methods: Annotated[
        Optional[CardAcceptanceMethods], pydantic.Field(alias="cardAcceptanceMethods")
    ] = None
    r"""Describes the distribution of card transactions by payment method."""

    currently_accepts_cards: Annotated[
        Optional[bool], pydantic.Field(alias="currentlyAcceptsCards")
    ] = None

    estimated_activity: Annotated[
        Optional[EstimatedActivity], pydantic.Field(alias="estimatedActivity")
    ] = None

    fulfillment: Optional[Fulfillment] = None

    refund_policy: Annotated[
        Optional[RefundPolicy], pydantic.Field(alias="refundPolicy")
    ] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "cardAcceptanceMethods",
                "currentlyAcceptsCards",
                "estimatedActivity",
                "fulfillment",
                "refundPolicy",
            ]
        )
        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


try:
    CollectFundsCardPayments.model_rebuild()
except NameError:
    pass
