lark-billing 0.0.7__py3-none-any.whl → 0.0.9__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.
Potentially problematic release.
This version of lark-billing might be problematic. Click here for more details.
- lark/__init__.py +45 -29
- lark/checkout/client.py +34 -12
- lark/checkout/raw_client.py +22 -6
- lark/client.py +19 -0
- lark/core/client_wrapper.py +2 -2
- lark/core/http_sse/__init__.py +42 -0
- lark/core/http_sse/_api.py +112 -0
- lark/core/http_sse/_decoders.py +61 -0
- lark/core/http_sse/_exceptions.py +7 -0
- lark/core/http_sse/_models.py +17 -0
- lark/core/pydantic_utilities.py +3 -1
- lark/customer_portal/client.py +4 -2
- lark/customer_portal/raw_client.py +2 -0
- lark/invoices/__init__.py +4 -0
- lark/invoices/client.py +136 -0
- lark/invoices/raw_client.py +147 -0
- lark/pricing_metrics/client.py +69 -0
- lark/pricing_metrics/raw_client.py +101 -0
- lark/rate_cards/__init__.py +15 -3
- lark/rate_cards/client.py +20 -14
- lark/rate_cards/raw_client.py +26 -20
- lark/rate_cards/types/__init__.py +12 -2
- lark/rate_cards/types/create_rate_card_request_usage_based_rates_item.py +30 -0
- lark/subjects/client.py +16 -18
- lark/subjects/raw_client.py +14 -8
- lark/subscriptions/client.py +194 -8
- lark/subscriptions/raw_client.py +256 -4
- lark/types/__init__.py +31 -32
- lark/types/aggregation.py +1 -43
- lark/types/amount.py +4 -1
- lark/types/create_customer_portal_session_response.py +9 -2
- lark/types/{create_simple_usage_based_rate_interface.py → create_fixed_rate_request.py} +11 -6
- lark/types/create_simple_usage_based_rate_request.py +39 -0
- lark/types/create_subject_response.py +29 -6
- lark/types/create_subscription_checkout_session_response.py +14 -3
- lark/types/fixed_rate_interface.py +1 -1
- lark/types/{custom_pricing_metric_resource.py → invoice_line_item_resource.py} +6 -2
- lark/types/invoice_resource.py +56 -0
- lark/types/invoice_status.py +5 -0
- lark/types/{max_aggregation_pricing_metric_resource.py → list_invoices_response.py} +4 -2
- lark/types/{create_fixed_rate_interface.py → list_pricing_metrics_response.py} +4 -5
- lark/types/period_resource.py +23 -0
- lark/types/{last_aggregation_pricing_metric_resource.py → pricing_metric_resource.py} +7 -2
- lark/types/rate_card_resource.py +36 -7
- lark/types/rate_card_resource_usage_based_rates_item.py +1 -2
- lark/types/simple_usage_based_rate_interface.py +1 -6
- lark/types/subject_resource.py +29 -6
- lark/types/subscription_resource.py +42 -8
- lark/types/subscription_status.py +5 -0
- lark/usage_events/__init__.py +6 -3
- lark/usage_events/client.py +15 -4
- lark/usage_events/raw_client.py +21 -6
- lark/usage_events/types/__init__.py +4 -2
- lark/{types/status.py → usage_events/types/create_usage_event_request_data_value.py} +1 -1
- {lark_billing-0.0.7.dist-info → lark_billing-0.0.9.dist-info}/METADATA +8 -7
- lark_billing-0.0.9.dist-info/RECORD +108 -0
- lark_billing-0.0.7.dist-info/RECORD +0 -94
- {lark_billing-0.0.7.dist-info → lark_billing-0.0.9.dist-info}/WHEEL +0 -0
lark/subscriptions/client.py
CHANGED
|
@@ -77,17 +77,20 @@ class SubscriptionsClient:
|
|
|
77
77
|
*,
|
|
78
78
|
rate_card_id: str,
|
|
79
79
|
subject_id: str,
|
|
80
|
-
metadata: typing.Optional[typing.Dict[str,
|
|
80
|
+
metadata: typing.Optional[typing.Dict[str, str]] = OMIT,
|
|
81
81
|
request_options: typing.Optional[RequestOptions] = None,
|
|
82
82
|
) -> SubscriptionResource:
|
|
83
83
|
"""
|
|
84
84
|
Parameters
|
|
85
85
|
----------
|
|
86
86
|
rate_card_id : str
|
|
87
|
+
The ID of the rate card to use for the subscription.
|
|
87
88
|
|
|
88
89
|
subject_id : str
|
|
90
|
+
The ID of the subject to create the subscription for.
|
|
89
91
|
|
|
90
|
-
metadata : typing.Optional[typing.Dict[str,
|
|
92
|
+
metadata : typing.Optional[typing.Dict[str, str]]
|
|
93
|
+
Additional metadata about the subscription. You may use this to store any custom data about the subscription.
|
|
91
94
|
|
|
92
95
|
request_options : typing.Optional[RequestOptions]
|
|
93
96
|
Request-specific configuration.
|
|
@@ -105,8 +108,8 @@ class SubscriptionsClient:
|
|
|
105
108
|
api_key="YOUR_API_KEY",
|
|
106
109
|
)
|
|
107
110
|
client.subscriptions.create_subscription(
|
|
108
|
-
rate_card_id="
|
|
109
|
-
subject_id="
|
|
111
|
+
rate_card_id="rc_AJWMxR81jxoRlli6p13uf3JB",
|
|
112
|
+
subject_id="subj_VyX6Q96h5avMho8O7QWlKeXE",
|
|
110
113
|
)
|
|
111
114
|
"""
|
|
112
115
|
_response = self._raw_client.create_subscription(
|
|
@@ -144,6 +147,88 @@ class SubscriptionsClient:
|
|
|
144
147
|
_response = self._raw_client.get_subscription(subscription_id, request_options=request_options)
|
|
145
148
|
return _response.data
|
|
146
149
|
|
|
150
|
+
def cancel_subscription(
|
|
151
|
+
self,
|
|
152
|
+
subscription_id: str,
|
|
153
|
+
*,
|
|
154
|
+
reason: typing.Optional[str] = OMIT,
|
|
155
|
+
cancel_at_end_of_cycle: typing.Optional[bool] = OMIT,
|
|
156
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
157
|
+
) -> SubscriptionResource:
|
|
158
|
+
"""
|
|
159
|
+
Parameters
|
|
160
|
+
----------
|
|
161
|
+
subscription_id : str
|
|
162
|
+
|
|
163
|
+
reason : typing.Optional[str]
|
|
164
|
+
The reason for cancelling the subscription.
|
|
165
|
+
|
|
166
|
+
cancel_at_end_of_cycle : typing.Optional[bool]
|
|
167
|
+
Whether to cancel the subscription at end of cycle.
|
|
168
|
+
|
|
169
|
+
request_options : typing.Optional[RequestOptions]
|
|
170
|
+
Request-specific configuration.
|
|
171
|
+
|
|
172
|
+
Returns
|
|
173
|
+
-------
|
|
174
|
+
SubscriptionResource
|
|
175
|
+
Successful Response
|
|
176
|
+
|
|
177
|
+
Examples
|
|
178
|
+
--------
|
|
179
|
+
from lark import Lark
|
|
180
|
+
|
|
181
|
+
client = Lark(
|
|
182
|
+
api_key="YOUR_API_KEY",
|
|
183
|
+
)
|
|
184
|
+
client.subscriptions.cancel_subscription(
|
|
185
|
+
subscription_id="subscription_id",
|
|
186
|
+
)
|
|
187
|
+
"""
|
|
188
|
+
_response = self._raw_client.cancel_subscription(
|
|
189
|
+
subscription_id,
|
|
190
|
+
reason=reason,
|
|
191
|
+
cancel_at_end_of_cycle=cancel_at_end_of_cycle,
|
|
192
|
+
request_options=request_options,
|
|
193
|
+
)
|
|
194
|
+
return _response.data
|
|
195
|
+
|
|
196
|
+
def change_subscription_rate_card(
|
|
197
|
+
self, subscription_id: str, *, rate_card_id: str, request_options: typing.Optional[RequestOptions] = None
|
|
198
|
+
) -> SubscriptionResource:
|
|
199
|
+
"""
|
|
200
|
+
Parameters
|
|
201
|
+
----------
|
|
202
|
+
subscription_id : str
|
|
203
|
+
|
|
204
|
+
rate_card_id : str
|
|
205
|
+
The ID of the rate card to change the subscription to.
|
|
206
|
+
|
|
207
|
+
request_options : typing.Optional[RequestOptions]
|
|
208
|
+
Request-specific configuration.
|
|
209
|
+
|
|
210
|
+
Returns
|
|
211
|
+
-------
|
|
212
|
+
SubscriptionResource
|
|
213
|
+
Successful Response
|
|
214
|
+
|
|
215
|
+
Examples
|
|
216
|
+
--------
|
|
217
|
+
from lark import Lark
|
|
218
|
+
|
|
219
|
+
client = Lark(
|
|
220
|
+
api_key="YOUR_API_KEY",
|
|
221
|
+
)
|
|
222
|
+
client.subscriptions.change_subscription_rate_card(
|
|
223
|
+
subscription_id="subscription_id",
|
|
224
|
+
rate_card_id="rc_jQK2n0wutCj6bBcAIrL6o07g",
|
|
225
|
+
)
|
|
226
|
+
"""
|
|
227
|
+
_response = self._raw_client.change_subscription_rate_card(
|
|
228
|
+
subscription_id, rate_card_id=rate_card_id, request_options=request_options
|
|
229
|
+
)
|
|
230
|
+
return _response.data
|
|
231
|
+
|
|
147
232
|
|
|
148
233
|
class AsyncSubscriptionsClient:
|
|
149
234
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
@@ -218,17 +303,20 @@ class AsyncSubscriptionsClient:
|
|
|
218
303
|
*,
|
|
219
304
|
rate_card_id: str,
|
|
220
305
|
subject_id: str,
|
|
221
|
-
metadata: typing.Optional[typing.Dict[str,
|
|
306
|
+
metadata: typing.Optional[typing.Dict[str, str]] = OMIT,
|
|
222
307
|
request_options: typing.Optional[RequestOptions] = None,
|
|
223
308
|
) -> SubscriptionResource:
|
|
224
309
|
"""
|
|
225
310
|
Parameters
|
|
226
311
|
----------
|
|
227
312
|
rate_card_id : str
|
|
313
|
+
The ID of the rate card to use for the subscription.
|
|
228
314
|
|
|
229
315
|
subject_id : str
|
|
316
|
+
The ID of the subject to create the subscription for.
|
|
230
317
|
|
|
231
|
-
metadata : typing.Optional[typing.Dict[str,
|
|
318
|
+
metadata : typing.Optional[typing.Dict[str, str]]
|
|
319
|
+
Additional metadata about the subscription. You may use this to store any custom data about the subscription.
|
|
232
320
|
|
|
233
321
|
request_options : typing.Optional[RequestOptions]
|
|
234
322
|
Request-specific configuration.
|
|
@@ -251,8 +339,8 @@ class AsyncSubscriptionsClient:
|
|
|
251
339
|
|
|
252
340
|
async def main() -> None:
|
|
253
341
|
await client.subscriptions.create_subscription(
|
|
254
|
-
rate_card_id="
|
|
255
|
-
subject_id="
|
|
342
|
+
rate_card_id="rc_AJWMxR81jxoRlli6p13uf3JB",
|
|
343
|
+
subject_id="subj_VyX6Q96h5avMho8O7QWlKeXE",
|
|
256
344
|
)
|
|
257
345
|
|
|
258
346
|
|
|
@@ -300,3 +388,101 @@ class AsyncSubscriptionsClient:
|
|
|
300
388
|
"""
|
|
301
389
|
_response = await self._raw_client.get_subscription(subscription_id, request_options=request_options)
|
|
302
390
|
return _response.data
|
|
391
|
+
|
|
392
|
+
async def cancel_subscription(
|
|
393
|
+
self,
|
|
394
|
+
subscription_id: str,
|
|
395
|
+
*,
|
|
396
|
+
reason: typing.Optional[str] = OMIT,
|
|
397
|
+
cancel_at_end_of_cycle: typing.Optional[bool] = OMIT,
|
|
398
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
399
|
+
) -> SubscriptionResource:
|
|
400
|
+
"""
|
|
401
|
+
Parameters
|
|
402
|
+
----------
|
|
403
|
+
subscription_id : str
|
|
404
|
+
|
|
405
|
+
reason : typing.Optional[str]
|
|
406
|
+
The reason for cancelling the subscription.
|
|
407
|
+
|
|
408
|
+
cancel_at_end_of_cycle : typing.Optional[bool]
|
|
409
|
+
Whether to cancel the subscription at end of cycle.
|
|
410
|
+
|
|
411
|
+
request_options : typing.Optional[RequestOptions]
|
|
412
|
+
Request-specific configuration.
|
|
413
|
+
|
|
414
|
+
Returns
|
|
415
|
+
-------
|
|
416
|
+
SubscriptionResource
|
|
417
|
+
Successful Response
|
|
418
|
+
|
|
419
|
+
Examples
|
|
420
|
+
--------
|
|
421
|
+
import asyncio
|
|
422
|
+
|
|
423
|
+
from lark import AsyncLark
|
|
424
|
+
|
|
425
|
+
client = AsyncLark(
|
|
426
|
+
api_key="YOUR_API_KEY",
|
|
427
|
+
)
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
async def main() -> None:
|
|
431
|
+
await client.subscriptions.cancel_subscription(
|
|
432
|
+
subscription_id="subscription_id",
|
|
433
|
+
)
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
asyncio.run(main())
|
|
437
|
+
"""
|
|
438
|
+
_response = await self._raw_client.cancel_subscription(
|
|
439
|
+
subscription_id,
|
|
440
|
+
reason=reason,
|
|
441
|
+
cancel_at_end_of_cycle=cancel_at_end_of_cycle,
|
|
442
|
+
request_options=request_options,
|
|
443
|
+
)
|
|
444
|
+
return _response.data
|
|
445
|
+
|
|
446
|
+
async def change_subscription_rate_card(
|
|
447
|
+
self, subscription_id: str, *, rate_card_id: str, request_options: typing.Optional[RequestOptions] = None
|
|
448
|
+
) -> SubscriptionResource:
|
|
449
|
+
"""
|
|
450
|
+
Parameters
|
|
451
|
+
----------
|
|
452
|
+
subscription_id : str
|
|
453
|
+
|
|
454
|
+
rate_card_id : str
|
|
455
|
+
The ID of the rate card to change the subscription to.
|
|
456
|
+
|
|
457
|
+
request_options : typing.Optional[RequestOptions]
|
|
458
|
+
Request-specific configuration.
|
|
459
|
+
|
|
460
|
+
Returns
|
|
461
|
+
-------
|
|
462
|
+
SubscriptionResource
|
|
463
|
+
Successful Response
|
|
464
|
+
|
|
465
|
+
Examples
|
|
466
|
+
--------
|
|
467
|
+
import asyncio
|
|
468
|
+
|
|
469
|
+
from lark import AsyncLark
|
|
470
|
+
|
|
471
|
+
client = AsyncLark(
|
|
472
|
+
api_key="YOUR_API_KEY",
|
|
473
|
+
)
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
async def main() -> None:
|
|
477
|
+
await client.subscriptions.change_subscription_rate_card(
|
|
478
|
+
subscription_id="subscription_id",
|
|
479
|
+
rate_card_id="rc_jQK2n0wutCj6bBcAIrL6o07g",
|
|
480
|
+
)
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
asyncio.run(main())
|
|
484
|
+
"""
|
|
485
|
+
_response = await self._raw_client.change_subscription_rate_card(
|
|
486
|
+
subscription_id, rate_card_id=rate_card_id, request_options=request_options
|
|
487
|
+
)
|
|
488
|
+
return _response.data
|
lark/subscriptions/raw_client.py
CHANGED
|
@@ -90,17 +90,20 @@ class RawSubscriptionsClient:
|
|
|
90
90
|
*,
|
|
91
91
|
rate_card_id: str,
|
|
92
92
|
subject_id: str,
|
|
93
|
-
metadata: typing.Optional[typing.Dict[str,
|
|
93
|
+
metadata: typing.Optional[typing.Dict[str, str]] = OMIT,
|
|
94
94
|
request_options: typing.Optional[RequestOptions] = None,
|
|
95
95
|
) -> HttpResponse[SubscriptionResource]:
|
|
96
96
|
"""
|
|
97
97
|
Parameters
|
|
98
98
|
----------
|
|
99
99
|
rate_card_id : str
|
|
100
|
+
The ID of the rate card to use for the subscription.
|
|
100
101
|
|
|
101
102
|
subject_id : str
|
|
103
|
+
The ID of the subject to create the subscription for.
|
|
102
104
|
|
|
103
|
-
metadata : typing.Optional[typing.Dict[str,
|
|
105
|
+
metadata : typing.Optional[typing.Dict[str, str]]
|
|
106
|
+
Additional metadata about the subscription. You may use this to store any custom data about the subscription.
|
|
104
107
|
|
|
105
108
|
request_options : typing.Optional[RequestOptions]
|
|
106
109
|
Request-specific configuration.
|
|
@@ -197,6 +200,129 @@ class RawSubscriptionsClient:
|
|
|
197
200
|
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
198
201
|
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
199
202
|
|
|
203
|
+
def cancel_subscription(
|
|
204
|
+
self,
|
|
205
|
+
subscription_id: str,
|
|
206
|
+
*,
|
|
207
|
+
reason: typing.Optional[str] = OMIT,
|
|
208
|
+
cancel_at_end_of_cycle: typing.Optional[bool] = OMIT,
|
|
209
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
210
|
+
) -> HttpResponse[SubscriptionResource]:
|
|
211
|
+
"""
|
|
212
|
+
Parameters
|
|
213
|
+
----------
|
|
214
|
+
subscription_id : str
|
|
215
|
+
|
|
216
|
+
reason : typing.Optional[str]
|
|
217
|
+
The reason for cancelling the subscription.
|
|
218
|
+
|
|
219
|
+
cancel_at_end_of_cycle : typing.Optional[bool]
|
|
220
|
+
Whether to cancel the subscription at end of cycle.
|
|
221
|
+
|
|
222
|
+
request_options : typing.Optional[RequestOptions]
|
|
223
|
+
Request-specific configuration.
|
|
224
|
+
|
|
225
|
+
Returns
|
|
226
|
+
-------
|
|
227
|
+
HttpResponse[SubscriptionResource]
|
|
228
|
+
Successful Response
|
|
229
|
+
"""
|
|
230
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
231
|
+
f"subscriptions/{jsonable_encoder(subscription_id)}/cancel",
|
|
232
|
+
method="POST",
|
|
233
|
+
json={
|
|
234
|
+
"reason": reason,
|
|
235
|
+
"cancel_at_end_of_cycle": cancel_at_end_of_cycle,
|
|
236
|
+
},
|
|
237
|
+
headers={
|
|
238
|
+
"content-type": "application/json",
|
|
239
|
+
},
|
|
240
|
+
request_options=request_options,
|
|
241
|
+
omit=OMIT,
|
|
242
|
+
)
|
|
243
|
+
try:
|
|
244
|
+
if 200 <= _response.status_code < 300:
|
|
245
|
+
_data = typing.cast(
|
|
246
|
+
SubscriptionResource,
|
|
247
|
+
parse_obj_as(
|
|
248
|
+
type_=SubscriptionResource, # type: ignore
|
|
249
|
+
object_=_response.json(),
|
|
250
|
+
),
|
|
251
|
+
)
|
|
252
|
+
return HttpResponse(response=_response, data=_data)
|
|
253
|
+
if _response.status_code == 422:
|
|
254
|
+
raise UnprocessableEntityError(
|
|
255
|
+
headers=dict(_response.headers),
|
|
256
|
+
body=typing.cast(
|
|
257
|
+
HttpValidationError,
|
|
258
|
+
parse_obj_as(
|
|
259
|
+
type_=HttpValidationError, # type: ignore
|
|
260
|
+
object_=_response.json(),
|
|
261
|
+
),
|
|
262
|
+
),
|
|
263
|
+
)
|
|
264
|
+
_response_json = _response.json()
|
|
265
|
+
except JSONDecodeError:
|
|
266
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
267
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
268
|
+
|
|
269
|
+
def change_subscription_rate_card(
|
|
270
|
+
self, subscription_id: str, *, rate_card_id: str, request_options: typing.Optional[RequestOptions] = None
|
|
271
|
+
) -> HttpResponse[SubscriptionResource]:
|
|
272
|
+
"""
|
|
273
|
+
Parameters
|
|
274
|
+
----------
|
|
275
|
+
subscription_id : str
|
|
276
|
+
|
|
277
|
+
rate_card_id : str
|
|
278
|
+
The ID of the rate card to change the subscription to.
|
|
279
|
+
|
|
280
|
+
request_options : typing.Optional[RequestOptions]
|
|
281
|
+
Request-specific configuration.
|
|
282
|
+
|
|
283
|
+
Returns
|
|
284
|
+
-------
|
|
285
|
+
HttpResponse[SubscriptionResource]
|
|
286
|
+
Successful Response
|
|
287
|
+
"""
|
|
288
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
289
|
+
f"subscriptions/{jsonable_encoder(subscription_id)}/change-rate-card",
|
|
290
|
+
method="POST",
|
|
291
|
+
json={
|
|
292
|
+
"rate_card_id": rate_card_id,
|
|
293
|
+
},
|
|
294
|
+
headers={
|
|
295
|
+
"content-type": "application/json",
|
|
296
|
+
},
|
|
297
|
+
request_options=request_options,
|
|
298
|
+
omit=OMIT,
|
|
299
|
+
)
|
|
300
|
+
try:
|
|
301
|
+
if 200 <= _response.status_code < 300:
|
|
302
|
+
_data = typing.cast(
|
|
303
|
+
SubscriptionResource,
|
|
304
|
+
parse_obj_as(
|
|
305
|
+
type_=SubscriptionResource, # type: ignore
|
|
306
|
+
object_=_response.json(),
|
|
307
|
+
),
|
|
308
|
+
)
|
|
309
|
+
return HttpResponse(response=_response, data=_data)
|
|
310
|
+
if _response.status_code == 422:
|
|
311
|
+
raise UnprocessableEntityError(
|
|
312
|
+
headers=dict(_response.headers),
|
|
313
|
+
body=typing.cast(
|
|
314
|
+
HttpValidationError,
|
|
315
|
+
parse_obj_as(
|
|
316
|
+
type_=HttpValidationError, # type: ignore
|
|
317
|
+
object_=_response.json(),
|
|
318
|
+
),
|
|
319
|
+
),
|
|
320
|
+
)
|
|
321
|
+
_response_json = _response.json()
|
|
322
|
+
except JSONDecodeError:
|
|
323
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
324
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
325
|
+
|
|
200
326
|
|
|
201
327
|
class AsyncRawSubscriptionsClient:
|
|
202
328
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
@@ -270,17 +396,20 @@ class AsyncRawSubscriptionsClient:
|
|
|
270
396
|
*,
|
|
271
397
|
rate_card_id: str,
|
|
272
398
|
subject_id: str,
|
|
273
|
-
metadata: typing.Optional[typing.Dict[str,
|
|
399
|
+
metadata: typing.Optional[typing.Dict[str, str]] = OMIT,
|
|
274
400
|
request_options: typing.Optional[RequestOptions] = None,
|
|
275
401
|
) -> AsyncHttpResponse[SubscriptionResource]:
|
|
276
402
|
"""
|
|
277
403
|
Parameters
|
|
278
404
|
----------
|
|
279
405
|
rate_card_id : str
|
|
406
|
+
The ID of the rate card to use for the subscription.
|
|
280
407
|
|
|
281
408
|
subject_id : str
|
|
409
|
+
The ID of the subject to create the subscription for.
|
|
282
410
|
|
|
283
|
-
metadata : typing.Optional[typing.Dict[str,
|
|
411
|
+
metadata : typing.Optional[typing.Dict[str, str]]
|
|
412
|
+
Additional metadata about the subscription. You may use this to store any custom data about the subscription.
|
|
284
413
|
|
|
285
414
|
request_options : typing.Optional[RequestOptions]
|
|
286
415
|
Request-specific configuration.
|
|
@@ -376,3 +505,126 @@ class AsyncRawSubscriptionsClient:
|
|
|
376
505
|
except JSONDecodeError:
|
|
377
506
|
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
378
507
|
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
508
|
+
|
|
509
|
+
async def cancel_subscription(
|
|
510
|
+
self,
|
|
511
|
+
subscription_id: str,
|
|
512
|
+
*,
|
|
513
|
+
reason: typing.Optional[str] = OMIT,
|
|
514
|
+
cancel_at_end_of_cycle: typing.Optional[bool] = OMIT,
|
|
515
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
516
|
+
) -> AsyncHttpResponse[SubscriptionResource]:
|
|
517
|
+
"""
|
|
518
|
+
Parameters
|
|
519
|
+
----------
|
|
520
|
+
subscription_id : str
|
|
521
|
+
|
|
522
|
+
reason : typing.Optional[str]
|
|
523
|
+
The reason for cancelling the subscription.
|
|
524
|
+
|
|
525
|
+
cancel_at_end_of_cycle : typing.Optional[bool]
|
|
526
|
+
Whether to cancel the subscription at end of cycle.
|
|
527
|
+
|
|
528
|
+
request_options : typing.Optional[RequestOptions]
|
|
529
|
+
Request-specific configuration.
|
|
530
|
+
|
|
531
|
+
Returns
|
|
532
|
+
-------
|
|
533
|
+
AsyncHttpResponse[SubscriptionResource]
|
|
534
|
+
Successful Response
|
|
535
|
+
"""
|
|
536
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
537
|
+
f"subscriptions/{jsonable_encoder(subscription_id)}/cancel",
|
|
538
|
+
method="POST",
|
|
539
|
+
json={
|
|
540
|
+
"reason": reason,
|
|
541
|
+
"cancel_at_end_of_cycle": cancel_at_end_of_cycle,
|
|
542
|
+
},
|
|
543
|
+
headers={
|
|
544
|
+
"content-type": "application/json",
|
|
545
|
+
},
|
|
546
|
+
request_options=request_options,
|
|
547
|
+
omit=OMIT,
|
|
548
|
+
)
|
|
549
|
+
try:
|
|
550
|
+
if 200 <= _response.status_code < 300:
|
|
551
|
+
_data = typing.cast(
|
|
552
|
+
SubscriptionResource,
|
|
553
|
+
parse_obj_as(
|
|
554
|
+
type_=SubscriptionResource, # type: ignore
|
|
555
|
+
object_=_response.json(),
|
|
556
|
+
),
|
|
557
|
+
)
|
|
558
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
559
|
+
if _response.status_code == 422:
|
|
560
|
+
raise UnprocessableEntityError(
|
|
561
|
+
headers=dict(_response.headers),
|
|
562
|
+
body=typing.cast(
|
|
563
|
+
HttpValidationError,
|
|
564
|
+
parse_obj_as(
|
|
565
|
+
type_=HttpValidationError, # type: ignore
|
|
566
|
+
object_=_response.json(),
|
|
567
|
+
),
|
|
568
|
+
),
|
|
569
|
+
)
|
|
570
|
+
_response_json = _response.json()
|
|
571
|
+
except JSONDecodeError:
|
|
572
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
573
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
574
|
+
|
|
575
|
+
async def change_subscription_rate_card(
|
|
576
|
+
self, subscription_id: str, *, rate_card_id: str, request_options: typing.Optional[RequestOptions] = None
|
|
577
|
+
) -> AsyncHttpResponse[SubscriptionResource]:
|
|
578
|
+
"""
|
|
579
|
+
Parameters
|
|
580
|
+
----------
|
|
581
|
+
subscription_id : str
|
|
582
|
+
|
|
583
|
+
rate_card_id : str
|
|
584
|
+
The ID of the rate card to change the subscription to.
|
|
585
|
+
|
|
586
|
+
request_options : typing.Optional[RequestOptions]
|
|
587
|
+
Request-specific configuration.
|
|
588
|
+
|
|
589
|
+
Returns
|
|
590
|
+
-------
|
|
591
|
+
AsyncHttpResponse[SubscriptionResource]
|
|
592
|
+
Successful Response
|
|
593
|
+
"""
|
|
594
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
595
|
+
f"subscriptions/{jsonable_encoder(subscription_id)}/change-rate-card",
|
|
596
|
+
method="POST",
|
|
597
|
+
json={
|
|
598
|
+
"rate_card_id": rate_card_id,
|
|
599
|
+
},
|
|
600
|
+
headers={
|
|
601
|
+
"content-type": "application/json",
|
|
602
|
+
},
|
|
603
|
+
request_options=request_options,
|
|
604
|
+
omit=OMIT,
|
|
605
|
+
)
|
|
606
|
+
try:
|
|
607
|
+
if 200 <= _response.status_code < 300:
|
|
608
|
+
_data = typing.cast(
|
|
609
|
+
SubscriptionResource,
|
|
610
|
+
parse_obj_as(
|
|
611
|
+
type_=SubscriptionResource, # type: ignore
|
|
612
|
+
object_=_response.json(),
|
|
613
|
+
),
|
|
614
|
+
)
|
|
615
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
616
|
+
if _response.status_code == 422:
|
|
617
|
+
raise UnprocessableEntityError(
|
|
618
|
+
headers=dict(_response.headers),
|
|
619
|
+
body=typing.cast(
|
|
620
|
+
HttpValidationError,
|
|
621
|
+
parse_obj_as(
|
|
622
|
+
type_=HttpValidationError, # type: ignore
|
|
623
|
+
object_=_response.json(),
|
|
624
|
+
),
|
|
625
|
+
),
|
|
626
|
+
)
|
|
627
|
+
_response_json = _response.json()
|
|
628
|
+
except JSONDecodeError:
|
|
629
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
630
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|