|
17 | 17 | subscription_fetch_costs_params, |
18 | 18 | subscription_fetch_usage_params, |
19 | 19 | subscription_update_trial_params, |
| 20 | + subscription_redeem_coupon_params, |
20 | 21 | subscription_trigger_phase_params, |
21 | 22 | subscription_fetch_schedule_params, |
22 | 23 | subscription_price_intervals_params, |
|
37 | 38 | from ..types.subscription_create_response import SubscriptionCreateResponse |
38 | 39 | from ..types.subscription_fetch_costs_response import SubscriptionFetchCostsResponse |
39 | 40 | from ..types.subscription_update_trial_response import SubscriptionUpdateTrialResponse |
| 41 | +from ..types.subscription_redeem_coupon_response import SubscriptionRedeemCouponResponse |
40 | 42 | from ..types.subscription_trigger_phase_response import SubscriptionTriggerPhaseResponse |
41 | 43 | from ..types.subscription_fetch_schedule_response import SubscriptionFetchScheduleResponse |
42 | 44 | from ..types.subscription_price_intervals_response import SubscriptionPriceIntervalsResponse |
@@ -1361,6 +1363,68 @@ def price_intervals( |
1361 | 1363 | cast_to=SubscriptionPriceIntervalsResponse, |
1362 | 1364 | ) |
1363 | 1365 |
|
| 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 | + |
1364 | 1428 | def schedule_plan_change( |
1365 | 1429 | self, |
1366 | 1430 | subscription_id: str, |
@@ -3385,6 +3449,68 @@ async def price_intervals( |
3385 | 3449 | cast_to=SubscriptionPriceIntervalsResponse, |
3386 | 3450 | ) |
3387 | 3451 |
|
| 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 | + |
3388 | 3514 | async def schedule_plan_change( |
3389 | 3515 | self, |
3390 | 3516 | subscription_id: str, |
@@ -4132,6 +4258,9 @@ def __init__(self, subscriptions: Subscriptions) -> None: |
4132 | 4258 | self.price_intervals = _legacy_response.to_raw_response_wrapper( |
4133 | 4259 | subscriptions.price_intervals, |
4134 | 4260 | ) |
| 4261 | + self.redeem_coupon = _legacy_response.to_raw_response_wrapper( |
| 4262 | + subscriptions.redeem_coupon, |
| 4263 | + ) |
4135 | 4264 | self.schedule_plan_change = _legacy_response.to_raw_response_wrapper( |
4136 | 4265 | subscriptions.schedule_plan_change, |
4137 | 4266 | ) |
@@ -4186,6 +4315,9 @@ def __init__(self, subscriptions: AsyncSubscriptions) -> None: |
4186 | 4315 | self.price_intervals = _legacy_response.async_to_raw_response_wrapper( |
4187 | 4316 | subscriptions.price_intervals, |
4188 | 4317 | ) |
| 4318 | + self.redeem_coupon = _legacy_response.async_to_raw_response_wrapper( |
| 4319 | + subscriptions.redeem_coupon, |
| 4320 | + ) |
4189 | 4321 | self.schedule_plan_change = _legacy_response.async_to_raw_response_wrapper( |
4190 | 4322 | subscriptions.schedule_plan_change, |
4191 | 4323 | ) |
@@ -4240,6 +4372,9 @@ def __init__(self, subscriptions: Subscriptions) -> None: |
4240 | 4372 | self.price_intervals = to_streamed_response_wrapper( |
4241 | 4373 | subscriptions.price_intervals, |
4242 | 4374 | ) |
| 4375 | + self.redeem_coupon = to_streamed_response_wrapper( |
| 4376 | + subscriptions.redeem_coupon, |
| 4377 | + ) |
4243 | 4378 | self.schedule_plan_change = to_streamed_response_wrapper( |
4244 | 4379 | subscriptions.schedule_plan_change, |
4245 | 4380 | ) |
@@ -4294,6 +4429,9 @@ def __init__(self, subscriptions: AsyncSubscriptions) -> None: |
4294 | 4429 | self.price_intervals = async_to_streamed_response_wrapper( |
4295 | 4430 | subscriptions.price_intervals, |
4296 | 4431 | ) |
| 4432 | + self.redeem_coupon = async_to_streamed_response_wrapper( |
| 4433 | + subscriptions.redeem_coupon, |
| 4434 | + ) |
4297 | 4435 | self.schedule_plan_change = async_to_streamed_response_wrapper( |
4298 | 4436 | subscriptions.schedule_plan_change, |
4299 | 4437 | ) |
|
0 commit comments