Skip to content

feat(api): api update #441

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

Merged
merged 1 commit into from
Nov 26, 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: 97
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-40a4e23dd482299a046fb62fd2b5a1e03d455156cb8cd4573e92e4132d74b243.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-14d1c1e4560c65c7c62f23343268ece4476ae079cd01ba2e6b924efde5f97c3e.yml
167 changes: 165 additions & 2 deletions src/orb/types/plan.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import Dict, List, Optional
from typing import Dict, List, Union, Optional
from datetime import datetime
from typing_extensions import Literal
from typing_extensions import Literal, Annotated, TypeAlias

from .price import Price
from .._utils import PropertyInfo
from .._models import BaseModel
from .shared.discount import Discount

__all__ = [
"Plan",
"Adjustment",
"AdjustmentAmountDiscountAdjustment",
"AdjustmentPercentageDiscountAdjustment",
"AdjustmentUsageDiscountAdjustment",
"AdjustmentMinimumAdjustment",
"AdjustmentMaximumAdjustment",
"BasePlan",
"Maximum",
"Minimum",
Expand All @@ -21,6 +28,156 @@
]


class AdjustmentAmountDiscountAdjustment(BaseModel):
id: str

adjustment_type: Literal["amount_discount"]

amount_discount: str
"""
The amount by which to discount the prices this adjustment applies to in a given
billing period.
"""

applies_to_price_ids: List[str]
"""The price IDs that this adjustment applies to."""

is_invoice_level: bool
"""
True for adjustments that apply to an entire invocice, false for adjustments
that apply to only one price.
"""

plan_phase_order: Optional[int] = None
"""The plan phase in which this adjustment is active."""

reason: Optional[str] = None
"""The reason for the adjustment."""


class AdjustmentPercentageDiscountAdjustment(BaseModel):
id: str

adjustment_type: Literal["percentage_discount"]

applies_to_price_ids: List[str]
"""The price IDs that this adjustment applies to."""

is_invoice_level: bool
"""
True for adjustments that apply to an entire invocice, false for adjustments
that apply to only one price.
"""

percentage_discount: float
"""
The percentage (as a value between 0 and 1) by which to discount the price
intervals this adjustment applies to in a given billing period.
"""

plan_phase_order: Optional[int] = None
"""The plan phase in which this adjustment is active."""

reason: Optional[str] = None
"""The reason for the adjustment."""


class AdjustmentUsageDiscountAdjustment(BaseModel):
id: str

adjustment_type: Literal["usage_discount"]

applies_to_price_ids: List[str]
"""The price IDs that this adjustment applies to."""

is_invoice_level: bool
"""
True for adjustments that apply to an entire invocice, false for adjustments
that apply to only one price.
"""

plan_phase_order: Optional[int] = None
"""The plan phase in which this adjustment is active."""

reason: Optional[str] = None
"""The reason for the adjustment."""

usage_discount: float
"""
The number of usage units by which to discount the price this adjustment applies
to in a given billing period.
"""


class AdjustmentMinimumAdjustment(BaseModel):
id: str

adjustment_type: Literal["minimum"]

applies_to_price_ids: List[str]
"""The price IDs that this adjustment applies to."""

is_invoice_level: bool
"""
True for adjustments that apply to an entire invocice, false for adjustments
that apply to only one price.
"""

item_id: str
"""The item ID that revenue from this minimum will be attributed to."""

minimum_amount: str
"""
The minimum amount to charge in a given billing period for the prices this
adjustment applies to.
"""

plan_phase_order: Optional[int] = None
"""The plan phase in which this adjustment is active."""

reason: Optional[str] = None
"""The reason for the adjustment."""


class AdjustmentMaximumAdjustment(BaseModel):
id: str

adjustment_type: Literal["maximum"]

applies_to_price_ids: List[str]
"""The price IDs that this adjustment applies to."""

is_invoice_level: bool
"""
True for adjustments that apply to an entire invocice, false for adjustments
that apply to only one price.
"""

maximum_amount: str
"""
The maximum amount to charge in a given billing period for the prices this
adjustment applies to.
"""

plan_phase_order: Optional[int] = None
"""The plan phase in which this adjustment is active."""

reason: Optional[str] = None
"""The reason for the adjustment."""


Adjustment: TypeAlias = Annotated[
Union[
AdjustmentAmountDiscountAdjustment,
AdjustmentPercentageDiscountAdjustment,
AdjustmentUsageDiscountAdjustment,
AdjustmentMinimumAdjustment,
AdjustmentMaximumAdjustment,
],
PropertyInfo(discriminator="adjustment_type"),
]


class BasePlan(BaseModel):
id: Optional[str] = None

Expand Down Expand Up @@ -124,6 +281,12 @@ class TrialConfig(BaseModel):
class Plan(BaseModel):
id: str

adjustments: List[Adjustment]
"""Adjustments for this plan.

If the plan has phases, this includes adjustments across all phases of the plan.
"""

base_plan: Optional[BasePlan] = None

base_plan_id: Optional[str] = None
Expand Down
55 changes: 55 additions & 0 deletions src/orb/types/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@


class AdjustmentIntervalAdjustmentAmountDiscountAdjustment(BaseModel):
id: str

adjustment_type: Literal["amount_discount"]

amount_discount: str
Expand All @@ -46,32 +48,63 @@ class AdjustmentIntervalAdjustmentAmountDiscountAdjustment(BaseModel):
applies_to_price_ids: List[str]
"""The price IDs that this adjustment applies to."""

is_invoice_level: bool
"""
True for adjustments that apply to an entire invocice, false for adjustments
that apply to only one price.
"""

plan_phase_order: Optional[int] = None
"""The plan phase in which this adjustment is active."""

reason: Optional[str] = None
"""The reason for the adjustment."""


class AdjustmentIntervalAdjustmentPercentageDiscountAdjustment(BaseModel):
id: str

adjustment_type: Literal["percentage_discount"]

applies_to_price_ids: List[str]
"""The price IDs that this adjustment applies to."""

is_invoice_level: bool
"""
True for adjustments that apply to an entire invocice, false for adjustments
that apply to only one price.
"""

percentage_discount: float
"""
The percentage (as a value between 0 and 1) by which to discount the price
intervals this adjustment applies to in a given billing period.
"""

plan_phase_order: Optional[int] = None
"""The plan phase in which this adjustment is active."""

reason: Optional[str] = None
"""The reason for the adjustment."""


class AdjustmentIntervalAdjustmentUsageDiscountAdjustment(BaseModel):
id: str

adjustment_type: Literal["usage_discount"]

applies_to_price_ids: List[str]
"""The price IDs that this adjustment applies to."""

is_invoice_level: bool
"""
True for adjustments that apply to an entire invocice, false for adjustments
that apply to only one price.
"""

plan_phase_order: Optional[int] = None
"""The plan phase in which this adjustment is active."""

reason: Optional[str] = None
"""The reason for the adjustment."""

Expand All @@ -83,11 +116,19 @@ class AdjustmentIntervalAdjustmentUsageDiscountAdjustment(BaseModel):


class AdjustmentIntervalAdjustmentMinimumAdjustment(BaseModel):
id: str

adjustment_type: Literal["minimum"]

applies_to_price_ids: List[str]
"""The price IDs that this adjustment applies to."""

is_invoice_level: bool
"""
True for adjustments that apply to an entire invocice, false for adjustments
that apply to only one price.
"""

item_id: str
"""The item ID that revenue from this minimum will be attributed to."""

Expand All @@ -97,22 +138,36 @@ class AdjustmentIntervalAdjustmentMinimumAdjustment(BaseModel):
adjustment applies to.
"""

plan_phase_order: Optional[int] = None
"""The plan phase in which this adjustment is active."""

reason: Optional[str] = None
"""The reason for the adjustment."""


class AdjustmentIntervalAdjustmentMaximumAdjustment(BaseModel):
id: str

adjustment_type: Literal["maximum"]

applies_to_price_ids: List[str]
"""The price IDs that this adjustment applies to."""

is_invoice_level: bool
"""
True for adjustments that apply to an entire invocice, false for adjustments
that apply to only one price.
"""

maximum_amount: str
"""
The maximum amount to charge in a given billing period for the prices this
adjustment applies to.
"""

plan_phase_order: Optional[int] = None
"""The plan phase in which this adjustment is active."""

reason: Optional[str] = None
"""The reason for the adjustment."""

Expand Down
Loading