"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""

from __future__ import annotations
import dataclasses
import dateutil.parser
from ..shared import amountdiscount as shared_amountdiscount
from ..shared import bpsprice as shared_bpsprice
from ..shared import bulkbpsprice as shared_bulkbpsprice
from ..shared import bulkprice as shared_bulkprice
from ..shared import fivetranexampleprice as shared_fivetranexampleprice
from ..shared import matrixprice as shared_matrixprice
from ..shared import maximum as shared_maximum
from ..shared import minimum as shared_minimum
from ..shared import packageprice as shared_packageprice
from ..shared import packagewithallocationprice as shared_packagewithallocationprice
from ..shared import percentagediscount as shared_percentagediscount
from ..shared import planminified as shared_planminified
from ..shared import planphase as shared_planphase
from ..shared import product as shared_product
from ..shared import testratingfunctionprice as shared_testratingfunctionprice
from ..shared import thresholdtotalamountprice as shared_thresholdtotalamountprice
from ..shared import tieredbpsprice as shared_tieredbpsprice
from ..shared import tieredpackageprice as shared_tieredpackageprice
from ..shared import tieredprice as shared_tieredprice
from ..shared import tieredwithminimumprice as shared_tieredwithminimumprice
from ..shared import trialconfig as shared_trialconfig
from ..shared import trialdiscount as shared_trialdiscount
from ..shared import unitprice as shared_unitprice
from ..shared import usagediscount as shared_usagediscount
from dataclasses_json import Undefined, dataclass_json
from datetime import datetime
from enum import Enum
from orb import utils
from typing import Optional, Union



@dataclasses.dataclass
class PlanDiscount:
    pass



@dataclasses.dataclass
class PlanMetadata:
    pass

class PlanStatus(str, Enum):
    ACTIVE = 'active'
    ARCHIVED = 'archived'
    DRAFT = 'draft'


@dataclass_json(undefined=Undefined.EXCLUDE)

@dataclasses.dataclass
class Plan:
    r"""The [Plan](../guides/core-concepts.mdx#plan-and-price) resource represents a plan that can be subscribed to by a
    customer. Plans define the billing behavior of the subscription. You can see more about how to configure prices
    in the [Price resource](/reference/price).
    """
    base_plan: Optional[shared_planminified.PlanMinified] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('base_plan') }})
    base_plan_id: Optional[str] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('base_plan_id') }})
    r"""The parent plan id if the given plan was created by overriding one or more of the parent's prices"""
    created_at: datetime = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('created_at'), 'encoder': utils.datetimeisoformat(False), 'decoder': dateutil.parser.isoparse }})
    currency: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('currency') }})
    r"""An ISO 4217 currency string or custom pricing unit (`credits`) for this plan's prices."""
    default_invoice_memo: Optional[str] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('default_invoice_memo') }})
    r"""The default memo text on the invoices corresponding to subscriptions on this plan. Note that each subscription may configure its own memo."""
    description: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('description') }})
    discount: Optional[Union[shared_percentagediscount.PercentageDiscount, shared_trialdiscount.TrialDiscount, shared_usagediscount.UsageDiscount, shared_amountdiscount.AmountDiscount]] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('discount') }})
    external_plan_id: Optional[str] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('external_plan_id') }})
    r"""An optional user-defined ID for this plan resource, used throughout the system as an alias for this Plan. Use this field to identify a plan by an existing identifier in your system."""
    id: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('id') }})
    invoicing_currency: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('invoicing_currency') }})
    r"""An ISO 4217 currency string for which this plan is billed in. Matches `currency` unless `currency` is a custom pricing unit."""
    maximum: Optional[shared_maximum.Maximum] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('maximum') }})
    maximum_amount: Optional[str] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('maximum_amount') }})
    metadata: PlanMetadata = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('metadata') }})
    minimum: Optional[shared_minimum.Minimum] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('minimum') }})
    minimum_amount: Optional[str] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('minimum_amount') }})
    name: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('name') }})
    net_terms: Optional[int] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('net_terms') }})
    r"""Determines the difference between the invoice issue date and the due date. A value of \\"0\\" here signifies that invoices are due on issue, whereas a value of \\"30\\" means that the customer has a month to pay the invoice before its overdue. Note that individual subscriptions or invoices may set a different net terms configuration."""
    plan_phases: Optional[list[shared_planphase.PlanPhase]] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('plan_phases') }})
    prices: list[Union[shared_unitprice.UnitPrice, shared_packageprice.PackagePrice, shared_matrixprice.MatrixPrice, shared_tieredprice.TieredPrice, shared_tieredbpsprice.TieredBpsPrice, shared_bpsprice.BpsPrice, shared_bulkbpsprice.BulkBpsPrice, shared_bulkprice.BulkPrice, shared_testratingfunctionprice.TestRatingFunctionPrice, shared_fivetranexampleprice.FivetranExamplePrice, shared_thresholdtotalamountprice.ThresholdTotalAmountPrice, shared_tieredpackageprice.TieredPackagePrice, shared_tieredwithminimumprice.TieredWithMinimumPrice, shared_packagewithallocationprice.PackageWithAllocationPrice]] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('prices') }})
    r"""Prices for this plan. If the plan has phases, this includes prices across all phases of the plan."""
    product: shared_product.Product = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('product') }})
    status: PlanStatus = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('status') }})
    trial_config: shared_trialconfig.TrialConfig = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('trial_config') }})
    

