Skip to content

Commit cffd4f8

Browse files
feat(api): add adjustment interval to subscriptions (#277)
1 parent 3b84e0f commit cffd4f8

File tree

2 files changed

+121
-1
lines changed

2 files changed

+121
-1
lines changed

.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 89
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb-7e13dcf04525285142e73cd86bf3a25fed7bea1d16a70d454e43f1ab692dec57.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb-5fa8f545ccc5fde6d8429e25905e1db29b5e246c1e88d795e937cd4bfb57ffa4.yml

src/orb/types/subscription.py

+120
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212

1313
__all__ = [
1414
"Subscription",
15+
"AdjustmentInterval",
16+
"AdjustmentIntervalAdjustment",
17+
"AdjustmentIntervalAdjustmentAmountDiscountAdjustment",
18+
"AdjustmentIntervalAdjustmentPercentageDiscountAdjustment",
19+
"AdjustmentIntervalAdjustmentUsageDiscountAdjustment",
20+
"AdjustmentIntervalAdjustmentMinimumAdjustment",
21+
"AdjustmentIntervalAdjustmentMaximumAdjustment",
1522
"DiscountInterval",
1623
"DiscountIntervalAmountDiscountInterval",
1724
"DiscountIntervalPercentageDiscountInterval",
@@ -26,6 +33,116 @@
2633
]
2734

2835

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+
29146
class DiscountIntervalAmountDiscountInterval(BaseModel):
30147
amount_discount: str
31148
"""Only available if discount_type is `amount`."""
@@ -453,6 +570,9 @@ class Subscription(BaseModel):
453570
phases.
454571
"""
455572

573+
adjustment_intervals: List[AdjustmentInterval]
574+
"""The adjustment intervals for this subscription."""
575+
456576
auto_collection: Optional[bool] = None
457577
"""
458578
Determines whether issued invoices for this subscription will automatically be

0 commit comments

Comments
 (0)