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

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2
from ..core.unchecked_base_model import UncheckedBaseModel
from .billing_period import BillingPeriod
from .character_refresh_period import CharacterRefreshPeriod
from .currency import Currency
from .invoice_response import InvoiceResponse
from .price import Price
from .subscription_max_credit_limit_extension import SubscriptionMaxCreditLimitExtension
from .subscription_pending_change import SubscriptionPendingChange
from .subscription_status_type import SubscriptionStatusType


class Subscription(UncheckedBaseModel):
    tier: str = pydantic.Field()
    """
    The tier of the user's subscription.
    """

    character_count: int = pydantic.Field()
    """
    The number of characters used by the user.
    """

    character_limit: int = pydantic.Field()
    """
    The maximum number of characters allowed in the current billing period.
    """

    max_character_limit_extension: typing.Optional[int] = pydantic.Field(default=None)
    """
    Deprecated: use `max_credit_limit_extension`. Maximum number of characters that the character limit can be exceeded by. Managed by the workspace admin.
    """

    max_credit_limit_extension: SubscriptionMaxCreditLimitExtension = pydantic.Field()
    """
    Maximum number of credits that the credit limit can be exceeded by. Managed by the workspace admin. `"unlimited"` means no cap, `0` means usage-based billing is disabled.
    """

    can_extend_character_limit: bool = pydantic.Field()
    """
    Whether the workspace is entitled to enter overages (usage-based billing).
    """

    allowed_to_extend_character_limit: bool = pydantic.Field()
    """
    Deprecated: use `max_credit_limit_extension != 0`. Whether the user is allowed to extend their character limit.
    """

    next_character_count_reset_unix: typing.Optional[int] = pydantic.Field(default=None)
    """
    The Unix timestamp of the next character count reset.
    """

    voice_slots_used: int = pydantic.Field()
    """
    The number of voice slots used by the user.
    """

    professional_voice_slots_used: int = pydantic.Field()
    """
    The number of professional voice slots used. For consolidated billing this is the group-wide count across all workspaces in the group; see professional_voice_slots_used_in_workspace for the current workspace only.
    """

    professional_voice_slots_used_in_workspace: int = pydantic.Field()
    """
    The number of professional voice slots used in the current workspace. For consolidated billing, professional_voice_slots_used counts across all workspaces in the group, while this counts only the current workspace.
    """

    voice_limit: int = pydantic.Field()
    """
    The maximum number of voice slots allowed for the user.
    """

    max_voice_add_edits: typing.Optional[int] = pydantic.Field(default=None)
    """
    The maximum number of voice add/edits allowed for the user.
    """

    voice_add_edit_counter: int = pydantic.Field()
    """
    The number of voice add/edits used by the user.
    """

    professional_voice_limit: int = pydantic.Field()
    """
    The maximum number of professional voices allowed for the user.
    """

    can_extend_voice_limit: bool = pydantic.Field()
    """
    Whether the user can extend their voice limit.
    """

    can_use_instant_voice_cloning: bool = pydantic.Field()
    """
    Whether the user can use instant voice cloning.
    """

    can_use_professional_voice_cloning: bool = pydantic.Field()
    """
    Whether the user can use professional voice cloning.
    """

    currency: typing.Optional[Currency] = pydantic.Field(default=None)
    """
    The currency of the user's subscription.
    """

    current_overage: Price = pydantic.Field()
    """
    The current usage-based overage cost.
    """

    status: SubscriptionStatusType = pydantic.Field()
    """
    The status of the user's subscription.
    """

    billing_period: typing.Optional[BillingPeriod] = pydantic.Field(default=None)
    """
    The billing period of the user's subscription.
    """

    character_refresh_period: typing.Optional[CharacterRefreshPeriod] = pydantic.Field(default=None)
    """
    The character refresh period of the user's subscription.
    """

    next_invoice: typing.Optional[InvoiceResponse] = pydantic.Field(default=None)
    """
    The next invoice for the user.
    """

    open_invoices: typing.List[InvoiceResponse] = pydantic.Field()
    """
    The open invoices for the user.
    """

    has_open_invoices: bool = pydantic.Field()
    """
    Whether the user has open invoices.
    """

    pending_change: typing.Optional[SubscriptionPendingChange] = pydantic.Field(default=None)
    """
    The pending change for the user.
    """

    has_used_starter_coupon_on_account: typing.Optional[bool] = pydantic.Field(default=None)
    """
    True if any workspace owned by this user's auth account has redeemed the starter first-month discount coupon.
    """

    has_used_creator_coupon_on_account: typing.Optional[bool] = pydantic.Field(default=None)
    """
    True if any workspace owned by this user's auth account has redeemed the creator first-month discount coupon.
    """

    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
