lark-billing 0.5.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. lark/__init__.py +92 -0
  2. lark/_base_client.py +1995 -0
  3. lark/_client.py +459 -0
  4. lark/_compat.py +219 -0
  5. lark/_constants.py +14 -0
  6. lark/_exceptions.py +108 -0
  7. lark/_files.py +123 -0
  8. lark/_models.py +857 -0
  9. lark/_qs.py +150 -0
  10. lark/_resource.py +43 -0
  11. lark/_response.py +830 -0
  12. lark/_streaming.py +333 -0
  13. lark/_types.py +261 -0
  14. lark/_utils/__init__.py +64 -0
  15. lark/_utils/_compat.py +45 -0
  16. lark/_utils/_datetime_parse.py +136 -0
  17. lark/_utils/_logs.py +25 -0
  18. lark/_utils/_proxy.py +65 -0
  19. lark/_utils/_reflection.py +42 -0
  20. lark/_utils/_resources_proxy.py +24 -0
  21. lark/_utils/_streams.py +12 -0
  22. lark/_utils/_sync.py +58 -0
  23. lark/_utils/_transform.py +457 -0
  24. lark/_utils/_typing.py +156 -0
  25. lark/_utils/_utils.py +421 -0
  26. lark/_version.py +4 -0
  27. lark/lib/.keep +4 -0
  28. lark/py.typed +0 -0
  29. lark/resources/__init__.py +117 -0
  30. lark/resources/customer_access.py +167 -0
  31. lark/resources/customer_portal.py +187 -0
  32. lark/resources/invoices.py +191 -0
  33. lark/resources/pricing_metrics.py +499 -0
  34. lark/resources/rate_cards.py +395 -0
  35. lark/resources/subjects.py +579 -0
  36. lark/resources/subscriptions.py +647 -0
  37. lark/resources/usage_events.py +221 -0
  38. lark/types/__init__.py +53 -0
  39. lark/types/amount_input_param.py +16 -0
  40. lark/types/amount_output.py +13 -0
  41. lark/types/checkout_callback_param.py +15 -0
  42. lark/types/customer_access_retrieve_billing_state_response.py +40 -0
  43. lark/types/customer_portal_create_session_params.py +18 -0
  44. lark/types/customer_portal_create_session_response.py +18 -0
  45. lark/types/flat_price_input_param.py +17 -0
  46. lark/types/flat_price_output.py +17 -0
  47. lark/types/invoice_list_params.py +16 -0
  48. lark/types/invoice_list_response.py +49 -0
  49. lark/types/package_price_input_param.py +24 -0
  50. lark/types/package_price_output.py +24 -0
  51. lark/types/period.py +18 -0
  52. lark/types/period_param.py +21 -0
  53. lark/types/pricing_metric_create_params.py +98 -0
  54. lark/types/pricing_metric_create_summary_params.py +25 -0
  55. lark/types/pricing_metric_create_summary_response.py +36 -0
  56. lark/types/pricing_metric_list_params.py +11 -0
  57. lark/types/pricing_metric_list_response.py +14 -0
  58. lark/types/pricing_metric_resource.py +72 -0
  59. lark/types/rate_card_create_params.py +148 -0
  60. lark/types/rate_card_list_params.py +13 -0
  61. lark/types/rate_card_list_response.py +14 -0
  62. lark/types/rate_card_resource.py +141 -0
  63. lark/types/subject_create_params.py +29 -0
  64. lark/types/subject_create_response.py +34 -0
  65. lark/types/subject_list_params.py +13 -0
  66. lark/types/subject_list_response.py +14 -0
  67. lark/types/subject_resource.py +34 -0
  68. lark/types/subject_update_params.py +22 -0
  69. lark/types/subscription_cancel_params.py +16 -0
  70. lark/types/subscription_change_rate_card_params.py +29 -0
  71. lark/types/subscription_change_rate_card_response.py +55 -0
  72. lark/types/subscription_create_params.py +38 -0
  73. lark/types/subscription_create_response.py +55 -0
  74. lark/types/subscription_list_params.py +26 -0
  75. lark/types/subscription_list_response.py +14 -0
  76. lark/types/subscription_resource.py +49 -0
  77. lark/types/usage_event_create_params.py +41 -0
  78. lark_billing-0.5.0.dist-info/METADATA +431 -0
  79. lark_billing-0.5.0.dist-info/RECORD +81 -0
  80. lark_billing-0.5.0.dist-info/WHEEL +4 -0
  81. lark_billing-0.5.0.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,647 @@
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 Dict, Optional
6
+ from typing_extensions import Literal
7
+
8
+ import httpx
9
+
10
+ from ..types import (
11
+ subscription_list_params,
12
+ subscription_cancel_params,
13
+ subscription_create_params,
14
+ subscription_change_rate_card_params,
15
+ )
16
+ from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
17
+ from .._utils import maybe_transform, async_maybe_transform
18
+ from .._compat import cached_property
19
+ from .._resource import SyncAPIResource, AsyncAPIResource
20
+ from .._response import (
21
+ to_raw_response_wrapper,
22
+ to_streamed_response_wrapper,
23
+ async_to_raw_response_wrapper,
24
+ async_to_streamed_response_wrapper,
25
+ )
26
+ from .._base_client import make_request_options
27
+ from ..types.subscription_resource import SubscriptionResource
28
+ from ..types.checkout_callback_param import CheckoutCallbackParam
29
+ from ..types.subscription_list_response import SubscriptionListResponse
30
+ from ..types.subscription_create_response import SubscriptionCreateResponse
31
+ from ..types.subscription_change_rate_card_response import SubscriptionChangeRateCardResponse
32
+
33
+ __all__ = ["SubscriptionsResource", "AsyncSubscriptionsResource"]
34
+
35
+
36
+ class SubscriptionsResource(SyncAPIResource):
37
+ @cached_property
38
+ def with_raw_response(self) -> SubscriptionsResourceWithRawResponse:
39
+ """
40
+ This property can be used as a prefix for any HTTP method call to return
41
+ the raw response object instead of the parsed content.
42
+
43
+ For more information, see https://www.github.com/uselark/lark-billing-python#accessing-raw-response-data-eg-headers
44
+ """
45
+ return SubscriptionsResourceWithRawResponse(self)
46
+
47
+ @cached_property
48
+ def with_streaming_response(self) -> SubscriptionsResourceWithStreamingResponse:
49
+ """
50
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
51
+
52
+ For more information, see https://www.github.com/uselark/lark-billing-python#with_streaming_response
53
+ """
54
+ return SubscriptionsResourceWithStreamingResponse(self)
55
+
56
+ def create(
57
+ self,
58
+ *,
59
+ rate_card_id: str,
60
+ subject_id: str,
61
+ checkout_callback_urls: Optional[CheckoutCallbackParam] | Omit = omit,
62
+ create_checkout_session: Literal["when_required", "always"] | Omit = omit,
63
+ metadata: Dict[str, str] | Omit = omit,
64
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
65
+ # The extra values given here take precedence over values defined on the client or passed to this method.
66
+ extra_headers: Headers | None = None,
67
+ extra_query: Query | None = None,
68
+ extra_body: Body | None = None,
69
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
70
+ ) -> SubscriptionCreateResponse:
71
+ """
72
+ Create Subscription
73
+
74
+ Args:
75
+ rate_card_id: The ID of the rate card to use for the subscription.
76
+
77
+ subject_id: The ID or external ID of the subject to create the subscription for.
78
+
79
+ checkout_callback_urls: The URLs to redirect to after the checkout is completed or cancelled, if a
80
+ checkout is required.
81
+
82
+ create_checkout_session: Determines whether a checkout session is always required even if the subject has
83
+ a payment method on file. By default, if the subject has a payment method on
84
+ file or the subscription is for a free plan, the subscription will be created
85
+ and billed for immediately (if for a paid plan).
86
+
87
+ metadata: Additional metadata about the subscription. You may use this to store any custom
88
+ data about the subscription.
89
+
90
+ extra_headers: Send extra headers
91
+
92
+ extra_query: Add additional query parameters to the request
93
+
94
+ extra_body: Add additional JSON properties to the request
95
+
96
+ timeout: Override the client-level default timeout for this request, in seconds
97
+ """
98
+ return self._post(
99
+ "/subscriptions",
100
+ body=maybe_transform(
101
+ {
102
+ "rate_card_id": rate_card_id,
103
+ "subject_id": subject_id,
104
+ "checkout_callback_urls": checkout_callback_urls,
105
+ "create_checkout_session": create_checkout_session,
106
+ "metadata": metadata,
107
+ },
108
+ subscription_create_params.SubscriptionCreateParams,
109
+ ),
110
+ options=make_request_options(
111
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
112
+ ),
113
+ cast_to=SubscriptionCreateResponse,
114
+ )
115
+
116
+ def retrieve(
117
+ self,
118
+ subscription_id: str,
119
+ *,
120
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
121
+ # The extra values given here take precedence over values defined on the client or passed to this method.
122
+ extra_headers: Headers | None = None,
123
+ extra_query: Query | None = None,
124
+ extra_body: Body | None = None,
125
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
126
+ ) -> SubscriptionResource:
127
+ """
128
+ Get Subscription
129
+
130
+ Args:
131
+ extra_headers: Send extra headers
132
+
133
+ extra_query: Add additional query parameters to the request
134
+
135
+ extra_body: Add additional JSON properties to the request
136
+
137
+ timeout: Override the client-level default timeout for this request, in seconds
138
+ """
139
+ if not subscription_id:
140
+ raise ValueError(f"Expected a non-empty value for `subscription_id` but received {subscription_id!r}")
141
+ return self._get(
142
+ f"/subscriptions/{subscription_id}",
143
+ options=make_request_options(
144
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
145
+ ),
146
+ cast_to=SubscriptionResource,
147
+ )
148
+
149
+ def list(
150
+ self,
151
+ *,
152
+ limit: int | Omit = omit,
153
+ offset: int | Omit = omit,
154
+ rate_card_id: Optional[str] | Omit = omit,
155
+ subject_id: Optional[str] | Omit = omit,
156
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
157
+ # The extra values given here take precedence over values defined on the client or passed to this method.
158
+ extra_headers: Headers | None = None,
159
+ extra_query: Query | None = None,
160
+ extra_body: Body | None = None,
161
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
162
+ ) -> SubscriptionListResponse:
163
+ """
164
+ List Subscriptions
165
+
166
+ Args:
167
+ rate_card_id: The ID of the rate card to list subscriptions for. Cannot be used with
168
+ subject_id.
169
+
170
+ subject_id: The ID or external ID of the subject to list subscriptions for. Cannot be used
171
+ with rate_card_id.
172
+
173
+ extra_headers: Send extra headers
174
+
175
+ extra_query: Add additional query parameters to the request
176
+
177
+ extra_body: Add additional JSON properties to the request
178
+
179
+ timeout: Override the client-level default timeout for this request, in seconds
180
+ """
181
+ return self._get(
182
+ "/subscriptions",
183
+ options=make_request_options(
184
+ extra_headers=extra_headers,
185
+ extra_query=extra_query,
186
+ extra_body=extra_body,
187
+ timeout=timeout,
188
+ query=maybe_transform(
189
+ {
190
+ "limit": limit,
191
+ "offset": offset,
192
+ "rate_card_id": rate_card_id,
193
+ "subject_id": subject_id,
194
+ },
195
+ subscription_list_params.SubscriptionListParams,
196
+ ),
197
+ ),
198
+ cast_to=SubscriptionListResponse,
199
+ )
200
+
201
+ def cancel(
202
+ self,
203
+ subscription_id: str,
204
+ *,
205
+ cancel_at_end_of_cycle: Literal[True] | Omit = omit,
206
+ reason: Optional[str] | Omit = omit,
207
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
208
+ # The extra values given here take precedence over values defined on the client or passed to this method.
209
+ extra_headers: Headers | None = None,
210
+ extra_query: Query | None = None,
211
+ extra_body: Body | None = None,
212
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
213
+ ) -> SubscriptionResource:
214
+ """
215
+ Cancel Subscription
216
+
217
+ Args:
218
+ cancel_at_end_of_cycle: Whether to cancel the subscription at end of cycle.
219
+
220
+ reason: The reason for cancelling the subscription.
221
+
222
+ extra_headers: Send extra headers
223
+
224
+ extra_query: Add additional query parameters to the request
225
+
226
+ extra_body: Add additional JSON properties to the request
227
+
228
+ timeout: Override the client-level default timeout for this request, in seconds
229
+ """
230
+ if not subscription_id:
231
+ raise ValueError(f"Expected a non-empty value for `subscription_id` but received {subscription_id!r}")
232
+ return self._post(
233
+ f"/subscriptions/{subscription_id}/cancel",
234
+ body=maybe_transform(
235
+ {
236
+ "cancel_at_end_of_cycle": cancel_at_end_of_cycle,
237
+ "reason": reason,
238
+ },
239
+ subscription_cancel_params.SubscriptionCancelParams,
240
+ ),
241
+ options=make_request_options(
242
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
243
+ ),
244
+ cast_to=SubscriptionResource,
245
+ )
246
+
247
+ def change_rate_card(
248
+ self,
249
+ subscription_id: str,
250
+ *,
251
+ rate_card_id: str,
252
+ checkout_callback_urls: Optional[CheckoutCallbackParam] | Omit = omit,
253
+ upgrade_behavior: Literal["prorate", "rate_difference"] | Omit = omit,
254
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
255
+ # The extra values given here take precedence over values defined on the client or passed to this method.
256
+ extra_headers: Headers | None = None,
257
+ extra_query: Query | None = None,
258
+ extra_body: Body | None = None,
259
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
260
+ ) -> SubscriptionChangeRateCardResponse:
261
+ """
262
+ Change Subscription Rate Card
263
+
264
+ Args:
265
+ rate_card_id: The ID of the rate card to change the subscription to.
266
+
267
+ checkout_callback_urls: The URLs to redirect to after the checkout is completed or cancelled, if a
268
+ checkout is required.
269
+
270
+ upgrade_behavior: The behavior to use when upgrading the subscription. If 'prorate', the customer
271
+ will be charged for the prorated difference. If 'rate_difference', the customer
272
+ will be charged for the difference in the rate cards without respect to time.
273
+
274
+ extra_headers: Send extra headers
275
+
276
+ extra_query: Add additional query parameters to the request
277
+
278
+ extra_body: Add additional JSON properties to the request
279
+
280
+ timeout: Override the client-level default timeout for this request, in seconds
281
+ """
282
+ if not subscription_id:
283
+ raise ValueError(f"Expected a non-empty value for `subscription_id` but received {subscription_id!r}")
284
+ return self._post(
285
+ f"/subscriptions/{subscription_id}/change-rate-card",
286
+ body=maybe_transform(
287
+ {
288
+ "rate_card_id": rate_card_id,
289
+ "checkout_callback_urls": checkout_callback_urls,
290
+ "upgrade_behavior": upgrade_behavior,
291
+ },
292
+ subscription_change_rate_card_params.SubscriptionChangeRateCardParams,
293
+ ),
294
+ options=make_request_options(
295
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
296
+ ),
297
+ cast_to=SubscriptionChangeRateCardResponse,
298
+ )
299
+
300
+
301
+ class AsyncSubscriptionsResource(AsyncAPIResource):
302
+ @cached_property
303
+ def with_raw_response(self) -> AsyncSubscriptionsResourceWithRawResponse:
304
+ """
305
+ This property can be used as a prefix for any HTTP method call to return
306
+ the raw response object instead of the parsed content.
307
+
308
+ For more information, see https://www.github.com/uselark/lark-billing-python#accessing-raw-response-data-eg-headers
309
+ """
310
+ return AsyncSubscriptionsResourceWithRawResponse(self)
311
+
312
+ @cached_property
313
+ def with_streaming_response(self) -> AsyncSubscriptionsResourceWithStreamingResponse:
314
+ """
315
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
316
+
317
+ For more information, see https://www.github.com/uselark/lark-billing-python#with_streaming_response
318
+ """
319
+ return AsyncSubscriptionsResourceWithStreamingResponse(self)
320
+
321
+ async def create(
322
+ self,
323
+ *,
324
+ rate_card_id: str,
325
+ subject_id: str,
326
+ checkout_callback_urls: Optional[CheckoutCallbackParam] | Omit = omit,
327
+ create_checkout_session: Literal["when_required", "always"] | Omit = omit,
328
+ metadata: Dict[str, str] | Omit = omit,
329
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
330
+ # The extra values given here take precedence over values defined on the client or passed to this method.
331
+ extra_headers: Headers | None = None,
332
+ extra_query: Query | None = None,
333
+ extra_body: Body | None = None,
334
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
335
+ ) -> SubscriptionCreateResponse:
336
+ """
337
+ Create Subscription
338
+
339
+ Args:
340
+ rate_card_id: The ID of the rate card to use for the subscription.
341
+
342
+ subject_id: The ID or external ID of the subject to create the subscription for.
343
+
344
+ checkout_callback_urls: The URLs to redirect to after the checkout is completed or cancelled, if a
345
+ checkout is required.
346
+
347
+ create_checkout_session: Determines whether a checkout session is always required even if the subject has
348
+ a payment method on file. By default, if the subject has a payment method on
349
+ file or the subscription is for a free plan, the subscription will be created
350
+ and billed for immediately (if for a paid plan).
351
+
352
+ metadata: Additional metadata about the subscription. You may use this to store any custom
353
+ data about the subscription.
354
+
355
+ extra_headers: Send extra headers
356
+
357
+ extra_query: Add additional query parameters to the request
358
+
359
+ extra_body: Add additional JSON properties to the request
360
+
361
+ timeout: Override the client-level default timeout for this request, in seconds
362
+ """
363
+ return await self._post(
364
+ "/subscriptions",
365
+ body=await async_maybe_transform(
366
+ {
367
+ "rate_card_id": rate_card_id,
368
+ "subject_id": subject_id,
369
+ "checkout_callback_urls": checkout_callback_urls,
370
+ "create_checkout_session": create_checkout_session,
371
+ "metadata": metadata,
372
+ },
373
+ subscription_create_params.SubscriptionCreateParams,
374
+ ),
375
+ options=make_request_options(
376
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
377
+ ),
378
+ cast_to=SubscriptionCreateResponse,
379
+ )
380
+
381
+ async def retrieve(
382
+ self,
383
+ subscription_id: str,
384
+ *,
385
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
386
+ # The extra values given here take precedence over values defined on the client or passed to this method.
387
+ extra_headers: Headers | None = None,
388
+ extra_query: Query | None = None,
389
+ extra_body: Body | None = None,
390
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
391
+ ) -> SubscriptionResource:
392
+ """
393
+ Get Subscription
394
+
395
+ Args:
396
+ extra_headers: Send extra headers
397
+
398
+ extra_query: Add additional query parameters to the request
399
+
400
+ extra_body: Add additional JSON properties to the request
401
+
402
+ timeout: Override the client-level default timeout for this request, in seconds
403
+ """
404
+ if not subscription_id:
405
+ raise ValueError(f"Expected a non-empty value for `subscription_id` but received {subscription_id!r}")
406
+ return await self._get(
407
+ f"/subscriptions/{subscription_id}",
408
+ options=make_request_options(
409
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
410
+ ),
411
+ cast_to=SubscriptionResource,
412
+ )
413
+
414
+ async def list(
415
+ self,
416
+ *,
417
+ limit: int | Omit = omit,
418
+ offset: int | Omit = omit,
419
+ rate_card_id: Optional[str] | Omit = omit,
420
+ subject_id: Optional[str] | Omit = omit,
421
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
422
+ # The extra values given here take precedence over values defined on the client or passed to this method.
423
+ extra_headers: Headers | None = None,
424
+ extra_query: Query | None = None,
425
+ extra_body: Body | None = None,
426
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
427
+ ) -> SubscriptionListResponse:
428
+ """
429
+ List Subscriptions
430
+
431
+ Args:
432
+ rate_card_id: The ID of the rate card to list subscriptions for. Cannot be used with
433
+ subject_id.
434
+
435
+ subject_id: The ID or external ID of the subject to list subscriptions for. Cannot be used
436
+ with rate_card_id.
437
+
438
+ extra_headers: Send extra headers
439
+
440
+ extra_query: Add additional query parameters to the request
441
+
442
+ extra_body: Add additional JSON properties to the request
443
+
444
+ timeout: Override the client-level default timeout for this request, in seconds
445
+ """
446
+ return await self._get(
447
+ "/subscriptions",
448
+ options=make_request_options(
449
+ extra_headers=extra_headers,
450
+ extra_query=extra_query,
451
+ extra_body=extra_body,
452
+ timeout=timeout,
453
+ query=await async_maybe_transform(
454
+ {
455
+ "limit": limit,
456
+ "offset": offset,
457
+ "rate_card_id": rate_card_id,
458
+ "subject_id": subject_id,
459
+ },
460
+ subscription_list_params.SubscriptionListParams,
461
+ ),
462
+ ),
463
+ cast_to=SubscriptionListResponse,
464
+ )
465
+
466
+ async def cancel(
467
+ self,
468
+ subscription_id: str,
469
+ *,
470
+ cancel_at_end_of_cycle: Literal[True] | Omit = omit,
471
+ reason: Optional[str] | Omit = omit,
472
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
473
+ # The extra values given here take precedence over values defined on the client or passed to this method.
474
+ extra_headers: Headers | None = None,
475
+ extra_query: Query | None = None,
476
+ extra_body: Body | None = None,
477
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
478
+ ) -> SubscriptionResource:
479
+ """
480
+ Cancel Subscription
481
+
482
+ Args:
483
+ cancel_at_end_of_cycle: Whether to cancel the subscription at end of cycle.
484
+
485
+ reason: The reason for cancelling the subscription.
486
+
487
+ extra_headers: Send extra headers
488
+
489
+ extra_query: Add additional query parameters to the request
490
+
491
+ extra_body: Add additional JSON properties to the request
492
+
493
+ timeout: Override the client-level default timeout for this request, in seconds
494
+ """
495
+ if not subscription_id:
496
+ raise ValueError(f"Expected a non-empty value for `subscription_id` but received {subscription_id!r}")
497
+ return await self._post(
498
+ f"/subscriptions/{subscription_id}/cancel",
499
+ body=await async_maybe_transform(
500
+ {
501
+ "cancel_at_end_of_cycle": cancel_at_end_of_cycle,
502
+ "reason": reason,
503
+ },
504
+ subscription_cancel_params.SubscriptionCancelParams,
505
+ ),
506
+ options=make_request_options(
507
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
508
+ ),
509
+ cast_to=SubscriptionResource,
510
+ )
511
+
512
+ async def change_rate_card(
513
+ self,
514
+ subscription_id: str,
515
+ *,
516
+ rate_card_id: str,
517
+ checkout_callback_urls: Optional[CheckoutCallbackParam] | Omit = omit,
518
+ upgrade_behavior: Literal["prorate", "rate_difference"] | Omit = omit,
519
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
520
+ # The extra values given here take precedence over values defined on the client or passed to this method.
521
+ extra_headers: Headers | None = None,
522
+ extra_query: Query | None = None,
523
+ extra_body: Body | None = None,
524
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
525
+ ) -> SubscriptionChangeRateCardResponse:
526
+ """
527
+ Change Subscription Rate Card
528
+
529
+ Args:
530
+ rate_card_id: The ID of the rate card to change the subscription to.
531
+
532
+ checkout_callback_urls: The URLs to redirect to after the checkout is completed or cancelled, if a
533
+ checkout is required.
534
+
535
+ upgrade_behavior: The behavior to use when upgrading the subscription. If 'prorate', the customer
536
+ will be charged for the prorated difference. If 'rate_difference', the customer
537
+ will be charged for the difference in the rate cards without respect to time.
538
+
539
+ extra_headers: Send extra headers
540
+
541
+ extra_query: Add additional query parameters to the request
542
+
543
+ extra_body: Add additional JSON properties to the request
544
+
545
+ timeout: Override the client-level default timeout for this request, in seconds
546
+ """
547
+ if not subscription_id:
548
+ raise ValueError(f"Expected a non-empty value for `subscription_id` but received {subscription_id!r}")
549
+ return await self._post(
550
+ f"/subscriptions/{subscription_id}/change-rate-card",
551
+ body=await async_maybe_transform(
552
+ {
553
+ "rate_card_id": rate_card_id,
554
+ "checkout_callback_urls": checkout_callback_urls,
555
+ "upgrade_behavior": upgrade_behavior,
556
+ },
557
+ subscription_change_rate_card_params.SubscriptionChangeRateCardParams,
558
+ ),
559
+ options=make_request_options(
560
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
561
+ ),
562
+ cast_to=SubscriptionChangeRateCardResponse,
563
+ )
564
+
565
+
566
+ class SubscriptionsResourceWithRawResponse:
567
+ def __init__(self, subscriptions: SubscriptionsResource) -> None:
568
+ self._subscriptions = subscriptions
569
+
570
+ self.create = to_raw_response_wrapper(
571
+ subscriptions.create,
572
+ )
573
+ self.retrieve = to_raw_response_wrapper(
574
+ subscriptions.retrieve,
575
+ )
576
+ self.list = to_raw_response_wrapper(
577
+ subscriptions.list,
578
+ )
579
+ self.cancel = to_raw_response_wrapper(
580
+ subscriptions.cancel,
581
+ )
582
+ self.change_rate_card = to_raw_response_wrapper(
583
+ subscriptions.change_rate_card,
584
+ )
585
+
586
+
587
+ class AsyncSubscriptionsResourceWithRawResponse:
588
+ def __init__(self, subscriptions: AsyncSubscriptionsResource) -> None:
589
+ self._subscriptions = subscriptions
590
+
591
+ self.create = async_to_raw_response_wrapper(
592
+ subscriptions.create,
593
+ )
594
+ self.retrieve = async_to_raw_response_wrapper(
595
+ subscriptions.retrieve,
596
+ )
597
+ self.list = async_to_raw_response_wrapper(
598
+ subscriptions.list,
599
+ )
600
+ self.cancel = async_to_raw_response_wrapper(
601
+ subscriptions.cancel,
602
+ )
603
+ self.change_rate_card = async_to_raw_response_wrapper(
604
+ subscriptions.change_rate_card,
605
+ )
606
+
607
+
608
+ class SubscriptionsResourceWithStreamingResponse:
609
+ def __init__(self, subscriptions: SubscriptionsResource) -> None:
610
+ self._subscriptions = subscriptions
611
+
612
+ self.create = to_streamed_response_wrapper(
613
+ subscriptions.create,
614
+ )
615
+ self.retrieve = to_streamed_response_wrapper(
616
+ subscriptions.retrieve,
617
+ )
618
+ self.list = to_streamed_response_wrapper(
619
+ subscriptions.list,
620
+ )
621
+ self.cancel = to_streamed_response_wrapper(
622
+ subscriptions.cancel,
623
+ )
624
+ self.change_rate_card = to_streamed_response_wrapper(
625
+ subscriptions.change_rate_card,
626
+ )
627
+
628
+
629
+ class AsyncSubscriptionsResourceWithStreamingResponse:
630
+ def __init__(self, subscriptions: AsyncSubscriptionsResource) -> None:
631
+ self._subscriptions = subscriptions
632
+
633
+ self.create = async_to_streamed_response_wrapper(
634
+ subscriptions.create,
635
+ )
636
+ self.retrieve = async_to_streamed_response_wrapper(
637
+ subscriptions.retrieve,
638
+ )
639
+ self.list = async_to_streamed_response_wrapper(
640
+ subscriptions.list,
641
+ )
642
+ self.cancel = async_to_streamed_response_wrapper(
643
+ subscriptions.cancel,
644
+ )
645
+ self.change_rate_card = async_to_streamed_response_wrapper(
646
+ subscriptions.change_rate_card,
647
+ )