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

from __future__ import annotations
from polar_sdk.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
from pydantic import model_serializer
from typing import Union
from typing_extensions import NotRequired, TypeAliasType, TypedDict


MetricsTotalsOrdersTypedDict = TypeAliasType(
    "MetricsTotalsOrdersTypedDict", Union[int, float]
)


MetricsTotalsOrders = TypeAliasType("MetricsTotalsOrders", Union[int, float])


MetricsTotalsRevenueTypedDict = TypeAliasType(
    "MetricsTotalsRevenueTypedDict", Union[int, float]
)


MetricsTotalsRevenue = TypeAliasType("MetricsTotalsRevenue", Union[int, float])


MetricsTotalsNetRevenueTypedDict = TypeAliasType(
    "MetricsTotalsNetRevenueTypedDict", Union[int, float]
)


MetricsTotalsNetRevenue = TypeAliasType("MetricsTotalsNetRevenue", Union[int, float])


MetricsTotalsCumulativeRevenueTypedDict = TypeAliasType(
    "MetricsTotalsCumulativeRevenueTypedDict", Union[int, float]
)


MetricsTotalsCumulativeRevenue = TypeAliasType(
    "MetricsTotalsCumulativeRevenue", Union[int, float]
)


MetricsTotalsNetCumulativeRevenueTypedDict = TypeAliasType(
    "MetricsTotalsNetCumulativeRevenueTypedDict", Union[int, float]
)


MetricsTotalsNetCumulativeRevenue = TypeAliasType(
    "MetricsTotalsNetCumulativeRevenue", Union[int, float]
)


MetricsTotalsCostsTypedDict = TypeAliasType(
    "MetricsTotalsCostsTypedDict", Union[int, float]
)


MetricsTotalsCosts = TypeAliasType("MetricsTotalsCosts", Union[int, float])


MetricsTotalsCumulativeCostsTypedDict = TypeAliasType(
    "MetricsTotalsCumulativeCostsTypedDict", Union[int, float]
)


MetricsTotalsCumulativeCosts = TypeAliasType(
    "MetricsTotalsCumulativeCosts", Union[int, float]
)


MetricsTotalsAverageOrderValueTypedDict = TypeAliasType(
    "MetricsTotalsAverageOrderValueTypedDict", Union[int, float]
)


MetricsTotalsAverageOrderValue = TypeAliasType(
    "MetricsTotalsAverageOrderValue", Union[int, float]
)


MetricsTotalsNetAverageOrderValueTypedDict = TypeAliasType(
    "MetricsTotalsNetAverageOrderValueTypedDict", Union[int, float]
)


MetricsTotalsNetAverageOrderValue = TypeAliasType(
    "MetricsTotalsNetAverageOrderValue", Union[int, float]
)


MetricsTotalsAverageRevenuePerUserTypedDict = TypeAliasType(
    "MetricsTotalsAverageRevenuePerUserTypedDict", Union[int, float]
)


MetricsTotalsAverageRevenuePerUser = TypeAliasType(
    "MetricsTotalsAverageRevenuePerUser", Union[int, float]
)


MetricsTotalsCostPerUserTypedDict = TypeAliasType(
    "MetricsTotalsCostPerUserTypedDict", Union[int, float]
)


MetricsTotalsCostPerUser = TypeAliasType("MetricsTotalsCostPerUser", Union[int, float])


MetricsTotalsActiveUserByEventTypedDict = TypeAliasType(
    "MetricsTotalsActiveUserByEventTypedDict", Union[int, float]
)


MetricsTotalsActiveUserByEvent = TypeAliasType(
    "MetricsTotalsActiveUserByEvent", Union[int, float]
)


MetricsTotalsOneTimeProductsTypedDict = TypeAliasType(
    "MetricsTotalsOneTimeProductsTypedDict", Union[int, float]
)


MetricsTotalsOneTimeProducts = TypeAliasType(
    "MetricsTotalsOneTimeProducts", Union[int, float]
)


MetricsTotalsOneTimeProductsRevenueTypedDict = TypeAliasType(
    "MetricsTotalsOneTimeProductsRevenueTypedDict", Union[int, float]
)


MetricsTotalsOneTimeProductsRevenue = TypeAliasType(
    "MetricsTotalsOneTimeProductsRevenue", Union[int, float]
)


MetricsTotalsOneTimeProductsNetRevenueTypedDict = TypeAliasType(
    "MetricsTotalsOneTimeProductsNetRevenueTypedDict", Union[int, float]
)


MetricsTotalsOneTimeProductsNetRevenue = TypeAliasType(
    "MetricsTotalsOneTimeProductsNetRevenue", Union[int, float]
)


MetricsTotalsNewSubscriptionsTypedDict = TypeAliasType(
    "MetricsTotalsNewSubscriptionsTypedDict", Union[int, float]
)


MetricsTotalsNewSubscriptions = TypeAliasType(
    "MetricsTotalsNewSubscriptions", Union[int, float]
)


MetricsTotalsNewSubscriptionsRevenueTypedDict = TypeAliasType(
    "MetricsTotalsNewSubscriptionsRevenueTypedDict", Union[int, float]
)


MetricsTotalsNewSubscriptionsRevenue = TypeAliasType(
    "MetricsTotalsNewSubscriptionsRevenue", Union[int, float]
)


MetricsTotalsNewSubscriptionsNetRevenueTypedDict = TypeAliasType(
    "MetricsTotalsNewSubscriptionsNetRevenueTypedDict", Union[int, float]
)


MetricsTotalsNewSubscriptionsNetRevenue = TypeAliasType(
    "MetricsTotalsNewSubscriptionsNetRevenue", Union[int, float]
)


MetricsTotalsRenewedSubscriptionsTypedDict = TypeAliasType(
    "MetricsTotalsRenewedSubscriptionsTypedDict", Union[int, float]
)


MetricsTotalsRenewedSubscriptions = TypeAliasType(
    "MetricsTotalsRenewedSubscriptions", Union[int, float]
)


MetricsTotalsRenewedSubscriptionsRevenueTypedDict = TypeAliasType(
    "MetricsTotalsRenewedSubscriptionsRevenueTypedDict", Union[int, float]
)


MetricsTotalsRenewedSubscriptionsRevenue = TypeAliasType(
    "MetricsTotalsRenewedSubscriptionsRevenue", Union[int, float]
)


MetricsTotalsRenewedSubscriptionsNetRevenueTypedDict = TypeAliasType(
    "MetricsTotalsRenewedSubscriptionsNetRevenueTypedDict", Union[int, float]
)


MetricsTotalsRenewedSubscriptionsNetRevenue = TypeAliasType(
    "MetricsTotalsRenewedSubscriptionsNetRevenue", Union[int, float]
)


MetricsTotalsActiveSubscriptionsTypedDict = TypeAliasType(
    "MetricsTotalsActiveSubscriptionsTypedDict", Union[int, float]
)


MetricsTotalsActiveSubscriptions = TypeAliasType(
    "MetricsTotalsActiveSubscriptions", Union[int, float]
)


MetricsTotalsCommittedSubscriptionsTypedDict = TypeAliasType(
    "MetricsTotalsCommittedSubscriptionsTypedDict", Union[int, float]
)


MetricsTotalsCommittedSubscriptions = TypeAliasType(
    "MetricsTotalsCommittedSubscriptions", Union[int, float]
)


MetricsTotalsMonthlyRecurringRevenueTypedDict = TypeAliasType(
    "MetricsTotalsMonthlyRecurringRevenueTypedDict", Union[int, float]
)


MetricsTotalsMonthlyRecurringRevenue = TypeAliasType(
    "MetricsTotalsMonthlyRecurringRevenue", Union[int, float]
)


MetricsTotalsCommittedMonthlyRecurringRevenueTypedDict = TypeAliasType(
    "MetricsTotalsCommittedMonthlyRecurringRevenueTypedDict", Union[int, float]
)


MetricsTotalsCommittedMonthlyRecurringRevenue = TypeAliasType(
    "MetricsTotalsCommittedMonthlyRecurringRevenue", Union[int, float]
)


MetricsTotalsCheckoutsTypedDict = TypeAliasType(
    "MetricsTotalsCheckoutsTypedDict", Union[int, float]
)


MetricsTotalsCheckouts = TypeAliasType("MetricsTotalsCheckouts", Union[int, float])


MetricsTotalsSucceededCheckoutsTypedDict = TypeAliasType(
    "MetricsTotalsSucceededCheckoutsTypedDict", Union[int, float]
)


MetricsTotalsSucceededCheckouts = TypeAliasType(
    "MetricsTotalsSucceededCheckouts", Union[int, float]
)


MetricsTotalsCheckoutsConversionTypedDict = TypeAliasType(
    "MetricsTotalsCheckoutsConversionTypedDict", Union[int, float]
)


MetricsTotalsCheckoutsConversion = TypeAliasType(
    "MetricsTotalsCheckoutsConversion", Union[int, float]
)


MetricsTotalsCanceledSubscriptionsTypedDict = TypeAliasType(
    "MetricsTotalsCanceledSubscriptionsTypedDict", Union[int, float]
)


MetricsTotalsCanceledSubscriptions = TypeAliasType(
    "MetricsTotalsCanceledSubscriptions", Union[int, float]
)


MetricsTotalsCanceledSubscriptionsCustomerServiceTypedDict = TypeAliasType(
    "MetricsTotalsCanceledSubscriptionsCustomerServiceTypedDict", Union[int, float]
)


MetricsTotalsCanceledSubscriptionsCustomerService = TypeAliasType(
    "MetricsTotalsCanceledSubscriptionsCustomerService", Union[int, float]
)


MetricsTotalsCanceledSubscriptionsLowQualityTypedDict = TypeAliasType(
    "MetricsTotalsCanceledSubscriptionsLowQualityTypedDict", Union[int, float]
)


MetricsTotalsCanceledSubscriptionsLowQuality = TypeAliasType(
    "MetricsTotalsCanceledSubscriptionsLowQuality", Union[int, float]
)


MetricsTotalsCanceledSubscriptionsMissingFeaturesTypedDict = TypeAliasType(
    "MetricsTotalsCanceledSubscriptionsMissingFeaturesTypedDict", Union[int, float]
)


MetricsTotalsCanceledSubscriptionsMissingFeatures = TypeAliasType(
    "MetricsTotalsCanceledSubscriptionsMissingFeatures", Union[int, float]
)


MetricsTotalsCanceledSubscriptionsSwitchedServiceTypedDict = TypeAliasType(
    "MetricsTotalsCanceledSubscriptionsSwitchedServiceTypedDict", Union[int, float]
)


MetricsTotalsCanceledSubscriptionsSwitchedService = TypeAliasType(
    "MetricsTotalsCanceledSubscriptionsSwitchedService", Union[int, float]
)


MetricsTotalsCanceledSubscriptionsTooComplexTypedDict = TypeAliasType(
    "MetricsTotalsCanceledSubscriptionsTooComplexTypedDict", Union[int, float]
)


MetricsTotalsCanceledSubscriptionsTooComplex = TypeAliasType(
    "MetricsTotalsCanceledSubscriptionsTooComplex", Union[int, float]
)


MetricsTotalsCanceledSubscriptionsTooExpensiveTypedDict = TypeAliasType(
    "MetricsTotalsCanceledSubscriptionsTooExpensiveTypedDict", Union[int, float]
)


MetricsTotalsCanceledSubscriptionsTooExpensive = TypeAliasType(
    "MetricsTotalsCanceledSubscriptionsTooExpensive", Union[int, float]
)


MetricsTotalsCanceledSubscriptionsUnusedTypedDict = TypeAliasType(
    "MetricsTotalsCanceledSubscriptionsUnusedTypedDict", Union[int, float]
)


MetricsTotalsCanceledSubscriptionsUnused = TypeAliasType(
    "MetricsTotalsCanceledSubscriptionsUnused", Union[int, float]
)


MetricsTotalsCanceledSubscriptionsOtherTypedDict = TypeAliasType(
    "MetricsTotalsCanceledSubscriptionsOtherTypedDict", Union[int, float]
)


MetricsTotalsCanceledSubscriptionsOther = TypeAliasType(
    "MetricsTotalsCanceledSubscriptionsOther", Union[int, float]
)


MetricsTotalsChurnedSubscriptionsTypedDict = TypeAliasType(
    "MetricsTotalsChurnedSubscriptionsTypedDict", Union[int, float]
)


MetricsTotalsChurnedSubscriptions = TypeAliasType(
    "MetricsTotalsChurnedSubscriptions", Union[int, float]
)


MetricsTotalsChurnRateTypedDict = TypeAliasType(
    "MetricsTotalsChurnRateTypedDict", Union[int, float]
)


MetricsTotalsChurnRate = TypeAliasType("MetricsTotalsChurnRate", Union[int, float])


MetricsTotalsLtvTypedDict = TypeAliasType(
    "MetricsTotalsLtvTypedDict", Union[int, float]
)


MetricsTotalsLtv = TypeAliasType("MetricsTotalsLtv", Union[int, float])


MetricsTotalsGrossMarginTypedDict = TypeAliasType(
    "MetricsTotalsGrossMarginTypedDict", Union[int, float]
)


MetricsTotalsGrossMargin = TypeAliasType("MetricsTotalsGrossMargin", Union[int, float])


MetricsTotalsGrossMarginPercentageTypedDict = TypeAliasType(
    "MetricsTotalsGrossMarginPercentageTypedDict", Union[int, float]
)


MetricsTotalsGrossMarginPercentage = TypeAliasType(
    "MetricsTotalsGrossMarginPercentage", Union[int, float]
)


MetricsTotalsCashflowTypedDict = TypeAliasType(
    "MetricsTotalsCashflowTypedDict", Union[int, float]
)


MetricsTotalsCashflow = TypeAliasType("MetricsTotalsCashflow", Union[int, float])


class MetricsTotalsTypedDict(TypedDict):
    orders: NotRequired[Nullable[MetricsTotalsOrdersTypedDict]]
    revenue: NotRequired[Nullable[MetricsTotalsRevenueTypedDict]]
    net_revenue: NotRequired[Nullable[MetricsTotalsNetRevenueTypedDict]]
    cumulative_revenue: NotRequired[Nullable[MetricsTotalsCumulativeRevenueTypedDict]]
    net_cumulative_revenue: NotRequired[
        Nullable[MetricsTotalsNetCumulativeRevenueTypedDict]
    ]
    costs: NotRequired[Nullable[MetricsTotalsCostsTypedDict]]
    cumulative_costs: NotRequired[Nullable[MetricsTotalsCumulativeCostsTypedDict]]
    average_order_value: NotRequired[Nullable[MetricsTotalsAverageOrderValueTypedDict]]
    net_average_order_value: NotRequired[
        Nullable[MetricsTotalsNetAverageOrderValueTypedDict]
    ]
    average_revenue_per_user: NotRequired[
        Nullable[MetricsTotalsAverageRevenuePerUserTypedDict]
    ]
    cost_per_user: NotRequired[Nullable[MetricsTotalsCostPerUserTypedDict]]
    active_user_by_event: NotRequired[Nullable[MetricsTotalsActiveUserByEventTypedDict]]
    one_time_products: NotRequired[Nullable[MetricsTotalsOneTimeProductsTypedDict]]
    one_time_products_revenue: NotRequired[
        Nullable[MetricsTotalsOneTimeProductsRevenueTypedDict]
    ]
    one_time_products_net_revenue: NotRequired[
        Nullable[MetricsTotalsOneTimeProductsNetRevenueTypedDict]
    ]
    new_subscriptions: NotRequired[Nullable[MetricsTotalsNewSubscriptionsTypedDict]]
    new_subscriptions_revenue: NotRequired[
        Nullable[MetricsTotalsNewSubscriptionsRevenueTypedDict]
    ]
    new_subscriptions_net_revenue: NotRequired[
        Nullable[MetricsTotalsNewSubscriptionsNetRevenueTypedDict]
    ]
    renewed_subscriptions: NotRequired[
        Nullable[MetricsTotalsRenewedSubscriptionsTypedDict]
    ]
    renewed_subscriptions_revenue: NotRequired[
        Nullable[MetricsTotalsRenewedSubscriptionsRevenueTypedDict]
    ]
    renewed_subscriptions_net_revenue: NotRequired[
        Nullable[MetricsTotalsRenewedSubscriptionsNetRevenueTypedDict]
    ]
    active_subscriptions: NotRequired[
        Nullable[MetricsTotalsActiveSubscriptionsTypedDict]
    ]
    committed_subscriptions: NotRequired[
        Nullable[MetricsTotalsCommittedSubscriptionsTypedDict]
    ]
    monthly_recurring_revenue: NotRequired[
        Nullable[MetricsTotalsMonthlyRecurringRevenueTypedDict]
    ]
    committed_monthly_recurring_revenue: NotRequired[
        Nullable[MetricsTotalsCommittedMonthlyRecurringRevenueTypedDict]
    ]
    checkouts: NotRequired[Nullable[MetricsTotalsCheckoutsTypedDict]]
    succeeded_checkouts: NotRequired[Nullable[MetricsTotalsSucceededCheckoutsTypedDict]]
    checkouts_conversion: NotRequired[
        Nullable[MetricsTotalsCheckoutsConversionTypedDict]
    ]
    canceled_subscriptions: NotRequired[
        Nullable[MetricsTotalsCanceledSubscriptionsTypedDict]
    ]
    canceled_subscriptions_customer_service: NotRequired[
        Nullable[MetricsTotalsCanceledSubscriptionsCustomerServiceTypedDict]
    ]
    canceled_subscriptions_low_quality: NotRequired[
        Nullable[MetricsTotalsCanceledSubscriptionsLowQualityTypedDict]
    ]
    canceled_subscriptions_missing_features: NotRequired[
        Nullable[MetricsTotalsCanceledSubscriptionsMissingFeaturesTypedDict]
    ]
    canceled_subscriptions_switched_service: NotRequired[
        Nullable[MetricsTotalsCanceledSubscriptionsSwitchedServiceTypedDict]
    ]
    canceled_subscriptions_too_complex: NotRequired[
        Nullable[MetricsTotalsCanceledSubscriptionsTooComplexTypedDict]
    ]
    canceled_subscriptions_too_expensive: NotRequired[
        Nullable[MetricsTotalsCanceledSubscriptionsTooExpensiveTypedDict]
    ]
    canceled_subscriptions_unused: NotRequired[
        Nullable[MetricsTotalsCanceledSubscriptionsUnusedTypedDict]
    ]
    canceled_subscriptions_other: NotRequired[
        Nullable[MetricsTotalsCanceledSubscriptionsOtherTypedDict]
    ]
    churned_subscriptions: NotRequired[
        Nullable[MetricsTotalsChurnedSubscriptionsTypedDict]
    ]
    churn_rate: NotRequired[Nullable[MetricsTotalsChurnRateTypedDict]]
    ltv: NotRequired[Nullable[MetricsTotalsLtvTypedDict]]
    gross_margin: NotRequired[Nullable[MetricsTotalsGrossMarginTypedDict]]
    gross_margin_percentage: NotRequired[
        Nullable[MetricsTotalsGrossMarginPercentageTypedDict]
    ]
    cashflow: NotRequired[Nullable[MetricsTotalsCashflowTypedDict]]


class MetricsTotals(BaseModel):
    orders: OptionalNullable[MetricsTotalsOrders] = UNSET

    revenue: OptionalNullable[MetricsTotalsRevenue] = UNSET

    net_revenue: OptionalNullable[MetricsTotalsNetRevenue] = UNSET

    cumulative_revenue: OptionalNullable[MetricsTotalsCumulativeRevenue] = UNSET

    net_cumulative_revenue: OptionalNullable[MetricsTotalsNetCumulativeRevenue] = UNSET

    costs: OptionalNullable[MetricsTotalsCosts] = UNSET

    cumulative_costs: OptionalNullable[MetricsTotalsCumulativeCosts] = UNSET

    average_order_value: OptionalNullable[MetricsTotalsAverageOrderValue] = UNSET

    net_average_order_value: OptionalNullable[MetricsTotalsNetAverageOrderValue] = UNSET

    average_revenue_per_user: OptionalNullable[MetricsTotalsAverageRevenuePerUser] = (
        UNSET
    )

    cost_per_user: OptionalNullable[MetricsTotalsCostPerUser] = UNSET

    active_user_by_event: OptionalNullable[MetricsTotalsActiveUserByEvent] = UNSET

    one_time_products: OptionalNullable[MetricsTotalsOneTimeProducts] = UNSET

    one_time_products_revenue: OptionalNullable[MetricsTotalsOneTimeProductsRevenue] = (
        UNSET
    )

    one_time_products_net_revenue: OptionalNullable[
        MetricsTotalsOneTimeProductsNetRevenue
    ] = UNSET

    new_subscriptions: OptionalNullable[MetricsTotalsNewSubscriptions] = UNSET

    new_subscriptions_revenue: OptionalNullable[
        MetricsTotalsNewSubscriptionsRevenue
    ] = UNSET

    new_subscriptions_net_revenue: OptionalNullable[
        MetricsTotalsNewSubscriptionsNetRevenue
    ] = UNSET

    renewed_subscriptions: OptionalNullable[MetricsTotalsRenewedSubscriptions] = UNSET

    renewed_subscriptions_revenue: OptionalNullable[
        MetricsTotalsRenewedSubscriptionsRevenue
    ] = UNSET

    renewed_subscriptions_net_revenue: OptionalNullable[
        MetricsTotalsRenewedSubscriptionsNetRevenue
    ] = UNSET

    active_subscriptions: OptionalNullable[MetricsTotalsActiveSubscriptions] = UNSET

    committed_subscriptions: OptionalNullable[MetricsTotalsCommittedSubscriptions] = (
        UNSET
    )

    monthly_recurring_revenue: OptionalNullable[
        MetricsTotalsMonthlyRecurringRevenue
    ] = UNSET

    committed_monthly_recurring_revenue: OptionalNullable[
        MetricsTotalsCommittedMonthlyRecurringRevenue
    ] = UNSET

    checkouts: OptionalNullable[MetricsTotalsCheckouts] = UNSET

    succeeded_checkouts: OptionalNullable[MetricsTotalsSucceededCheckouts] = UNSET

    checkouts_conversion: OptionalNullable[MetricsTotalsCheckoutsConversion] = UNSET

    canceled_subscriptions: OptionalNullable[MetricsTotalsCanceledSubscriptions] = UNSET

    canceled_subscriptions_customer_service: OptionalNullable[
        MetricsTotalsCanceledSubscriptionsCustomerService
    ] = UNSET

    canceled_subscriptions_low_quality: OptionalNullable[
        MetricsTotalsCanceledSubscriptionsLowQuality
    ] = UNSET

    canceled_subscriptions_missing_features: OptionalNullable[
        MetricsTotalsCanceledSubscriptionsMissingFeatures
    ] = UNSET

    canceled_subscriptions_switched_service: OptionalNullable[
        MetricsTotalsCanceledSubscriptionsSwitchedService
    ] = UNSET

    canceled_subscriptions_too_complex: OptionalNullable[
        MetricsTotalsCanceledSubscriptionsTooComplex
    ] = UNSET

    canceled_subscriptions_too_expensive: OptionalNullable[
        MetricsTotalsCanceledSubscriptionsTooExpensive
    ] = UNSET

    canceled_subscriptions_unused: OptionalNullable[
        MetricsTotalsCanceledSubscriptionsUnused
    ] = UNSET

    canceled_subscriptions_other: OptionalNullable[
        MetricsTotalsCanceledSubscriptionsOther
    ] = UNSET

    churned_subscriptions: OptionalNullable[MetricsTotalsChurnedSubscriptions] = UNSET

    churn_rate: OptionalNullable[MetricsTotalsChurnRate] = UNSET

    ltv: OptionalNullable[MetricsTotalsLtv] = UNSET

    gross_margin: OptionalNullable[MetricsTotalsGrossMargin] = UNSET

    gross_margin_percentage: OptionalNullable[MetricsTotalsGrossMarginPercentage] = (
        UNSET
    )

    cashflow: OptionalNullable[MetricsTotalsCashflow] = UNSET

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "orders",
            "revenue",
            "net_revenue",
            "cumulative_revenue",
            "net_cumulative_revenue",
            "costs",
            "cumulative_costs",
            "average_order_value",
            "net_average_order_value",
            "average_revenue_per_user",
            "cost_per_user",
            "active_user_by_event",
            "one_time_products",
            "one_time_products_revenue",
            "one_time_products_net_revenue",
            "new_subscriptions",
            "new_subscriptions_revenue",
            "new_subscriptions_net_revenue",
            "renewed_subscriptions",
            "renewed_subscriptions_revenue",
            "renewed_subscriptions_net_revenue",
            "active_subscriptions",
            "committed_subscriptions",
            "monthly_recurring_revenue",
            "committed_monthly_recurring_revenue",
            "checkouts",
            "succeeded_checkouts",
            "checkouts_conversion",
            "canceled_subscriptions",
            "canceled_subscriptions_customer_service",
            "canceled_subscriptions_low_quality",
            "canceled_subscriptions_missing_features",
            "canceled_subscriptions_switched_service",
            "canceled_subscriptions_too_complex",
            "canceled_subscriptions_too_expensive",
            "canceled_subscriptions_unused",
            "canceled_subscriptions_other",
            "churned_subscriptions",
            "churn_rate",
            "ltv",
            "gross_margin",
            "gross_margin_percentage",
            "cashflow",
        ]
        nullable_fields = [
            "orders",
            "revenue",
            "net_revenue",
            "cumulative_revenue",
            "net_cumulative_revenue",
            "costs",
            "cumulative_costs",
            "average_order_value",
            "net_average_order_value",
            "average_revenue_per_user",
            "cost_per_user",
            "active_user_by_event",
            "one_time_products",
            "one_time_products_revenue",
            "one_time_products_net_revenue",
            "new_subscriptions",
            "new_subscriptions_revenue",
            "new_subscriptions_net_revenue",
            "renewed_subscriptions",
            "renewed_subscriptions_revenue",
            "renewed_subscriptions_net_revenue",
            "active_subscriptions",
            "committed_subscriptions",
            "monthly_recurring_revenue",
            "committed_monthly_recurring_revenue",
            "checkouts",
            "succeeded_checkouts",
            "checkouts_conversion",
            "canceled_subscriptions",
            "canceled_subscriptions_customer_service",
            "canceled_subscriptions_low_quality",
            "canceled_subscriptions_missing_features",
            "canceled_subscriptions_switched_service",
            "canceled_subscriptions_too_complex",
            "canceled_subscriptions_too_expensive",
            "canceled_subscriptions_unused",
            "canceled_subscriptions_other",
            "churned_subscriptions",
            "churn_rate",
            "ltv",
            "gross_margin",
            "gross_margin_percentage",
            "cashflow",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

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

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m
