# This file was auto-generated by Fern from our API Definition.

import datetime as dt
import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .billing_product_for_subscription_response_data import BillingProductForSubscriptionResponseData
from .billing_subscription_discount_view import BillingSubscriptionDiscountView
from .invoice_response_data import InvoiceResponseData
from .payment_method_response_data import PaymentMethodResponseData


class BillingSubscriptionView(UniversalBaseModel):
    """
    The updated resource
    """

    cancel_at: typing.Optional[int] = None
    cancel_at_period_end: bool
    company_id: typing.Optional[str] = None
    created_at: dt.datetime
    currency: str
    customer_external_id: str
    default_payment_method_id: typing.Optional[str] = None
    discounts: typing.List[BillingSubscriptionDiscountView]
    expired_at: typing.Optional[dt.datetime] = None
    id: str
    interval: str
    latest_invoice: typing.Optional[InvoiceResponseData] = None
    metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
    payment_method: typing.Optional[PaymentMethodResponseData] = None
    period_end: int
    period_start: int
    products: typing.List[BillingProductForSubscriptionResponseData]
    status: str
    subscription_external_id: str
    total_price: int
    trial_end: typing.Optional[int] = None
    trial_end_setting: typing.Optional[str] = None

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
