Skip to content

feat(api): api update #520

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
Feb 4, 2025
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: 103
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-8663e8fc543041d9694eddcd2f7e9784611369606700f99340e6dc80607b2dfa.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-0dbb8ba730f755468357ebda41332664e8396faf29a6a6a64ad37cf35cf70d0c.yml
384 changes: 382 additions & 2 deletions src/orb/resources/prices/prices.py

Large diffs are not rendered by default.

175 changes: 175 additions & 0 deletions src/orb/types/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
"CustomerBalanceTransactionInvoice",
"CustomerTaxID",
"LineItem",
"LineItemAdjustment",
"LineItemAdjustmentAmountDiscountAdjustment",
"LineItemAdjustmentPercentageDiscountAdjustment",
"LineItemAdjustmentUsageDiscountAdjustment",
"LineItemAdjustmentMinimumAdjustment",
"LineItemAdjustmentMaximumAdjustment",
"LineItemMaximum",
"LineItemMinimum",
"LineItemSubLineItem",
Expand Down Expand Up @@ -319,6 +325,156 @@ class CustomerTaxID(BaseModel):
value: str


class LineItemAdjustmentAmountDiscountAdjustment(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 LineItemAdjustmentPercentageDiscountAdjustment(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 LineItemAdjustmentUsageDiscountAdjustment(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 LineItemAdjustmentMinimumAdjustment(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 LineItemAdjustmentMaximumAdjustment(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."""


LineItemAdjustment: TypeAlias = Annotated[
Union[
LineItemAdjustmentAmountDiscountAdjustment,
LineItemAdjustmentPercentageDiscountAdjustment,
LineItemAdjustmentUsageDiscountAdjustment,
LineItemAdjustmentMinimumAdjustment,
LineItemAdjustmentMaximumAdjustment,
],
PropertyInfo(discriminator="adjustment_type"),
]


class LineItemMaximum(BaseModel):
applies_to_price_ids: List[str]
"""List of price_ids that this maximum amount applies to.
Expand Down Expand Up @@ -441,9 +597,21 @@ class LineItem(BaseModel):
id: str
"""A unique ID for this line item."""

adjusted_subtotal: str
"""
The line amount after any adjustments, before overage conversion, credits and
partial invoicing.
"""

adjustments: List[LineItemAdjustment]
"""All adjustments applied to the line item."""

amount: str
"""The final amount after any discounts or minimums."""

credits_applied: str
"""The number of credits used"""

discount: Optional[Discount] = None

end_date: datetime
Expand All @@ -457,16 +625,23 @@ class LineItem(BaseModel):
"""

maximum: Optional[LineItemMaximum] = None
"""This field is deprecated in favor of `adjustments`."""

maximum_amount: Optional[str] = None
"""This field is deprecated in favor of `adjustments`."""

minimum: Optional[LineItemMinimum] = None
"""This field is deprecated in favor of `adjustments`."""

minimum_amount: Optional[str] = None
"""This field is deprecated in favor of `adjustments`."""

name: str
"""The name of the price associated with this line item."""

partially_invoiced_amount: str
"""Any amount applied from a partial invoice"""

price: Optional[Price] = None
"""
The Price resource represents a price that can be billed on a subscription,
Expand Down
Loading