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

import typing

import pydantic
import typing_extensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from ..core.serialization import FieldMetadata
from .bill_data import BillData
from .created_at import CreatedAt
from .datetime_nullable import DatetimeNullable
from .dbaname import Dbaname
from .entrypage_id import EntrypageId
from .entrypointfield import Entrypointfield
from .external_paypoint_id import ExternalPaypointId
from .general_events import GeneralEvents
from .last_modified import LastModified
from .legalname import Legalname
from .netamountnullable import Netamountnullable
from .org_parent_name import OrgParentName
from .paypoint_id import PaypointId
from .query_payment_data import QueryPaymentData
from .query_transaction_payor_data import QueryTransactionPayorData
from .source import Source


class SubscriptionQueryRecords(UniversalBaseModel):
    created_at: typing_extensions.Annotated[typing.Optional[CreatedAt], FieldMetadata(alias="CreatedAt")] = (
        pydantic.Field(default=None)
    )
    """
    Timestamp of when the subscription ws created, in UTC.
    """

    customer: typing_extensions.Annotated[
        typing.Optional[QueryTransactionPayorData], FieldMetadata(alias="Customer")
    ] = None
    end_date: typing_extensions.Annotated[typing.Optional[DatetimeNullable], FieldMetadata(alias="EndDate")] = (
        pydantic.Field(default=None)
    )
    """
    The subscription's end date.
    """

    entrypage_id: typing_extensions.Annotated[typing.Optional[EntrypageId], FieldMetadata(alias="EntrypageId")] = None
    external_paypoint_id: typing_extensions.Annotated[
        typing.Optional[ExternalPaypointId], FieldMetadata(alias="ExternalPaypointID")
    ] = None
    fee_amount: typing_extensions.Annotated[typing.Optional[float], FieldMetadata(alias="FeeAmount")] = pydantic.Field(
        default=None
    )
    """
    Fee applied to the subscription.
    """

    frequency: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="Frequency")] = pydantic.Field(
        default=None
    )
    """
    The subscription's frequency.
    """

    id_sub: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="IdSub")] = pydantic.Field(
        default=None
    )
    """
    The subscription's ID.
    """

    invoice_data: typing_extensions.Annotated[typing.Optional[BillData], FieldMetadata(alias="InvoiceData")] = None
    last_run: typing_extensions.Annotated[typing.Optional[DatetimeNullable], FieldMetadata(alias="LastRun")] = (
        pydantic.Field(default=None)
    )
    """
    The last time the subscription was processed.
    """

    last_updated: typing_extensions.Annotated[typing.Optional[LastModified], FieldMetadata(alias="LastUpdated")] = (
        pydantic.Field(default=None)
    )
    """
    The last date and time the subscription was updated.
    """

    left_cycles: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="LeftCycles")] = pydantic.Field(
        default=None
    )
    """
    The number of cycles the subscription has left.
    """

    method: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="Method")] = pydantic.Field(
        default=None
    )
    """
    The subscription's payment method.
    """

    net_amount: typing_extensions.Annotated[typing.Optional[Netamountnullable], FieldMetadata(alias="NetAmount")] = (
        pydantic.Field(default=None)
    )
    """
    The subscription amount, minus any fees.
    """

    next_date: typing_extensions.Annotated[typing.Optional[DatetimeNullable], FieldMetadata(alias="NextDate")] = (
        pydantic.Field(default=None)
    )
    """
    The next date the subscription will be processed.
    """

    parent_org_name: typing_extensions.Annotated[
        typing.Optional[OrgParentName], FieldMetadata(alias="ParentOrgName")
    ] = None
    payment_data: typing_extensions.Annotated[typing.Optional[QueryPaymentData], FieldMetadata(alias="PaymentData")] = (
        None
    )
    paypoint_dbaname: typing_extensions.Annotated[typing.Optional[Dbaname], FieldMetadata(alias="PaypointDbaname")] = (
        pydantic.Field(default=None)
    )
    """
    The paypoint's DBA name.
    """

    paypoint_entryname: typing_extensions.Annotated[
        typing.Optional[Entrypointfield], FieldMetadata(alias="PaypointEntryname")
    ] = pydantic.Field(default=None)
    """
    The paypoint's entryname.
    """

    paypoint_id: typing_extensions.Annotated[typing.Optional[PaypointId], FieldMetadata(alias="PaypointId")] = None
    paypoint_legalname: typing_extensions.Annotated[
        typing.Optional[Legalname], FieldMetadata(alias="PaypointLegalname")
    ] = pydantic.Field(default=None)
    """
    The paypoint's legal name.
    """

    plan_id: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="PlanId")] = pydantic.Field(
        default=None
    )
    """
    Payment plan ID.
    """

    source: typing_extensions.Annotated[typing.Optional[Source], FieldMetadata(alias="Source")] = None
    start_date: typing_extensions.Annotated[typing.Optional[DatetimeNullable], FieldMetadata(alias="StartDate")] = (
        pydantic.Field(default=None)
    )
    """
    The subscription start date.
    """

    sub_events: typing_extensions.Annotated[
        typing.Optional[typing.List[GeneralEvents]], FieldMetadata(alias="SubEvents")
    ] = pydantic.Field(default=None)
    """
    Events associated with the subscription.
    """

    sub_status: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="SubStatus")] = pydantic.Field(
        default=None
    )
    """
    The subscription's status.
    - 0: Paused
    - 1: Active
    """

    total_amount: typing_extensions.Annotated[typing.Optional[float], FieldMetadata(alias="TotalAmount")] = (
        pydantic.Field(default=None)
    )
    """
    The subscription amount, including any fees.
    """

    total_cycles: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="TotalCycles")] = (
        pydantic.Field(default=None)
    )
    """
    The total number of cycles the subscription is set to run.
    """

    until_cancelled: typing_extensions.Annotated[typing.Optional[bool], FieldMetadata(alias="UntilCancelled")] = (
        pydantic.Field(default=None)
    )
    """
    When `true`, the subscription has no explicit end date and will run until canceled.
    """

    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
