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

from __future__ import annotations
from flexprice_py.types import BaseModel, UNSET_SENTINEL
from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict


class DtoProrationDetailsTypedDict(TypedDict):
    charge_amount: NotRequired[str]
    r"""charge_amount is the charge amount for the new subscription"""
    charge_description: NotRequired[str]
    r"""charge_description describes what the charge is for"""
    credit_amount: NotRequired[str]
    r"""credit_amount is the credit amount from the old subscription"""
    credit_description: NotRequired[str]
    r"""credit_description describes what the credit is for"""
    currency: NotRequired[str]
    r"""currency is the currency for all amounts"""
    current_period_end: NotRequired[str]
    r"""current_period_end is the end of the current billing period"""
    current_period_start: NotRequired[str]
    r"""current_period_start is the start of the current billing period"""
    days_remaining: NotRequired[int]
    r"""days_remaining is the number of days remaining in the current period"""
    days_used: NotRequired[int]
    r"""days_used is the number of days used in the current period"""
    net_amount: NotRequired[str]
    r"""net_amount is the net amount (charge - credit)"""
    proration_date: NotRequired[str]
    r"""proration_date is the date used for proration calculations"""


class DtoProrationDetails(BaseModel):
    charge_amount: Optional[str] = None
    r"""charge_amount is the charge amount for the new subscription"""

    charge_description: Optional[str] = None
    r"""charge_description describes what the charge is for"""

    credit_amount: Optional[str] = None
    r"""credit_amount is the credit amount from the old subscription"""

    credit_description: Optional[str] = None
    r"""credit_description describes what the credit is for"""

    currency: Optional[str] = None
    r"""currency is the currency for all amounts"""

    current_period_end: Optional[str] = None
    r"""current_period_end is the end of the current billing period"""

    current_period_start: Optional[str] = None
    r"""current_period_start is the start of the current billing period"""

    days_remaining: Optional[int] = None
    r"""days_remaining is the number of days remaining in the current period"""

    days_used: Optional[int] = None
    r"""days_used is the number of days used in the current period"""

    net_amount: Optional[str] = None
    r"""net_amount is the net amount (charge - credit)"""

    proration_date: Optional[str] = None
    r"""proration_date is the date used for proration calculations"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "charge_amount",
                "charge_description",
                "credit_amount",
                "credit_description",
                "currency",
                "current_period_end",
                "current_period_start",
                "days_remaining",
                "days_used",
                "net_amount",
                "proration_date",
            ]
        )
        serialized = handler(self)
        m = {}

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

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

        return m
