"""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 DtoCustomerInvoiceSummaryTypedDict(TypedDict):
    currency: NotRequired[str]
    r"""currency is the three-letter ISO currency code for this summary"""
    customer_id: NotRequired[str]
    r"""customer_id is the unique identifier of the customer"""
    overdue_invoice_count: NotRequired[int]
    r"""overdue_invoice_count is the number of overdue invoices for this customer in this currency"""
    total_invoice_count: NotRequired[int]
    r"""total_invoice_count is the total number of invoices for this customer in this currency"""
    total_overdue_amount: NotRequired[str]
    r"""total_overdue_amount is the total amount of overdue invoices in this currency"""
    total_revenue_amount: NotRequired[str]
    r"""total_revenue_amount is the total revenue generated from this customer in this currency"""
    total_unpaid_amount: NotRequired[str]
    r"""total_unpaid_amount is the total amount of unpaid invoices in this currency"""
    unpaid_fixed_charges: NotRequired[str]
    r"""unpaid_fixed_charges is the total amount of unpaid fixed charges in this currency"""
    unpaid_invoice_count: NotRequired[int]
    r"""unpaid_invoice_count is the number of unpaid invoices for this customer in this currency"""
    unpaid_usage_charges: NotRequired[str]
    r"""unpaid_usage_charges is the total amount of unpaid usage-based charges in this currency"""


class DtoCustomerInvoiceSummary(BaseModel):
    currency: Optional[str] = None
    r"""currency is the three-letter ISO currency code for this summary"""

    customer_id: Optional[str] = None
    r"""customer_id is the unique identifier of the customer"""

    overdue_invoice_count: Optional[int] = None
    r"""overdue_invoice_count is the number of overdue invoices for this customer in this currency"""

    total_invoice_count: Optional[int] = None
    r"""total_invoice_count is the total number of invoices for this customer in this currency"""

    total_overdue_amount: Optional[str] = None
    r"""total_overdue_amount is the total amount of overdue invoices in this currency"""

    total_revenue_amount: Optional[str] = None
    r"""total_revenue_amount is the total revenue generated from this customer in this currency"""

    total_unpaid_amount: Optional[str] = None
    r"""total_unpaid_amount is the total amount of unpaid invoices in this currency"""

    unpaid_fixed_charges: Optional[str] = None
    r"""unpaid_fixed_charges is the total amount of unpaid fixed charges in this currency"""

    unpaid_invoice_count: Optional[int] = None
    r"""unpaid_invoice_count is the number of unpaid invoices for this customer in this currency"""

    unpaid_usage_charges: Optional[str] = None
    r"""unpaid_usage_charges is the total amount of unpaid usage-based charges in this currency"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "currency",
                "customer_id",
                "overdue_invoice_count",
                "total_invoice_count",
                "total_overdue_amount",
                "total_revenue_amount",
                "total_unpaid_amount",
                "unpaid_fixed_charges",
                "unpaid_invoice_count",
                "unpaid_usage_charges",
            ]
        )
        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
