|
12 | 12 |
|
13 | 13 | __all__ = [
|
14 | 14 | "Subscription",
|
| 15 | + "AdjustmentInterval", |
| 16 | + "AdjustmentIntervalAdjustment", |
| 17 | + "AdjustmentIntervalAdjustmentAmountDiscountAdjustment", |
| 18 | + "AdjustmentIntervalAdjustmentPercentageDiscountAdjustment", |
| 19 | + "AdjustmentIntervalAdjustmentUsageDiscountAdjustment", |
| 20 | + "AdjustmentIntervalAdjustmentMinimumAdjustment", |
| 21 | + "AdjustmentIntervalAdjustmentMaximumAdjustment", |
15 | 22 | "DiscountInterval",
|
16 | 23 | "DiscountIntervalAmountDiscountInterval",
|
17 | 24 | "DiscountIntervalPercentageDiscountInterval",
|
|
26 | 33 | ]
|
27 | 34 |
|
28 | 35 |
|
| 36 | +class AdjustmentIntervalAdjustmentAmountDiscountAdjustment(BaseModel): |
| 37 | + adjustment_type: Literal["amount_discount"] |
| 38 | + |
| 39 | + amount_discount: str |
| 40 | + """ |
| 41 | + The amount by which to discount the prices this adjustment applies to in a given |
| 42 | + billing period. |
| 43 | + """ |
| 44 | + |
| 45 | + applies_to_price_ids: List[str] |
| 46 | + """The price IDs that this adjustment applies to.""" |
| 47 | + |
| 48 | + reason: Optional[str] = None |
| 49 | + """The reason for the adjustment.""" |
| 50 | + |
| 51 | + |
| 52 | +class AdjustmentIntervalAdjustmentPercentageDiscountAdjustment(BaseModel): |
| 53 | + adjustment_type: Literal["percentage_discount"] |
| 54 | + |
| 55 | + applies_to_price_ids: List[str] |
| 56 | + """The price IDs that this adjustment applies to.""" |
| 57 | + |
| 58 | + percentage_discount: float |
| 59 | + """ |
| 60 | + The percentage (as a value between 0 and 1) by which to discount the price |
| 61 | + intervals this adjustment applies to in a given billing period. |
| 62 | + """ |
| 63 | + |
| 64 | + reason: Optional[str] = None |
| 65 | + """The reason for the adjustment.""" |
| 66 | + |
| 67 | + |
| 68 | +class AdjustmentIntervalAdjustmentUsageDiscountAdjustment(BaseModel): |
| 69 | + adjustment_type: Literal["usage_discount"] |
| 70 | + |
| 71 | + applies_to_price_ids: List[str] |
| 72 | + """The price IDs that this adjustment applies to.""" |
| 73 | + |
| 74 | + reason: Optional[str] = None |
| 75 | + """The reason for the adjustment.""" |
| 76 | + |
| 77 | + usage_discount: float |
| 78 | + """ |
| 79 | + The number of usage units by which to discount the price this adjustment applies |
| 80 | + to in a given billing period. |
| 81 | + """ |
| 82 | + |
| 83 | + |
| 84 | +class AdjustmentIntervalAdjustmentMinimumAdjustment(BaseModel): |
| 85 | + adjustment_type: Literal["minimum"] |
| 86 | + |
| 87 | + applies_to_price_ids: List[str] |
| 88 | + """The price IDs that this adjustment applies to.""" |
| 89 | + |
| 90 | + item_id: str |
| 91 | + """The item ID that revenue from this minimum will be attributed to.""" |
| 92 | + |
| 93 | + minimum_amount: str |
| 94 | + """ |
| 95 | + The minimum amount to charge in a given billing period for the prices this |
| 96 | + adjustment applies to. |
| 97 | + """ |
| 98 | + |
| 99 | + reason: Optional[str] = None |
| 100 | + """The reason for the adjustment.""" |
| 101 | + |
| 102 | + |
| 103 | +class AdjustmentIntervalAdjustmentMaximumAdjustment(BaseModel): |
| 104 | + adjustment_type: Literal["maximum"] |
| 105 | + |
| 106 | + applies_to_price_ids: List[str] |
| 107 | + """The price IDs that this adjustment applies to.""" |
| 108 | + |
| 109 | + maximum_amount: str |
| 110 | + """ |
| 111 | + The maximum amount to charge in a given billing period for the prices this |
| 112 | + adjustment applies to. |
| 113 | + """ |
| 114 | + |
| 115 | + reason: Optional[str] = None |
| 116 | + """The reason for the adjustment.""" |
| 117 | + |
| 118 | + |
| 119 | +AdjustmentIntervalAdjustment = Annotated[ |
| 120 | + Union[ |
| 121 | + AdjustmentIntervalAdjustmentAmountDiscountAdjustment, |
| 122 | + AdjustmentIntervalAdjustmentPercentageDiscountAdjustment, |
| 123 | + AdjustmentIntervalAdjustmentUsageDiscountAdjustment, |
| 124 | + AdjustmentIntervalAdjustmentMinimumAdjustment, |
| 125 | + AdjustmentIntervalAdjustmentMaximumAdjustment, |
| 126 | + ], |
| 127 | + PropertyInfo(discriminator="adjustment_type"), |
| 128 | +] |
| 129 | + |
| 130 | + |
| 131 | +class AdjustmentInterval(BaseModel): |
| 132 | + id: str |
| 133 | + |
| 134 | + adjustment: AdjustmentIntervalAdjustment |
| 135 | + |
| 136 | + applies_to_price_interval_ids: List[str] |
| 137 | + """The price interval IDs that this adjustment applies to.""" |
| 138 | + |
| 139 | + end_date: Optional[datetime] = None |
| 140 | + """The end date of the adjustment interval.""" |
| 141 | + |
| 142 | + start_date: datetime |
| 143 | + """The start date of the adjustment interval.""" |
| 144 | + |
| 145 | + |
29 | 146 | class DiscountIntervalAmountDiscountInterval(BaseModel):
|
30 | 147 | amount_discount: str
|
31 | 148 | """Only available if discount_type is `amount`."""
|
@@ -453,6 +570,9 @@ class Subscription(BaseModel):
|
453 | 570 | phases.
|
454 | 571 | """
|
455 | 572 |
|
| 573 | + adjustment_intervals: List[AdjustmentInterval] |
| 574 | + """The adjustment intervals for this subscription.""" |
| 575 | + |
456 | 576 | auto_collection: Optional[bool] = None
|
457 | 577 | """
|
458 | 578 | Determines whether issued invoices for this subscription will automatically be
|
|
0 commit comments