Skip to content

Commit 43c008a

Browse files
feat(api): api update
1 parent 94c69df commit 43c008a

File tree

10 files changed

+1023
-7
lines changed

10 files changed

+1023
-7
lines changed

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 114
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-faced218bf2dee89c8449bdb209e7090452d26c0646f0b998f84fe5bd3c4b7cb.yml
3-
openapi_spec_hash: b3a957e9c012fad5093545f65614ea42
4-
config_hash: e63f2d098e5d12f63ae4cd8270aa5c3c
1+
configured_endpoints: 115
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-d513be954ba2cb57489bd048f93790cabb13849f0f04d328a5a15694c99550df.yml
3+
openapi_spec_hash: 0d42694f412abf65defc3f88646a809c
4+
config_hash: 1e2186b09e57d7d27b6ab5c8e6410b31

api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ from orb.types import (
365365
SubscriptionFetchCostsResponse,
366366
SubscriptionFetchScheduleResponse,
367367
SubscriptionPriceIntervalsResponse,
368+
SubscriptionRedeemCouponResponse,
368369
SubscriptionSchedulePlanChangeResponse,
369370
SubscriptionTriggerPhaseResponse,
370371
SubscriptionUnscheduleCancellationResponse,
@@ -386,6 +387,7 @@ Methods:
386387
- <code title="get /subscriptions/{subscription_id}/schedule">client.subscriptions.<a href="./src/orb/resources/subscriptions.py">fetch_schedule</a>(subscription_id, \*\*<a href="src/orb/types/subscription_fetch_schedule_params.py">params</a>) -> <a href="./src/orb/types/subscription_fetch_schedule_response.py">SyncPage[SubscriptionFetchScheduleResponse]</a></code>
387388
- <code title="get /subscriptions/{subscription_id}/usage">client.subscriptions.<a href="./src/orb/resources/subscriptions.py">fetch_usage</a>(subscription_id, \*\*<a href="src/orb/types/subscription_fetch_usage_params.py">params</a>) -> <a href="./src/orb/types/subscription_usage.py">SubscriptionUsage</a></code>
388389
- <code title="post /subscriptions/{subscription_id}/price_intervals">client.subscriptions.<a href="./src/orb/resources/subscriptions.py">price_intervals</a>(subscription_id, \*\*<a href="src/orb/types/subscription_price_intervals_params.py">params</a>) -> <a href="./src/orb/types/subscription_price_intervals_response.py">SubscriptionPriceIntervalsResponse</a></code>
390+
- <code title="post /subscriptions/{subscription_id}/redeem_coupon">client.subscriptions.<a href="./src/orb/resources/subscriptions.py">redeem_coupon</a>(subscription_id, \*\*<a href="src/orb/types/subscription_redeem_coupon_params.py">params</a>) -> <a href="./src/orb/types/subscription_redeem_coupon_response.py">SubscriptionRedeemCouponResponse</a></code>
389391
- <code title="post /subscriptions/{subscription_id}/schedule_plan_change">client.subscriptions.<a href="./src/orb/resources/subscriptions.py">schedule_plan_change</a>(subscription_id, \*\*<a href="src/orb/types/subscription_schedule_plan_change_params.py">params</a>) -> <a href="./src/orb/types/subscription_schedule_plan_change_response.py">SubscriptionSchedulePlanChangeResponse</a></code>
390392
- <code title="post /subscriptions/{subscription_id}/trigger_phase">client.subscriptions.<a href="./src/orb/resources/subscriptions.py">trigger_phase</a>(subscription_id, \*\*<a href="src/orb/types/subscription_trigger_phase_params.py">params</a>) -> <a href="./src/orb/types/subscription_trigger_phase_response.py">SubscriptionTriggerPhaseResponse</a></code>
391393
- <code title="post /subscriptions/{subscription_id}/unschedule_cancellation">client.subscriptions.<a href="./src/orb/resources/subscriptions.py">unschedule_cancellation</a>(subscription_id) -> <a href="./src/orb/types/subscription_unschedule_cancellation_response.py">SubscriptionUnscheduleCancellationResponse</a></code>

src/orb/resources/subscriptions.py

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
subscription_fetch_costs_params,
1818
subscription_fetch_usage_params,
1919
subscription_update_trial_params,
20+
subscription_redeem_coupon_params,
2021
subscription_trigger_phase_params,
2122
subscription_fetch_schedule_params,
2223
subscription_price_intervals_params,
@@ -37,6 +38,7 @@
3738
from ..types.subscription_create_response import SubscriptionCreateResponse
3839
from ..types.subscription_fetch_costs_response import SubscriptionFetchCostsResponse
3940
from ..types.subscription_update_trial_response import SubscriptionUpdateTrialResponse
41+
from ..types.subscription_redeem_coupon_response import SubscriptionRedeemCouponResponse
4042
from ..types.subscription_trigger_phase_response import SubscriptionTriggerPhaseResponse
4143
from ..types.subscription_fetch_schedule_response import SubscriptionFetchScheduleResponse
4244
from ..types.subscription_price_intervals_response import SubscriptionPriceIntervalsResponse
@@ -1361,6 +1363,68 @@ def price_intervals(
13611363
cast_to=SubscriptionPriceIntervalsResponse,
13621364
)
13631365

1366+
def redeem_coupon(
1367+
self,
1368+
subscription_id: str,
1369+
*,
1370+
change_option: Literal["requested_date", "end_of_subscription_term", "immediate"],
1371+
coupon_id: str,
1372+
allow_invoice_credit_or_void: Optional[bool] | NotGiven = NOT_GIVEN,
1373+
change_date: Union[str, datetime, None] | NotGiven = NOT_GIVEN,
1374+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1375+
# The extra values given here take precedence over values defined on the client or passed to this method.
1376+
extra_headers: Headers | None = None,
1377+
extra_query: Query | None = None,
1378+
extra_body: Body | None = None,
1379+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
1380+
idempotency_key: str | None = None,
1381+
) -> SubscriptionRedeemCouponResponse:
1382+
"""
1383+
Redeem a coupon effective at a given time.
1384+
1385+
Args:
1386+
coupon_id: Coupon ID to be redeemed for this subscription.
1387+
1388+
allow_invoice_credit_or_void: If false, this request will fail if it would void an issued invoice or create a
1389+
credit note. Consider using this as a safety mechanism if you do not expect
1390+
existing invoices to be changed.
1391+
1392+
change_date: The date that the coupon discount should take effect. This parameter can only be
1393+
passed if the `change_option` is `requested_date`.
1394+
1395+
extra_headers: Send extra headers
1396+
1397+
extra_query: Add additional query parameters to the request
1398+
1399+
extra_body: Add additional JSON properties to the request
1400+
1401+
timeout: Override the client-level default timeout for this request, in seconds
1402+
1403+
idempotency_key: Specify a custom idempotency key for this request
1404+
"""
1405+
if not subscription_id:
1406+
raise ValueError(f"Expected a non-empty value for `subscription_id` but received {subscription_id!r}")
1407+
return self._post(
1408+
f"/subscriptions/{subscription_id}/redeem_coupon",
1409+
body=maybe_transform(
1410+
{
1411+
"change_option": change_option,
1412+
"coupon_id": coupon_id,
1413+
"allow_invoice_credit_or_void": allow_invoice_credit_or_void,
1414+
"change_date": change_date,
1415+
},
1416+
subscription_redeem_coupon_params.SubscriptionRedeemCouponParams,
1417+
),
1418+
options=make_request_options(
1419+
extra_headers=extra_headers,
1420+
extra_query=extra_query,
1421+
extra_body=extra_body,
1422+
timeout=timeout,
1423+
idempotency_key=idempotency_key,
1424+
),
1425+
cast_to=SubscriptionRedeemCouponResponse,
1426+
)
1427+
13641428
def schedule_plan_change(
13651429
self,
13661430
subscription_id: str,
@@ -3385,6 +3449,68 @@ async def price_intervals(
33853449
cast_to=SubscriptionPriceIntervalsResponse,
33863450
)
33873451

3452+
async def redeem_coupon(
3453+
self,
3454+
subscription_id: str,
3455+
*,
3456+
change_option: Literal["requested_date", "end_of_subscription_term", "immediate"],
3457+
coupon_id: str,
3458+
allow_invoice_credit_or_void: Optional[bool] | NotGiven = NOT_GIVEN,
3459+
change_date: Union[str, datetime, None] | NotGiven = NOT_GIVEN,
3460+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
3461+
# The extra values given here take precedence over values defined on the client or passed to this method.
3462+
extra_headers: Headers | None = None,
3463+
extra_query: Query | None = None,
3464+
extra_body: Body | None = None,
3465+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
3466+
idempotency_key: str | None = None,
3467+
) -> SubscriptionRedeemCouponResponse:
3468+
"""
3469+
Redeem a coupon effective at a given time.
3470+
3471+
Args:
3472+
coupon_id: Coupon ID to be redeemed for this subscription.
3473+
3474+
allow_invoice_credit_or_void: If false, this request will fail if it would void an issued invoice or create a
3475+
credit note. Consider using this as a safety mechanism if you do not expect
3476+
existing invoices to be changed.
3477+
3478+
change_date: The date that the coupon discount should take effect. This parameter can only be
3479+
passed if the `change_option` is `requested_date`.
3480+
3481+
extra_headers: Send extra headers
3482+
3483+
extra_query: Add additional query parameters to the request
3484+
3485+
extra_body: Add additional JSON properties to the request
3486+
3487+
timeout: Override the client-level default timeout for this request, in seconds
3488+
3489+
idempotency_key: Specify a custom idempotency key for this request
3490+
"""
3491+
if not subscription_id:
3492+
raise ValueError(f"Expected a non-empty value for `subscription_id` but received {subscription_id!r}")
3493+
return await self._post(
3494+
f"/subscriptions/{subscription_id}/redeem_coupon",
3495+
body=await async_maybe_transform(
3496+
{
3497+
"change_option": change_option,
3498+
"coupon_id": coupon_id,
3499+
"allow_invoice_credit_or_void": allow_invoice_credit_or_void,
3500+
"change_date": change_date,
3501+
},
3502+
subscription_redeem_coupon_params.SubscriptionRedeemCouponParams,
3503+
),
3504+
options=make_request_options(
3505+
extra_headers=extra_headers,
3506+
extra_query=extra_query,
3507+
extra_body=extra_body,
3508+
timeout=timeout,
3509+
idempotency_key=idempotency_key,
3510+
),
3511+
cast_to=SubscriptionRedeemCouponResponse,
3512+
)
3513+
33883514
async def schedule_plan_change(
33893515
self,
33903516
subscription_id: str,
@@ -4132,6 +4258,9 @@ def __init__(self, subscriptions: Subscriptions) -> None:
41324258
self.price_intervals = _legacy_response.to_raw_response_wrapper(
41334259
subscriptions.price_intervals,
41344260
)
4261+
self.redeem_coupon = _legacy_response.to_raw_response_wrapper(
4262+
subscriptions.redeem_coupon,
4263+
)
41354264
self.schedule_plan_change = _legacy_response.to_raw_response_wrapper(
41364265
subscriptions.schedule_plan_change,
41374266
)
@@ -4186,6 +4315,9 @@ def __init__(self, subscriptions: AsyncSubscriptions) -> None:
41864315
self.price_intervals = _legacy_response.async_to_raw_response_wrapper(
41874316
subscriptions.price_intervals,
41884317
)
4318+
self.redeem_coupon = _legacy_response.async_to_raw_response_wrapper(
4319+
subscriptions.redeem_coupon,
4320+
)
41894321
self.schedule_plan_change = _legacy_response.async_to_raw_response_wrapper(
41904322
subscriptions.schedule_plan_change,
41914323
)
@@ -4240,6 +4372,9 @@ def __init__(self, subscriptions: Subscriptions) -> None:
42404372
self.price_intervals = to_streamed_response_wrapper(
42414373
subscriptions.price_intervals,
42424374
)
4375+
self.redeem_coupon = to_streamed_response_wrapper(
4376+
subscriptions.redeem_coupon,
4377+
)
42434378
self.schedule_plan_change = to_streamed_response_wrapper(
42444379
subscriptions.schedule_plan_change,
42454380
)
@@ -4294,6 +4429,9 @@ def __init__(self, subscriptions: AsyncSubscriptions) -> None:
42944429
self.price_intervals = async_to_streamed_response_wrapper(
42954430
subscriptions.price_intervals,
42964431
)
4432+
self.redeem_coupon = async_to_streamed_response_wrapper(
4433+
subscriptions.redeem_coupon,
4434+
)
42974435
self.schedule_plan_change = async_to_streamed_response_wrapper(
42984436
subscriptions.schedule_plan_change,
42994437
)

src/orb/types/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,15 @@
8686
from .subscription_update_trial_params import SubscriptionUpdateTrialParams as SubscriptionUpdateTrialParams
8787
from .invoice_line_item_create_response import InvoiceLineItemCreateResponse as InvoiceLineItemCreateResponse
8888
from .subscription_fetch_costs_response import SubscriptionFetchCostsResponse as SubscriptionFetchCostsResponse
89+
from .subscription_redeem_coupon_params import SubscriptionRedeemCouponParams as SubscriptionRedeemCouponParams
8990
from .subscription_trigger_phase_params import SubscriptionTriggerPhaseParams as SubscriptionTriggerPhaseParams
9091
from .subscription_change_apply_response import SubscriptionChangeApplyResponse as SubscriptionChangeApplyResponse
9192
from .subscription_fetch_schedule_params import SubscriptionFetchScheduleParams as SubscriptionFetchScheduleParams
9293
from .subscription_update_trial_response import SubscriptionUpdateTrialResponse as SubscriptionUpdateTrialResponse
9394
from .dimensional_price_group_list_params import DimensionalPriceGroupListParams as DimensionalPriceGroupListParams
9495
from .subscription_change_cancel_response import SubscriptionChangeCancelResponse as SubscriptionChangeCancelResponse
9596
from .subscription_price_intervals_params import SubscriptionPriceIntervalsParams as SubscriptionPriceIntervalsParams
97+
from .subscription_redeem_coupon_response import SubscriptionRedeemCouponResponse as SubscriptionRedeemCouponResponse
9698
from .subscription_trigger_phase_response import SubscriptionTriggerPhaseResponse as SubscriptionTriggerPhaseResponse
9799
from .alert_create_for_subscription_params import AlertCreateForSubscriptionParams as AlertCreateForSubscriptionParams
98100
from .beta_set_default_plan_version_params import BetaSetDefaultPlanVersionParams as BetaSetDefaultPlanVersionParams

src/orb/types/invoice.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ class LineItem(BaseModel):
760760
partially_invoiced_amount: str
761761
"""Any amount applied from a partial invoice"""
762762

763-
price: Optional[Price] = None
763+
price: Price
764764
"""
765765
The Price resource represents a price that can be billed on a subscription,
766766
resulting in a charge on an invoice in the form of an invoice line item. Prices

src/orb/types/invoice_fetch_upcoming_response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ class LineItem(BaseModel):
760760
partially_invoiced_amount: str
761761
"""Any amount applied from a partial invoice"""
762762

763-
price: Optional[Price] = None
763+
price: Price
764764
"""
765765
The Price resource represents a price that can be billed on a subscription,
766766
resulting in a charge on an invoice in the form of an invoice line item. Prices

src/orb/types/invoice_line_item_create_response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ class InvoiceLineItemCreateResponse(BaseModel):
462462
partially_invoiced_amount: str
463463
"""Any amount applied from a partial invoice"""
464464

465-
price: Optional[Price] = None
465+
price: Price
466466
"""
467467
The Price resource represents a price that can be billed on a subscription,
468468
resulting in a charge on an invoice in the form of an invoice line item. Prices
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing import Union, Optional
6+
from datetime import datetime
7+
from typing_extensions import Literal, Required, Annotated, TypedDict
8+
9+
from .._utils import PropertyInfo
10+
11+
__all__ = ["SubscriptionRedeemCouponParams"]
12+
13+
14+
class SubscriptionRedeemCouponParams(TypedDict, total=False):
15+
change_option: Required[Literal["requested_date", "end_of_subscription_term", "immediate"]]
16+
17+
coupon_id: Required[str]
18+
"""Coupon ID to be redeemed for this subscription."""
19+
20+
allow_invoice_credit_or_void: Optional[bool]
21+
"""
22+
If false, this request will fail if it would void an issued invoice or create a
23+
credit note. Consider using this as a safety mechanism if you do not expect
24+
existing invoices to be changed.
25+
"""
26+
27+
change_date: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]
28+
"""The date that the coupon discount should take effect.
29+
30+
This parameter can only be passed if the `change_option` is `requested_date`.
31+
"""

0 commit comments

Comments
 (0)