|
1 | 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
2 | 2 |
|
3 |
| -from typing import Dict, List, Optional |
| 3 | +from typing import Dict, List, Union, Optional |
4 | 4 | from datetime import datetime
|
5 |
| -from typing_extensions import Literal |
| 5 | +from typing_extensions import Literal, Annotated, TypeAlias |
6 | 6 |
|
7 | 7 | from .price import Price
|
| 8 | +from .._utils import PropertyInfo |
8 | 9 | from .._models import BaseModel
|
9 | 10 | from .shared.discount import Discount
|
10 | 11 |
|
11 | 12 | __all__ = [
|
12 | 13 | "Plan",
|
| 14 | + "Adjustment", |
| 15 | + "AdjustmentAmountDiscountAdjustment", |
| 16 | + "AdjustmentPercentageDiscountAdjustment", |
| 17 | + "AdjustmentUsageDiscountAdjustment", |
| 18 | + "AdjustmentMinimumAdjustment", |
| 19 | + "AdjustmentMaximumAdjustment", |
13 | 20 | "BasePlan",
|
14 | 21 | "Maximum",
|
15 | 22 | "Minimum",
|
|
21 | 28 | ]
|
22 | 29 |
|
23 | 30 |
|
| 31 | +class AdjustmentAmountDiscountAdjustment(BaseModel): |
| 32 | + id: str |
| 33 | + |
| 34 | + adjustment_type: Literal["amount_discount"] |
| 35 | + |
| 36 | + amount_discount: str |
| 37 | + """ |
| 38 | + The amount by which to discount the prices this adjustment applies to in a given |
| 39 | + billing period. |
| 40 | + """ |
| 41 | + |
| 42 | + applies_to_price_ids: List[str] |
| 43 | + """The price IDs that this adjustment applies to.""" |
| 44 | + |
| 45 | + is_invoice_level: bool |
| 46 | + """ |
| 47 | + True for adjustments that apply to an entire invocice, false for adjustments |
| 48 | + that apply to only one price. |
| 49 | + """ |
| 50 | + |
| 51 | + plan_phase_order: Optional[int] = None |
| 52 | + """The plan phase in which this adjustment is active.""" |
| 53 | + |
| 54 | + reason: Optional[str] = None |
| 55 | + """The reason for the adjustment.""" |
| 56 | + |
| 57 | + |
| 58 | +class AdjustmentPercentageDiscountAdjustment(BaseModel): |
| 59 | + id: str |
| 60 | + |
| 61 | + adjustment_type: Literal["percentage_discount"] |
| 62 | + |
| 63 | + applies_to_price_ids: List[str] |
| 64 | + """The price IDs that this adjustment applies to.""" |
| 65 | + |
| 66 | + is_invoice_level: bool |
| 67 | + """ |
| 68 | + True for adjustments that apply to an entire invocice, false for adjustments |
| 69 | + that apply to only one price. |
| 70 | + """ |
| 71 | + |
| 72 | + percentage_discount: float |
| 73 | + """ |
| 74 | + The percentage (as a value between 0 and 1) by which to discount the price |
| 75 | + intervals this adjustment applies to in a given billing period. |
| 76 | + """ |
| 77 | + |
| 78 | + plan_phase_order: Optional[int] = None |
| 79 | + """The plan phase in which this adjustment is active.""" |
| 80 | + |
| 81 | + reason: Optional[str] = None |
| 82 | + """The reason for the adjustment.""" |
| 83 | + |
| 84 | + |
| 85 | +class AdjustmentUsageDiscountAdjustment(BaseModel): |
| 86 | + id: str |
| 87 | + |
| 88 | + adjustment_type: Literal["usage_discount"] |
| 89 | + |
| 90 | + applies_to_price_ids: List[str] |
| 91 | + """The price IDs that this adjustment applies to.""" |
| 92 | + |
| 93 | + is_invoice_level: bool |
| 94 | + """ |
| 95 | + True for adjustments that apply to an entire invocice, false for adjustments |
| 96 | + that apply to only one price. |
| 97 | + """ |
| 98 | + |
| 99 | + plan_phase_order: Optional[int] = None |
| 100 | + """The plan phase in which this adjustment is active.""" |
| 101 | + |
| 102 | + reason: Optional[str] = None |
| 103 | + """The reason for the adjustment.""" |
| 104 | + |
| 105 | + usage_discount: float |
| 106 | + """ |
| 107 | + The number of usage units by which to discount the price this adjustment applies |
| 108 | + to in a given billing period. |
| 109 | + """ |
| 110 | + |
| 111 | + |
| 112 | +class AdjustmentMinimumAdjustment(BaseModel): |
| 113 | + id: str |
| 114 | + |
| 115 | + adjustment_type: Literal["minimum"] |
| 116 | + |
| 117 | + applies_to_price_ids: List[str] |
| 118 | + """The price IDs that this adjustment applies to.""" |
| 119 | + |
| 120 | + is_invoice_level: bool |
| 121 | + """ |
| 122 | + True for adjustments that apply to an entire invocice, false for adjustments |
| 123 | + that apply to only one price. |
| 124 | + """ |
| 125 | + |
| 126 | + item_id: str |
| 127 | + """The item ID that revenue from this minimum will be attributed to.""" |
| 128 | + |
| 129 | + minimum_amount: str |
| 130 | + """ |
| 131 | + The minimum amount to charge in a given billing period for the prices this |
| 132 | + adjustment applies to. |
| 133 | + """ |
| 134 | + |
| 135 | + plan_phase_order: Optional[int] = None |
| 136 | + """The plan phase in which this adjustment is active.""" |
| 137 | + |
| 138 | + reason: Optional[str] = None |
| 139 | + """The reason for the adjustment.""" |
| 140 | + |
| 141 | + |
| 142 | +class AdjustmentMaximumAdjustment(BaseModel): |
| 143 | + id: str |
| 144 | + |
| 145 | + adjustment_type: Literal["maximum"] |
| 146 | + |
| 147 | + applies_to_price_ids: List[str] |
| 148 | + """The price IDs that this adjustment applies to.""" |
| 149 | + |
| 150 | + is_invoice_level: bool |
| 151 | + """ |
| 152 | + True for adjustments that apply to an entire invocice, false for adjustments |
| 153 | + that apply to only one price. |
| 154 | + """ |
| 155 | + |
| 156 | + maximum_amount: str |
| 157 | + """ |
| 158 | + The maximum amount to charge in a given billing period for the prices this |
| 159 | + adjustment applies to. |
| 160 | + """ |
| 161 | + |
| 162 | + plan_phase_order: Optional[int] = None |
| 163 | + """The plan phase in which this adjustment is active.""" |
| 164 | + |
| 165 | + reason: Optional[str] = None |
| 166 | + """The reason for the adjustment.""" |
| 167 | + |
| 168 | + |
| 169 | +Adjustment: TypeAlias = Annotated[ |
| 170 | + Union[ |
| 171 | + AdjustmentAmountDiscountAdjustment, |
| 172 | + AdjustmentPercentageDiscountAdjustment, |
| 173 | + AdjustmentUsageDiscountAdjustment, |
| 174 | + AdjustmentMinimumAdjustment, |
| 175 | + AdjustmentMaximumAdjustment, |
| 176 | + ], |
| 177 | + PropertyInfo(discriminator="adjustment_type"), |
| 178 | +] |
| 179 | + |
| 180 | + |
24 | 181 | class BasePlan(BaseModel):
|
25 | 182 | id: Optional[str] = None
|
26 | 183 |
|
@@ -124,6 +281,12 @@ class TrialConfig(BaseModel):
|
124 | 281 | class Plan(BaseModel):
|
125 | 282 | id: str
|
126 | 283 |
|
| 284 | + adjustments: List[Adjustment] |
| 285 | + """Adjustments for this plan. |
| 286 | +
|
| 287 | + If the plan has phases, this includes adjustments across all phases of the plan. |
| 288 | + """ |
| 289 | + |
127 | 290 | base_plan: Optional[BasePlan] = None
|
128 | 291 |
|
129 | 292 | base_plan_id: Optional[str] = None
|
|
0 commit comments