Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): add support for adding allocation price to subscription #295

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 90
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb-d9cc087ece8a2eba847035f3cd8ae44d3401046e01761ab6ad7fd6165d93f0c8.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb-d08c3c586f46f155358104a907afa8300ce44a25814c1574c0f4344935c1b838.yml
24 changes: 24 additions & 0 deletions src/orb/types/subscription_price_intervals_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
__all__ = [
"SubscriptionPriceIntervalsParams",
"Add",
"AddAllocationPrice",
"AddDiscount",
"AddDiscountAmountDiscountCreationParams",
"AddDiscountPercentageDiscountCreationParams",
Expand Down Expand Up @@ -77,6 +78,26 @@ class SubscriptionPriceIntervalsParams(TypedDict, total=False):
"""A list of adjustments to edit on the subscription."""


class AddAllocationPrice(TypedDict, total=False):
amount: Required[float]
"""An amount of the currency to allocate to the customer at the specified cadence."""

cadence: Required[Literal["one_time", "monthly", "quarterly", "semi_annual", "annual"]]
"""The cadence at which to allocate the amount to the customer."""

currency: Required[str]
"""
An ISO 4217 currency string or a custom pricing unit identifier in which to bill
this price.
"""

expires_at_end_of_cadence: Required[bool]
"""
Whether the allocated amount should expire at the end of the cadence or roll
over to the next period.
"""


class AddDiscountAmountDiscountCreationParams(TypedDict, total=False):
amount_discount: Required[float]
"""Only available if discount_type is `amount`."""
Expand Down Expand Up @@ -1104,6 +1125,9 @@ class Add(TypedDict, total=False):
This is the date that the price will start billing on the subscription.
"""

allocation_price: Optional[AddAllocationPrice]
"""The definition of a new allocation price to create and add to the subscription."""

discounts: Optional[Iterable[AddDiscount]]
"""A list of discounts to initialize on the price interval."""

Expand Down
36 changes: 36 additions & 0 deletions tests/api_resources/test_subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,12 @@ def test_method_price_intervals_with_all_params(self, client: Orb) -> None:
"unit_config": {"unit_amount": "string"},
"currency": "string",
},
"allocation_price": {
"currency": "USD",
"amount": 0,
"cadence": "monthly",
"expires_at_end_of_cadence": True,
},
"start_date": parse_datetime("2019-12-27T18:11:19.117Z"),
"end_date": parse_datetime("2019-12-27T18:11:19.117Z"),
"fixed_fee_quantity_transitions": [
Expand Down Expand Up @@ -551,6 +557,12 @@ def test_method_price_intervals_with_all_params(self, client: Orb) -> None:
"unit_config": {"unit_amount": "string"},
"currency": "string",
},
"allocation_price": {
"currency": "USD",
"amount": 0,
"cadence": "monthly",
"expires_at_end_of_cadence": True,
},
"start_date": parse_datetime("2019-12-27T18:11:19.117Z"),
"end_date": parse_datetime("2019-12-27T18:11:19.117Z"),
"fixed_fee_quantity_transitions": [
Expand Down Expand Up @@ -601,6 +613,12 @@ def test_method_price_intervals_with_all_params(self, client: Orb) -> None:
"unit_config": {"unit_amount": "string"},
"currency": "string",
},
"allocation_price": {
"currency": "USD",
"amount": 0,
"cadence": "monthly",
"expires_at_end_of_cadence": True,
},
"start_date": parse_datetime("2019-12-27T18:11:19.117Z"),
"end_date": parse_datetime("2019-12-27T18:11:19.117Z"),
"fixed_fee_quantity_transitions": [
Expand Down Expand Up @@ -1598,6 +1616,12 @@ async def test_method_price_intervals_with_all_params(self, async_client: AsyncO
"unit_config": {"unit_amount": "string"},
"currency": "string",
},
"allocation_price": {
"currency": "USD",
"amount": 0,
"cadence": "monthly",
"expires_at_end_of_cadence": True,
},
"start_date": parse_datetime("2019-12-27T18:11:19.117Z"),
"end_date": parse_datetime("2019-12-27T18:11:19.117Z"),
"fixed_fee_quantity_transitions": [
Expand Down Expand Up @@ -1648,6 +1672,12 @@ async def test_method_price_intervals_with_all_params(self, async_client: AsyncO
"unit_config": {"unit_amount": "string"},
"currency": "string",
},
"allocation_price": {
"currency": "USD",
"amount": 0,
"cadence": "monthly",
"expires_at_end_of_cadence": True,
},
"start_date": parse_datetime("2019-12-27T18:11:19.117Z"),
"end_date": parse_datetime("2019-12-27T18:11:19.117Z"),
"fixed_fee_quantity_transitions": [
Expand Down Expand Up @@ -1698,6 +1728,12 @@ async def test_method_price_intervals_with_all_params(self, async_client: AsyncO
"unit_config": {"unit_amount": "string"},
"currency": "string",
},
"allocation_price": {
"currency": "USD",
"amount": 0,
"cadence": "monthly",
"expires_at_end_of_cadence": True,
},
"start_date": parse_datetime("2019-12-27T18:11:19.117Z"),
"end_date": parse_datetime("2019-12-27T18:11:19.117Z"),
"fixed_fee_quantity_transitions": [
Expand Down