"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
# @generated-id: ecd568a1530e

from __future__ import annotations
from .sales_invoice_discount_type_response import SalesInvoiceDiscountTypeResponse
from mollie import models
from mollie.types import BaseModel
from pydantic import field_serializer
from typing_extensions import TypedDict


class SalesInvoiceDiscountResponseTypedDict(TypedDict):
    type: SalesInvoiceDiscountTypeResponse
    r"""The type of discount."""
    value: str
    r"""A string containing an exact monetary amount in the given currency, or the percentage."""


class SalesInvoiceDiscountResponse(BaseModel):
    type: SalesInvoiceDiscountTypeResponse
    r"""The type of discount."""

    value: str
    r"""A string containing an exact monetary amount in the given currency, or the percentage."""

    @field_serializer("type")
    def serialize_type(self, value):
        if isinstance(value, str):
            try:
                return models.SalesInvoiceDiscountTypeResponse(value)
            except ValueError:
                return value
        return value
