lark-billing 0.0.6__py3-none-any.whl → 0.0.8__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 +92 -369
- lark/checkout/client.py +20 -79
- lark/checkout/raw_client.py +18 -102
- lark/client.py +112 -27
- 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/{types/credit_grant.py → core/http_sse/_exceptions.py} +4 -2
- lark/core/http_sse/_models.py +17 -0
- lark/core/pydantic_utilities.py +3 -1
- lark/{feature_access → customer_access}/client.py +30 -24
- lark/{feature_access → customer_access}/raw_client.py +22 -17
- lark/{types/rate_card.py → customer_portal/__init__.py} +1 -2
- lark/customer_portal/client.py +115 -0
- lark/customer_portal/raw_client.py +134 -0
- lark/environment.py +7 -0
- lark/{types/dimension.py → invoices/__init__.py} +1 -2
- lark/invoices/client.py +136 -0
- lark/invoices/raw_client.py +147 -0
- lark/pricing_metrics/__init__.py +38 -0
- lark/pricing_metrics/client.py +288 -0
- lark/pricing_metrics/raw_client.py +369 -0
- lark/pricing_metrics/types/__init__.py +42 -0
- lark/{types/credit_grant_resource_input_schedule.py → pricing_metrics/types/pricing_metric_aggregation.py} +7 -8
- lark/rate_cards/__init__.py +0 -15
- lark/rate_cards/client.py +30 -542
- lark/rate_cards/raw_client.py +34 -370
- lark/rate_cards/types/__init__.py +0 -17
- lark/rate_cards/types/create_rate_card_request_usage_based_rates_item.py +3 -29
- lark/subjects/client.py +18 -54
- lark/subjects/raw_client.py +14 -24
- lark/subscriptions/client.py +104 -80
- lark/subscriptions/raw_client.py +186 -53
- lark/types/__init__.py +63 -379
- lark/types/aggregation.py +1 -43
- lark/types/amount.py +5 -1
- lark/types/{credit_grant_date_time_expiration_interface.py → billing_state_response.py} +3 -2
- lark/types/{credit_grant_schedule_one_time_resource.py → count_aggregation_pricing_metric_resource.py} +1 -1
- lark/types/{create_dimension_interface.py → create_customer_portal_session_response.py} +3 -3
- lark/types/{create_dimension_coordinate_interface.py → create_fixed_rate_request.py} +5 -3
- lark/types/{pricing_metric_interface.py → create_pricing_metric_response.py} +2 -5
- lark/types/{create_simple_usage_based_rate_interface.py → create_simple_usage_based_rate_request.py} +6 -9
- lark/types/create_subject_response.py +30 -6
- lark/types/create_subscription_checkout_session_response.py +1 -2
- lark/types/create_usage_event_summary_response.py +1 -1
- lark/types/fixed_rate_interface.py +0 -6
- lark/types/{create_pricing_metric_interface.py → get_pricing_metric_response.py} +3 -5
- lark/types/{complete_subscription_checkout_response.py → invoice_line_item_resource.py} +4 -2
- lark/types/invoice_resource.py +31 -0
- lark/types/invoice_status.py +5 -0
- lark/types/{check_feature_access_response.py → list_invoices_response.py} +4 -4
- lark/types/{check_feature_access_request.py → list_pricing_metrics_response.py} +4 -7
- lark/types/package_price.py +2 -2
- lark/types/package_price_input_rounding_behavior.py +5 -0
- lark/types/package_price_output_rounding_behavior.py +5 -0
- lark/types/period_resource.py +23 -0
- lark/types/price.py +39 -1
- lark/types/pricing_metric_resource.py +24 -0
- lark/types/rate_card_resource.py +0 -6
- lark/types/rate_card_resource_usage_based_rates_item.py +2 -29
- lark/types/simple_usage_based_rate_interface.py +1 -7
- lark/types/subject_resource.py +30 -6
- lark/types/subscription_resource.py +6 -4
- lark/types/subscription_status.py +5 -0
- lark/types/{credit_grant_date_time_expiration_resource.py → sum_aggregation_pricing_metric_resource.py} +2 -2
- lark/types/{subject.py → value.py} +1 -1
- lark/usage_events/client.py +8 -21
- lark/usage_events/raw_client.py +6 -6
- {lark_billing-0.0.6.dist-info → lark_billing-0.0.8.dist-info}/METADATA +4 -3
- lark_billing-0.0.8.dist-info/RECORD +107 -0
- lark/rate_cards/types/create_rate_card_version_request_usage_based_rates_item.py +0 -58
- lark/rate_cards/types/create_rate_card_version_request_version_type.py +0 -5
- lark/types/create_credit_grant_interface.py +0 -27
- lark/types/create_credit_grant_interface_expiration.py +0 -27
- lark/types/create_credit_pool_request.py +0 -5
- lark/types/create_dimensional_usage_based_rate_interface.py +0 -32
- lark/types/create_fixed_rate_interface.py +0 -28
- lark/types/create_pricing_matrix_cell_interface.py +0 -22
- lark/types/create_pricing_matrix_interface.py +0 -20
- lark/types/create_pricing_plan_request.py +0 -5
- lark/types/create_rate_card_response.py +0 -36
- lark/types/create_rate_card_response_billing_interval.py +0 -5
- lark/types/create_rate_card_response_usage_based_rates_item.py +0 -58
- lark/types/create_rate_card_version_response.py +0 -36
- lark/types/create_rate_card_version_response_billing_interval.py +0 -5
- lark/types/create_rate_card_version_response_usage_based_rates_item.py +0 -59
- lark/types/credit_grant_duration_expiration_interface.py +0 -21
- lark/types/credit_grant_duration_expiration_resource.py +0 -21
- lark/types/credit_grant_interface.py +0 -28
- lark/types/credit_grant_interface_input_expiration.py +0 -27
- lark/types/credit_grant_interface_output_expiration.py +0 -43
- lark/types/credit_grant_interface_output_schedule.py +0 -41
- lark/types/credit_grant_resource.py +0 -28
- lark/types/credit_grant_resource_input_expiration.py +0 -27
- lark/types/credit_grant_resource_output_expiration.py +0 -43
- lark/types/credit_grant_resource_output_schedule.py +0 -39
- lark/types/credit_grant_schedule.py +0 -5
- lark/types/credit_grant_schedule_one_time_interface.py +0 -19
- lark/types/credit_grant_schedule_rate_cycle_start_interface.py +0 -19
- lark/types/credit_grant_schedule_rate_cycle_start_resource.py +0 -17
- lark/types/credit_grant_subject_granting_config_interface.py +0 -20
- lark/types/credit_pool.py +0 -5
- lark/types/credit_pool_rollover_config.py +0 -5
- lark/types/custom_aggregation_pricing_metric_interface.py +0 -22
- lark/types/custom_pricing_metric.py +0 -5
- lark/types/custom_unit.py +0 -5
- lark/types/custom_unit_amount.py +0 -5
- lark/types/dimension_coordinate.py +0 -5
- lark/types/dimension_coordinate_interface.py +0 -20
- lark/types/dimension_coordinate_set.py +0 -5
- lark/types/dimension_interface.py +0 -20
- lark/types/dimensional_rate_matrix.py +0 -5
- lark/types/dimensional_rate_matrix_cell.py +0 -5
- lark/types/dimensional_usage_based_rate.py +0 -5
- lark/types/dimensional_usage_based_rate_input.py +0 -5
- lark/types/dimensional_usage_based_rate_interface.py +0 -33
- lark/types/feature_access_resource.py +0 -21
- lark/types/get_rate_card_response.py +0 -36
- lark/types/get_rate_card_response_billing_interval.py +0 -5
- lark/types/get_rate_card_response_usage_based_rates_item.py +0 -58
- lark/types/grant_credits_request.py +0 -5
- lark/types/last_aggregation_pricing_metric_interface.py +0 -22
- lark/types/license_based_rate.py +0 -5
- lark/types/license_based_rate_input.py +0 -5
- lark/types/max_aggregation_pricing_metric_interface.py +0 -22
- lark/types/monetary_amount.py +0 -5
- lark/types/package_price_rounding_behavior.py +0 -5
- lark/types/package_price_wrapper.py +0 -5
- lark/types/pricing_matrix_cell_interface.py +0 -22
- lark/types/pricing_matrix_interface.py +0 -20
- lark/types/pricing_metric.py +0 -5
- lark/types/pricing_plan.py +0 -5
- lark/types/pricing_plan_subscription.py +0 -5
- lark/types/pricing_tier.py +0 -5
- lark/types/rate_card_version.py +0 -5
- lark/types/rate_card_version_input.py +0 -5
- lark/types/simple_usage_based_rate.py +0 -5
- lark/types/simple_usage_based_rate_input.py +0 -5
- lark/types/status.py +0 -5
- lark/types/subject_granting_config.py +0 -5
- lark/types/subject_granting_config_resource.py +0 -20
- lark/types/tiered_price.py +0 -5
- lark/types/tiered_price_wrapper.py +0 -5
- lark/types/unit.py +0 -5
- lark/types/update_pricing_plan_request.py +0 -5
- lark/types/update_rate_card_request.py +0 -5
- lark/types/update_subscription_request.py +0 -5
- lark/types/usage_based_rate.py +0 -5
- lark/types/usage_based_rate_input.py +0 -5
- lark/types/usage_unit.py +0 -5
- lark_billing-0.0.6.dist-info/RECORD +0 -167
- /lark/{feature_access → customer_access}/__init__.py +0 -0
- {lark_billing-0.0.6.dist-info → lark_billing-0.0.8.dist-info}/WHEEL +0 -0
lark/checkout/client.py
CHANGED
|
@@ -4,7 +4,6 @@ import typing
|
|
|
4
4
|
|
|
5
5
|
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
6
6
|
from ..core.request_options import RequestOptions
|
|
7
|
-
from ..types.complete_subscription_checkout_response import CompleteSubscriptionCheckoutResponse
|
|
8
7
|
from ..types.create_subscription_checkout_session_response import CreateSubscriptionCheckoutSessionResponse
|
|
9
8
|
from .raw_client import AsyncRawCheckoutClient, RawCheckoutClient
|
|
10
9
|
|
|
@@ -32,7 +31,8 @@ class CheckoutClient:
|
|
|
32
31
|
*,
|
|
33
32
|
subject_id: str,
|
|
34
33
|
rate_card_id: str,
|
|
35
|
-
|
|
34
|
+
success_callback_url: str,
|
|
35
|
+
cancel_url: typing.Optional[str] = OMIT,
|
|
36
36
|
request_options: typing.Optional[RequestOptions] = None,
|
|
37
37
|
) -> CreateSubscriptionCheckoutSessionResponse:
|
|
38
38
|
"""
|
|
@@ -42,7 +42,11 @@ class CheckoutClient:
|
|
|
42
42
|
|
|
43
43
|
rate_card_id : str
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
success_callback_url : str
|
|
46
|
+
The URL to redirect to after the checkout is successful.
|
|
47
|
+
|
|
48
|
+
cancel_url : typing.Optional[str]
|
|
49
|
+
The URL to redirect to after the checkout is cancelled.
|
|
46
50
|
|
|
47
51
|
request_options : typing.Optional[RequestOptions]
|
|
48
52
|
Request-specific configuration.
|
|
@@ -58,52 +62,22 @@ class CheckoutClient:
|
|
|
58
62
|
|
|
59
63
|
client = Lark(
|
|
60
64
|
api_key="YOUR_API_KEY",
|
|
61
|
-
base_url="https://yourhost.com/path/to/api",
|
|
62
65
|
)
|
|
63
66
|
client.checkout.create_subscription_checkout_session(
|
|
64
67
|
subject_id="subject_id",
|
|
65
68
|
rate_card_id="rate_card_id",
|
|
69
|
+
success_callback_url="https://example.com/callback",
|
|
66
70
|
)
|
|
67
71
|
"""
|
|
68
72
|
_response = self._raw_client.create_subscription_checkout_session(
|
|
69
73
|
subject_id=subject_id,
|
|
70
74
|
rate_card_id=rate_card_id,
|
|
71
|
-
|
|
75
|
+
success_callback_url=success_callback_url,
|
|
76
|
+
cancel_url=cancel_url,
|
|
72
77
|
request_options=request_options,
|
|
73
78
|
)
|
|
74
79
|
return _response.data
|
|
75
80
|
|
|
76
|
-
def complete_subscription_checkout(
|
|
77
|
-
self, checkout_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
78
|
-
) -> CompleteSubscriptionCheckoutResponse:
|
|
79
|
-
"""
|
|
80
|
-
Parameters
|
|
81
|
-
----------
|
|
82
|
-
checkout_id : str
|
|
83
|
-
|
|
84
|
-
request_options : typing.Optional[RequestOptions]
|
|
85
|
-
Request-specific configuration.
|
|
86
|
-
|
|
87
|
-
Returns
|
|
88
|
-
-------
|
|
89
|
-
CompleteSubscriptionCheckoutResponse
|
|
90
|
-
Successful Response
|
|
91
|
-
|
|
92
|
-
Examples
|
|
93
|
-
--------
|
|
94
|
-
from lark import Lark
|
|
95
|
-
|
|
96
|
-
client = Lark(
|
|
97
|
-
api_key="YOUR_API_KEY",
|
|
98
|
-
base_url="https://yourhost.com/path/to/api",
|
|
99
|
-
)
|
|
100
|
-
client.checkout.complete_subscription_checkout(
|
|
101
|
-
checkout_id="checkout_id",
|
|
102
|
-
)
|
|
103
|
-
"""
|
|
104
|
-
_response = self._raw_client.complete_subscription_checkout(checkout_id, request_options=request_options)
|
|
105
|
-
return _response.data
|
|
106
|
-
|
|
107
81
|
|
|
108
82
|
class AsyncCheckoutClient:
|
|
109
83
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
@@ -125,7 +99,8 @@ class AsyncCheckoutClient:
|
|
|
125
99
|
*,
|
|
126
100
|
subject_id: str,
|
|
127
101
|
rate_card_id: str,
|
|
128
|
-
|
|
102
|
+
success_callback_url: str,
|
|
103
|
+
cancel_url: typing.Optional[str] = OMIT,
|
|
129
104
|
request_options: typing.Optional[RequestOptions] = None,
|
|
130
105
|
) -> CreateSubscriptionCheckoutSessionResponse:
|
|
131
106
|
"""
|
|
@@ -135,7 +110,11 @@ class AsyncCheckoutClient:
|
|
|
135
110
|
|
|
136
111
|
rate_card_id : str
|
|
137
112
|
|
|
138
|
-
|
|
113
|
+
success_callback_url : str
|
|
114
|
+
The URL to redirect to after the checkout is successful.
|
|
115
|
+
|
|
116
|
+
cancel_url : typing.Optional[str]
|
|
117
|
+
The URL to redirect to after the checkout is cancelled.
|
|
139
118
|
|
|
140
119
|
request_options : typing.Optional[RequestOptions]
|
|
141
120
|
Request-specific configuration.
|
|
@@ -153,7 +132,6 @@ class AsyncCheckoutClient:
|
|
|
153
132
|
|
|
154
133
|
client = AsyncLark(
|
|
155
134
|
api_key="YOUR_API_KEY",
|
|
156
|
-
base_url="https://yourhost.com/path/to/api",
|
|
157
135
|
)
|
|
158
136
|
|
|
159
137
|
|
|
@@ -161,6 +139,7 @@ class AsyncCheckoutClient:
|
|
|
161
139
|
await client.checkout.create_subscription_checkout_session(
|
|
162
140
|
subject_id="subject_id",
|
|
163
141
|
rate_card_id="rate_card_id",
|
|
142
|
+
success_callback_url="https://example.com/callback",
|
|
164
143
|
)
|
|
165
144
|
|
|
166
145
|
|
|
@@ -169,46 +148,8 @@ class AsyncCheckoutClient:
|
|
|
169
148
|
_response = await self._raw_client.create_subscription_checkout_session(
|
|
170
149
|
subject_id=subject_id,
|
|
171
150
|
rate_card_id=rate_card_id,
|
|
172
|
-
|
|
151
|
+
success_callback_url=success_callback_url,
|
|
152
|
+
cancel_url=cancel_url,
|
|
173
153
|
request_options=request_options,
|
|
174
154
|
)
|
|
175
155
|
return _response.data
|
|
176
|
-
|
|
177
|
-
async def complete_subscription_checkout(
|
|
178
|
-
self, checkout_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
179
|
-
) -> CompleteSubscriptionCheckoutResponse:
|
|
180
|
-
"""
|
|
181
|
-
Parameters
|
|
182
|
-
----------
|
|
183
|
-
checkout_id : str
|
|
184
|
-
|
|
185
|
-
request_options : typing.Optional[RequestOptions]
|
|
186
|
-
Request-specific configuration.
|
|
187
|
-
|
|
188
|
-
Returns
|
|
189
|
-
-------
|
|
190
|
-
CompleteSubscriptionCheckoutResponse
|
|
191
|
-
Successful Response
|
|
192
|
-
|
|
193
|
-
Examples
|
|
194
|
-
--------
|
|
195
|
-
import asyncio
|
|
196
|
-
|
|
197
|
-
from lark import AsyncLark
|
|
198
|
-
|
|
199
|
-
client = AsyncLark(
|
|
200
|
-
api_key="YOUR_API_KEY",
|
|
201
|
-
base_url="https://yourhost.com/path/to/api",
|
|
202
|
-
)
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
async def main() -> None:
|
|
206
|
-
await client.checkout.complete_subscription_checkout(
|
|
207
|
-
checkout_id="checkout_id",
|
|
208
|
-
)
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
asyncio.run(main())
|
|
212
|
-
"""
|
|
213
|
-
_response = await self._raw_client.complete_subscription_checkout(checkout_id, request_options=request_options)
|
|
214
|
-
return _response.data
|
lark/checkout/raw_client.py
CHANGED
|
@@ -6,11 +6,9 @@ from json.decoder import JSONDecodeError
|
|
|
6
6
|
from ..core.api_error import ApiError
|
|
7
7
|
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
8
8
|
from ..core.http_response import AsyncHttpResponse, HttpResponse
|
|
9
|
-
from ..core.jsonable_encoder import jsonable_encoder
|
|
10
9
|
from ..core.pydantic_utilities import parse_obj_as
|
|
11
10
|
from ..core.request_options import RequestOptions
|
|
12
11
|
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
|
13
|
-
from ..types.complete_subscription_checkout_response import CompleteSubscriptionCheckoutResponse
|
|
14
12
|
from ..types.create_subscription_checkout_session_response import CreateSubscriptionCheckoutSessionResponse
|
|
15
13
|
from ..types.http_validation_error import HttpValidationError
|
|
16
14
|
|
|
@@ -27,7 +25,8 @@ class RawCheckoutClient:
|
|
|
27
25
|
*,
|
|
28
26
|
subject_id: str,
|
|
29
27
|
rate_card_id: str,
|
|
30
|
-
|
|
28
|
+
success_callback_url: str,
|
|
29
|
+
cancel_url: typing.Optional[str] = OMIT,
|
|
31
30
|
request_options: typing.Optional[RequestOptions] = None,
|
|
32
31
|
) -> HttpResponse[CreateSubscriptionCheckoutSessionResponse]:
|
|
33
32
|
"""
|
|
@@ -37,7 +36,11 @@ class RawCheckoutClient:
|
|
|
37
36
|
|
|
38
37
|
rate_card_id : str
|
|
39
38
|
|
|
40
|
-
|
|
39
|
+
success_callback_url : str
|
|
40
|
+
The URL to redirect to after the checkout is successful.
|
|
41
|
+
|
|
42
|
+
cancel_url : typing.Optional[str]
|
|
43
|
+
The URL to redirect to after the checkout is cancelled.
|
|
41
44
|
|
|
42
45
|
request_options : typing.Optional[RequestOptions]
|
|
43
46
|
Request-specific configuration.
|
|
@@ -53,7 +56,8 @@ class RawCheckoutClient:
|
|
|
53
56
|
json={
|
|
54
57
|
"subject_id": subject_id,
|
|
55
58
|
"rate_card_id": rate_card_id,
|
|
56
|
-
"
|
|
59
|
+
"success_callback_url": success_callback_url,
|
|
60
|
+
"cancel_url": cancel_url,
|
|
57
61
|
},
|
|
58
62
|
headers={
|
|
59
63
|
"content-type": "application/json",
|
|
@@ -87,53 +91,6 @@ class RawCheckoutClient:
|
|
|
87
91
|
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
88
92
|
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
89
93
|
|
|
90
|
-
def complete_subscription_checkout(
|
|
91
|
-
self, checkout_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
92
|
-
) -> HttpResponse[CompleteSubscriptionCheckoutResponse]:
|
|
93
|
-
"""
|
|
94
|
-
Parameters
|
|
95
|
-
----------
|
|
96
|
-
checkout_id : str
|
|
97
|
-
|
|
98
|
-
request_options : typing.Optional[RequestOptions]
|
|
99
|
-
Request-specific configuration.
|
|
100
|
-
|
|
101
|
-
Returns
|
|
102
|
-
-------
|
|
103
|
-
HttpResponse[CompleteSubscriptionCheckoutResponse]
|
|
104
|
-
Successful Response
|
|
105
|
-
"""
|
|
106
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
107
|
-
f"checkout/{jsonable_encoder(checkout_id)}/complete",
|
|
108
|
-
method="POST",
|
|
109
|
-
request_options=request_options,
|
|
110
|
-
)
|
|
111
|
-
try:
|
|
112
|
-
if 200 <= _response.status_code < 300:
|
|
113
|
-
_data = typing.cast(
|
|
114
|
-
CompleteSubscriptionCheckoutResponse,
|
|
115
|
-
parse_obj_as(
|
|
116
|
-
type_=CompleteSubscriptionCheckoutResponse, # type: ignore
|
|
117
|
-
object_=_response.json(),
|
|
118
|
-
),
|
|
119
|
-
)
|
|
120
|
-
return HttpResponse(response=_response, data=_data)
|
|
121
|
-
if _response.status_code == 422:
|
|
122
|
-
raise UnprocessableEntityError(
|
|
123
|
-
headers=dict(_response.headers),
|
|
124
|
-
body=typing.cast(
|
|
125
|
-
HttpValidationError,
|
|
126
|
-
parse_obj_as(
|
|
127
|
-
type_=HttpValidationError, # type: ignore
|
|
128
|
-
object_=_response.json(),
|
|
129
|
-
),
|
|
130
|
-
),
|
|
131
|
-
)
|
|
132
|
-
_response_json = _response.json()
|
|
133
|
-
except JSONDecodeError:
|
|
134
|
-
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
135
|
-
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
136
|
-
|
|
137
94
|
|
|
138
95
|
class AsyncRawCheckoutClient:
|
|
139
96
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
@@ -144,7 +101,8 @@ class AsyncRawCheckoutClient:
|
|
|
144
101
|
*,
|
|
145
102
|
subject_id: str,
|
|
146
103
|
rate_card_id: str,
|
|
147
|
-
|
|
104
|
+
success_callback_url: str,
|
|
105
|
+
cancel_url: typing.Optional[str] = OMIT,
|
|
148
106
|
request_options: typing.Optional[RequestOptions] = None,
|
|
149
107
|
) -> AsyncHttpResponse[CreateSubscriptionCheckoutSessionResponse]:
|
|
150
108
|
"""
|
|
@@ -154,7 +112,11 @@ class AsyncRawCheckoutClient:
|
|
|
154
112
|
|
|
155
113
|
rate_card_id : str
|
|
156
114
|
|
|
157
|
-
|
|
115
|
+
success_callback_url : str
|
|
116
|
+
The URL to redirect to after the checkout is successful.
|
|
117
|
+
|
|
118
|
+
cancel_url : typing.Optional[str]
|
|
119
|
+
The URL to redirect to after the checkout is cancelled.
|
|
158
120
|
|
|
159
121
|
request_options : typing.Optional[RequestOptions]
|
|
160
122
|
Request-specific configuration.
|
|
@@ -170,7 +132,8 @@ class AsyncRawCheckoutClient:
|
|
|
170
132
|
json={
|
|
171
133
|
"subject_id": subject_id,
|
|
172
134
|
"rate_card_id": rate_card_id,
|
|
173
|
-
"
|
|
135
|
+
"success_callback_url": success_callback_url,
|
|
136
|
+
"cancel_url": cancel_url,
|
|
174
137
|
},
|
|
175
138
|
headers={
|
|
176
139
|
"content-type": "application/json",
|
|
@@ -203,50 +166,3 @@ class AsyncRawCheckoutClient:
|
|
|
203
166
|
except JSONDecodeError:
|
|
204
167
|
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
205
168
|
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
206
|
-
|
|
207
|
-
async def complete_subscription_checkout(
|
|
208
|
-
self, checkout_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
209
|
-
) -> AsyncHttpResponse[CompleteSubscriptionCheckoutResponse]:
|
|
210
|
-
"""
|
|
211
|
-
Parameters
|
|
212
|
-
----------
|
|
213
|
-
checkout_id : str
|
|
214
|
-
|
|
215
|
-
request_options : typing.Optional[RequestOptions]
|
|
216
|
-
Request-specific configuration.
|
|
217
|
-
|
|
218
|
-
Returns
|
|
219
|
-
-------
|
|
220
|
-
AsyncHttpResponse[CompleteSubscriptionCheckoutResponse]
|
|
221
|
-
Successful Response
|
|
222
|
-
"""
|
|
223
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
224
|
-
f"checkout/{jsonable_encoder(checkout_id)}/complete",
|
|
225
|
-
method="POST",
|
|
226
|
-
request_options=request_options,
|
|
227
|
-
)
|
|
228
|
-
try:
|
|
229
|
-
if 200 <= _response.status_code < 300:
|
|
230
|
-
_data = typing.cast(
|
|
231
|
-
CompleteSubscriptionCheckoutResponse,
|
|
232
|
-
parse_obj_as(
|
|
233
|
-
type_=CompleteSubscriptionCheckoutResponse, # type: ignore
|
|
234
|
-
object_=_response.json(),
|
|
235
|
-
),
|
|
236
|
-
)
|
|
237
|
-
return AsyncHttpResponse(response=_response, data=_data)
|
|
238
|
-
if _response.status_code == 422:
|
|
239
|
-
raise UnprocessableEntityError(
|
|
240
|
-
headers=dict(_response.headers),
|
|
241
|
-
body=typing.cast(
|
|
242
|
-
HttpValidationError,
|
|
243
|
-
parse_obj_as(
|
|
244
|
-
type_=HttpValidationError, # type: ignore
|
|
245
|
-
object_=_response.json(),
|
|
246
|
-
),
|
|
247
|
-
),
|
|
248
|
-
)
|
|
249
|
-
_response_json = _response.json()
|
|
250
|
-
except JSONDecodeError:
|
|
251
|
-
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
252
|
-
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
lark/client.py
CHANGED
|
@@ -6,10 +6,14 @@ import typing
|
|
|
6
6
|
|
|
7
7
|
import httpx
|
|
8
8
|
from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
9
|
+
from .environment import LarkEnvironment
|
|
9
10
|
|
|
10
11
|
if typing.TYPE_CHECKING:
|
|
11
12
|
from .checkout.client import AsyncCheckoutClient, CheckoutClient
|
|
12
|
-
from .
|
|
13
|
+
from .customer_access.client import AsyncCustomerAccessClient, CustomerAccessClient
|
|
14
|
+
from .customer_portal.client import AsyncCustomerPortalClient, CustomerPortalClient
|
|
15
|
+
from .invoices.client import AsyncInvoicesClient, InvoicesClient
|
|
16
|
+
from .pricing_metrics.client import AsyncPricingMetricsClient, PricingMetricsClient
|
|
13
17
|
from .rate_cards.client import AsyncRateCardsClient, RateCardsClient
|
|
14
18
|
from .subjects.client import AsyncSubjectsClient, SubjectsClient
|
|
15
19
|
from .subscriptions.client import AsyncSubscriptionsClient, SubscriptionsClient
|
|
@@ -22,9 +26,18 @@ class Lark:
|
|
|
22
26
|
|
|
23
27
|
Parameters
|
|
24
28
|
----------
|
|
25
|
-
base_url : str
|
|
29
|
+
base_url : typing.Optional[str]
|
|
26
30
|
The base url to use for requests from the client.
|
|
27
31
|
|
|
32
|
+
environment : LarkEnvironment
|
|
33
|
+
The environment to use for requests from the client. from .environment import LarkEnvironment
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
Defaults to LarkEnvironment.DEFAULT
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
28
41
|
api_key : str
|
|
29
42
|
headers : typing.Optional[typing.Dict[str, str]]
|
|
30
43
|
Additional headers to send with every request.
|
|
@@ -44,14 +57,14 @@ class Lark:
|
|
|
44
57
|
|
|
45
58
|
client = Lark(
|
|
46
59
|
api_key="YOUR_API_KEY",
|
|
47
|
-
base_url="https://yourhost.com/path/to/api",
|
|
48
60
|
)
|
|
49
61
|
"""
|
|
50
62
|
|
|
51
63
|
def __init__(
|
|
52
64
|
self,
|
|
53
65
|
*,
|
|
54
|
-
base_url: str,
|
|
66
|
+
base_url: typing.Optional[str] = None,
|
|
67
|
+
environment: LarkEnvironment = LarkEnvironment.DEFAULT,
|
|
55
68
|
api_key: str,
|
|
56
69
|
headers: typing.Optional[typing.Dict[str, str]] = None,
|
|
57
70
|
timeout: typing.Optional[float] = None,
|
|
@@ -62,7 +75,7 @@ class Lark:
|
|
|
62
75
|
timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
|
|
63
76
|
)
|
|
64
77
|
self._client_wrapper = SyncClientWrapper(
|
|
65
|
-
base_url=base_url,
|
|
78
|
+
base_url=_get_base_url(base_url=base_url, environment=environment),
|
|
66
79
|
api_key=api_key,
|
|
67
80
|
headers=headers,
|
|
68
81
|
httpx_client=httpx_client
|
|
@@ -73,11 +86,14 @@ class Lark:
|
|
|
73
86
|
timeout=_defaulted_timeout,
|
|
74
87
|
)
|
|
75
88
|
self._checkout: typing.Optional[CheckoutClient] = None
|
|
89
|
+
self._customer_portal: typing.Optional[CustomerPortalClient] = None
|
|
76
90
|
self._rate_cards: typing.Optional[RateCardsClient] = None
|
|
77
91
|
self._usage_events: typing.Optional[UsageEventsClient] = None
|
|
78
92
|
self._subscriptions: typing.Optional[SubscriptionsClient] = None
|
|
79
|
-
self._feature_access: typing.Optional[FeatureAccessClient] = None
|
|
80
93
|
self._subjects: typing.Optional[SubjectsClient] = None
|
|
94
|
+
self._pricing_metrics: typing.Optional[PricingMetricsClient] = None
|
|
95
|
+
self._customer_access: typing.Optional[CustomerAccessClient] = None
|
|
96
|
+
self._invoices: typing.Optional[InvoicesClient] = None
|
|
81
97
|
|
|
82
98
|
@property
|
|
83
99
|
def checkout(self):
|
|
@@ -87,6 +103,14 @@ class Lark:
|
|
|
87
103
|
self._checkout = CheckoutClient(client_wrapper=self._client_wrapper)
|
|
88
104
|
return self._checkout
|
|
89
105
|
|
|
106
|
+
@property
|
|
107
|
+
def customer_portal(self):
|
|
108
|
+
if self._customer_portal is None:
|
|
109
|
+
from .customer_portal.client import CustomerPortalClient # noqa: E402
|
|
110
|
+
|
|
111
|
+
self._customer_portal = CustomerPortalClient(client_wrapper=self._client_wrapper)
|
|
112
|
+
return self._customer_portal
|
|
113
|
+
|
|
90
114
|
@property
|
|
91
115
|
def rate_cards(self):
|
|
92
116
|
if self._rate_cards is None:
|
|
@@ -111,14 +135,6 @@ class Lark:
|
|
|
111
135
|
self._subscriptions = SubscriptionsClient(client_wrapper=self._client_wrapper)
|
|
112
136
|
return self._subscriptions
|
|
113
137
|
|
|
114
|
-
@property
|
|
115
|
-
def feature_access(self):
|
|
116
|
-
if self._feature_access is None:
|
|
117
|
-
from .feature_access.client import FeatureAccessClient # noqa: E402
|
|
118
|
-
|
|
119
|
-
self._feature_access = FeatureAccessClient(client_wrapper=self._client_wrapper)
|
|
120
|
-
return self._feature_access
|
|
121
|
-
|
|
122
138
|
@property
|
|
123
139
|
def subjects(self):
|
|
124
140
|
if self._subjects is None:
|
|
@@ -127,6 +143,30 @@ class Lark:
|
|
|
127
143
|
self._subjects = SubjectsClient(client_wrapper=self._client_wrapper)
|
|
128
144
|
return self._subjects
|
|
129
145
|
|
|
146
|
+
@property
|
|
147
|
+
def pricing_metrics(self):
|
|
148
|
+
if self._pricing_metrics is None:
|
|
149
|
+
from .pricing_metrics.client import PricingMetricsClient # noqa: E402
|
|
150
|
+
|
|
151
|
+
self._pricing_metrics = PricingMetricsClient(client_wrapper=self._client_wrapper)
|
|
152
|
+
return self._pricing_metrics
|
|
153
|
+
|
|
154
|
+
@property
|
|
155
|
+
def customer_access(self):
|
|
156
|
+
if self._customer_access is None:
|
|
157
|
+
from .customer_access.client import CustomerAccessClient # noqa: E402
|
|
158
|
+
|
|
159
|
+
self._customer_access = CustomerAccessClient(client_wrapper=self._client_wrapper)
|
|
160
|
+
return self._customer_access
|
|
161
|
+
|
|
162
|
+
@property
|
|
163
|
+
def invoices(self):
|
|
164
|
+
if self._invoices is None:
|
|
165
|
+
from .invoices.client import InvoicesClient # noqa: E402
|
|
166
|
+
|
|
167
|
+
self._invoices = InvoicesClient(client_wrapper=self._client_wrapper)
|
|
168
|
+
return self._invoices
|
|
169
|
+
|
|
130
170
|
|
|
131
171
|
class AsyncLark:
|
|
132
172
|
"""
|
|
@@ -134,9 +174,18 @@ class AsyncLark:
|
|
|
134
174
|
|
|
135
175
|
Parameters
|
|
136
176
|
----------
|
|
137
|
-
base_url : str
|
|
177
|
+
base_url : typing.Optional[str]
|
|
138
178
|
The base url to use for requests from the client.
|
|
139
179
|
|
|
180
|
+
environment : LarkEnvironment
|
|
181
|
+
The environment to use for requests from the client. from .environment import LarkEnvironment
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
Defaults to LarkEnvironment.DEFAULT
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
140
189
|
api_key : str
|
|
141
190
|
headers : typing.Optional[typing.Dict[str, str]]
|
|
142
191
|
Additional headers to send with every request.
|
|
@@ -156,14 +205,14 @@ class AsyncLark:
|
|
|
156
205
|
|
|
157
206
|
client = AsyncLark(
|
|
158
207
|
api_key="YOUR_API_KEY",
|
|
159
|
-
base_url="https://yourhost.com/path/to/api",
|
|
160
208
|
)
|
|
161
209
|
"""
|
|
162
210
|
|
|
163
211
|
def __init__(
|
|
164
212
|
self,
|
|
165
213
|
*,
|
|
166
|
-
base_url: str,
|
|
214
|
+
base_url: typing.Optional[str] = None,
|
|
215
|
+
environment: LarkEnvironment = LarkEnvironment.DEFAULT,
|
|
167
216
|
api_key: str,
|
|
168
217
|
headers: typing.Optional[typing.Dict[str, str]] = None,
|
|
169
218
|
timeout: typing.Optional[float] = None,
|
|
@@ -174,7 +223,7 @@ class AsyncLark:
|
|
|
174
223
|
timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
|
|
175
224
|
)
|
|
176
225
|
self._client_wrapper = AsyncClientWrapper(
|
|
177
|
-
base_url=base_url,
|
|
226
|
+
base_url=_get_base_url(base_url=base_url, environment=environment),
|
|
178
227
|
api_key=api_key,
|
|
179
228
|
headers=headers,
|
|
180
229
|
httpx_client=httpx_client
|
|
@@ -185,11 +234,14 @@ class AsyncLark:
|
|
|
185
234
|
timeout=_defaulted_timeout,
|
|
186
235
|
)
|
|
187
236
|
self._checkout: typing.Optional[AsyncCheckoutClient] = None
|
|
237
|
+
self._customer_portal: typing.Optional[AsyncCustomerPortalClient] = None
|
|
188
238
|
self._rate_cards: typing.Optional[AsyncRateCardsClient] = None
|
|
189
239
|
self._usage_events: typing.Optional[AsyncUsageEventsClient] = None
|
|
190
240
|
self._subscriptions: typing.Optional[AsyncSubscriptionsClient] = None
|
|
191
|
-
self._feature_access: typing.Optional[AsyncFeatureAccessClient] = None
|
|
192
241
|
self._subjects: typing.Optional[AsyncSubjectsClient] = None
|
|
242
|
+
self._pricing_metrics: typing.Optional[AsyncPricingMetricsClient] = None
|
|
243
|
+
self._customer_access: typing.Optional[AsyncCustomerAccessClient] = None
|
|
244
|
+
self._invoices: typing.Optional[AsyncInvoicesClient] = None
|
|
193
245
|
|
|
194
246
|
@property
|
|
195
247
|
def checkout(self):
|
|
@@ -199,6 +251,14 @@ class AsyncLark:
|
|
|
199
251
|
self._checkout = AsyncCheckoutClient(client_wrapper=self._client_wrapper)
|
|
200
252
|
return self._checkout
|
|
201
253
|
|
|
254
|
+
@property
|
|
255
|
+
def customer_portal(self):
|
|
256
|
+
if self._customer_portal is None:
|
|
257
|
+
from .customer_portal.client import AsyncCustomerPortalClient # noqa: E402
|
|
258
|
+
|
|
259
|
+
self._customer_portal = AsyncCustomerPortalClient(client_wrapper=self._client_wrapper)
|
|
260
|
+
return self._customer_portal
|
|
261
|
+
|
|
202
262
|
@property
|
|
203
263
|
def rate_cards(self):
|
|
204
264
|
if self._rate_cards is None:
|
|
@@ -223,14 +283,6 @@ class AsyncLark:
|
|
|
223
283
|
self._subscriptions = AsyncSubscriptionsClient(client_wrapper=self._client_wrapper)
|
|
224
284
|
return self._subscriptions
|
|
225
285
|
|
|
226
|
-
@property
|
|
227
|
-
def feature_access(self):
|
|
228
|
-
if self._feature_access is None:
|
|
229
|
-
from .feature_access.client import AsyncFeatureAccessClient # noqa: E402
|
|
230
|
-
|
|
231
|
-
self._feature_access = AsyncFeatureAccessClient(client_wrapper=self._client_wrapper)
|
|
232
|
-
return self._feature_access
|
|
233
|
-
|
|
234
286
|
@property
|
|
235
287
|
def subjects(self):
|
|
236
288
|
if self._subjects is None:
|
|
@@ -238,3 +290,36 @@ class AsyncLark:
|
|
|
238
290
|
|
|
239
291
|
self._subjects = AsyncSubjectsClient(client_wrapper=self._client_wrapper)
|
|
240
292
|
return self._subjects
|
|
293
|
+
|
|
294
|
+
@property
|
|
295
|
+
def pricing_metrics(self):
|
|
296
|
+
if self._pricing_metrics is None:
|
|
297
|
+
from .pricing_metrics.client import AsyncPricingMetricsClient # noqa: E402
|
|
298
|
+
|
|
299
|
+
self._pricing_metrics = AsyncPricingMetricsClient(client_wrapper=self._client_wrapper)
|
|
300
|
+
return self._pricing_metrics
|
|
301
|
+
|
|
302
|
+
@property
|
|
303
|
+
def customer_access(self):
|
|
304
|
+
if self._customer_access is None:
|
|
305
|
+
from .customer_access.client import AsyncCustomerAccessClient # noqa: E402
|
|
306
|
+
|
|
307
|
+
self._customer_access = AsyncCustomerAccessClient(client_wrapper=self._client_wrapper)
|
|
308
|
+
return self._customer_access
|
|
309
|
+
|
|
310
|
+
@property
|
|
311
|
+
def invoices(self):
|
|
312
|
+
if self._invoices is None:
|
|
313
|
+
from .invoices.client import AsyncInvoicesClient # noqa: E402
|
|
314
|
+
|
|
315
|
+
self._invoices = AsyncInvoicesClient(client_wrapper=self._client_wrapper)
|
|
316
|
+
return self._invoices
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
def _get_base_url(*, base_url: typing.Optional[str] = None, environment: LarkEnvironment) -> str:
|
|
320
|
+
if base_url is not None:
|
|
321
|
+
return base_url
|
|
322
|
+
elif environment is not None:
|
|
323
|
+
return environment.value
|
|
324
|
+
else:
|
|
325
|
+
raise Exception("Please pass in either base_url or environment to construct the client")
|
lark/core/client_wrapper.py
CHANGED
|
@@ -22,10 +22,10 @@ class BaseClientWrapper:
|
|
|
22
22
|
|
|
23
23
|
def get_headers(self) -> typing.Dict[str, str]:
|
|
24
24
|
headers: typing.Dict[str, str] = {
|
|
25
|
-
"User-Agent": "lark-billing/0.0.
|
|
25
|
+
"User-Agent": "lark-billing/0.0.8",
|
|
26
26
|
"X-Fern-Language": "Python",
|
|
27
27
|
"X-Fern-SDK-Name": "lark-billing",
|
|
28
|
-
"X-Fern-SDK-Version": "0.0.
|
|
28
|
+
"X-Fern-SDK-Version": "0.0.8",
|
|
29
29
|
**(self.get_custom_headers() or {}),
|
|
30
30
|
}
|
|
31
31
|
headers["X-API-Key"] = self.api_key
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
# isort: skip_file
|
|
4
|
+
|
|
5
|
+
import typing
|
|
6
|
+
from importlib import import_module
|
|
7
|
+
|
|
8
|
+
if typing.TYPE_CHECKING:
|
|
9
|
+
from ._api import EventSource, aconnect_sse, connect_sse
|
|
10
|
+
from ._exceptions import SSEError
|
|
11
|
+
from ._models import ServerSentEvent
|
|
12
|
+
_dynamic_imports: typing.Dict[str, str] = {
|
|
13
|
+
"EventSource": "._api",
|
|
14
|
+
"SSEError": "._exceptions",
|
|
15
|
+
"ServerSentEvent": "._models",
|
|
16
|
+
"aconnect_sse": "._api",
|
|
17
|
+
"connect_sse": "._api",
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def __getattr__(attr_name: str) -> typing.Any:
|
|
22
|
+
module_name = _dynamic_imports.get(attr_name)
|
|
23
|
+
if module_name is None:
|
|
24
|
+
raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}")
|
|
25
|
+
try:
|
|
26
|
+
module = import_module(module_name, __package__)
|
|
27
|
+
if module_name == f".{attr_name}":
|
|
28
|
+
return module
|
|
29
|
+
else:
|
|
30
|
+
return getattr(module, attr_name)
|
|
31
|
+
except ImportError as e:
|
|
32
|
+
raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e
|
|
33
|
+
except AttributeError as e:
|
|
34
|
+
raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def __dir__():
|
|
38
|
+
lazy_attrs = list(_dynamic_imports.keys())
|
|
39
|
+
return sorted(lazy_attrs)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
__all__ = ["EventSource", "SSEError", "ServerSentEvent", "aconnect_sse", "connect_sse"]
|