lark-billing 0.0.6__py3-none-any.whl → 0.0.7__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 +69 -360
- lark/checkout/client.py +8 -85
- lark/checkout/raw_client.py +6 -102
- lark/client.py +93 -27
- lark/core/client_wrapper.py +2 -2
- 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/pricing_metrics/__init__.py +38 -0
- lark/pricing_metrics/client.py +219 -0
- lark/pricing_metrics/raw_client.py +268 -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 +3 -30
- lark/rate_cards/client.py +28 -540
- lark/rate_cards/raw_client.py +32 -368
- lark/rate_cards/types/__init__.py +2 -29
- lark/subjects/client.py +2 -36
- lark/subjects/raw_client.py +0 -16
- lark/subscriptions/client.py +24 -184
- lark/subscriptions/raw_client.py +18 -135
- lark/types/__init__.py +41 -356
- lark/types/amount.py +5 -1
- lark/types/{create_dimension_coordinate_interface.py → billing_state_response.py} +3 -3
- 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_fixed_rate_interface.py +1 -7
- lark/types/{pricing_metric_interface.py → create_pricing_metric_response.py} +2 -5
- lark/types/create_simple_usage_based_rate_interface.py +3 -8
- lark/types/create_subject_response.py +2 -1
- lark/types/create_subscription_checkout_session_response.py +1 -2
- lark/types/create_usage_event_summary_response.py +1 -1
- lark/types/{credit_grant_schedule_rate_cycle_start_resource.py → custom_pricing_metric_resource.py} +3 -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/{credit_grant_schedule_one_time_interface.py → last_aggregation_pricing_metric_resource.py} +2 -2
- lark/types/{credit_grant_date_time_expiration_resource.py → max_aggregation_pricing_metric_resource.py} +2 -2
- 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/price.py +39 -1
- lark/types/rate_card_resource.py +0 -6
- lark/types/rate_card_resource_usage_based_rates_item.py +2 -28
- lark/types/simple_usage_based_rate_interface.py +1 -2
- lark/types/status.py +1 -1
- lark/types/subject_resource.py +2 -1
- lark/types/subscription_resource.py +0 -1
- lark/types/{credit_grant_date_time_expiration_interface.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.7.dist-info}/METADATA +3 -3
- lark_billing-0.0.7.dist-info/RECORD +94 -0
- lark/rate_cards/types/create_rate_card_request_usage_based_rates_item.py +0 -56
- 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/check_feature_access_request.py +0 -24
- lark/types/check_feature_access_response.py +0 -21
- lark/types/complete_subscription_checkout_response.py +0 -21
- 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_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.py +0 -5
- 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_rate_cycle_start_interface.py +0 -19
- 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.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/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.7.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,7 @@ class CheckoutClient:
|
|
|
32
31
|
*,
|
|
33
32
|
subject_id: str,
|
|
34
33
|
rate_card_id: str,
|
|
35
|
-
|
|
34
|
+
callback_url: str,
|
|
36
35
|
request_options: typing.Optional[RequestOptions] = None,
|
|
37
36
|
) -> CreateSubscriptionCheckoutSessionResponse:
|
|
38
37
|
"""
|
|
@@ -42,7 +41,7 @@ class CheckoutClient:
|
|
|
42
41
|
|
|
43
42
|
rate_card_id : str
|
|
44
43
|
|
|
45
|
-
|
|
44
|
+
callback_url : str
|
|
46
45
|
|
|
47
46
|
request_options : typing.Optional[RequestOptions]
|
|
48
47
|
Request-specific configuration.
|
|
@@ -58,52 +57,18 @@ class CheckoutClient:
|
|
|
58
57
|
|
|
59
58
|
client = Lark(
|
|
60
59
|
api_key="YOUR_API_KEY",
|
|
61
|
-
base_url="https://yourhost.com/path/to/api",
|
|
62
60
|
)
|
|
63
61
|
client.checkout.create_subscription_checkout_session(
|
|
64
62
|
subject_id="subject_id",
|
|
65
63
|
rate_card_id="rate_card_id",
|
|
64
|
+
callback_url="callback_url",
|
|
66
65
|
)
|
|
67
66
|
"""
|
|
68
67
|
_response = self._raw_client.create_subscription_checkout_session(
|
|
69
|
-
subject_id=subject_id,
|
|
70
|
-
rate_card_id=rate_card_id,
|
|
71
|
-
rate_card_overrides=rate_card_overrides,
|
|
72
|
-
request_options=request_options,
|
|
68
|
+
subject_id=subject_id, rate_card_id=rate_card_id, callback_url=callback_url, request_options=request_options
|
|
73
69
|
)
|
|
74
70
|
return _response.data
|
|
75
71
|
|
|
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
72
|
|
|
108
73
|
class AsyncCheckoutClient:
|
|
109
74
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
@@ -125,7 +90,7 @@ class AsyncCheckoutClient:
|
|
|
125
90
|
*,
|
|
126
91
|
subject_id: str,
|
|
127
92
|
rate_card_id: str,
|
|
128
|
-
|
|
93
|
+
callback_url: str,
|
|
129
94
|
request_options: typing.Optional[RequestOptions] = None,
|
|
130
95
|
) -> CreateSubscriptionCheckoutSessionResponse:
|
|
131
96
|
"""
|
|
@@ -135,7 +100,7 @@ class AsyncCheckoutClient:
|
|
|
135
100
|
|
|
136
101
|
rate_card_id : str
|
|
137
102
|
|
|
138
|
-
|
|
103
|
+
callback_url : str
|
|
139
104
|
|
|
140
105
|
request_options : typing.Optional[RequestOptions]
|
|
141
106
|
Request-specific configuration.
|
|
@@ -153,7 +118,6 @@ class AsyncCheckoutClient:
|
|
|
153
118
|
|
|
154
119
|
client = AsyncLark(
|
|
155
120
|
api_key="YOUR_API_KEY",
|
|
156
|
-
base_url="https://yourhost.com/path/to/api",
|
|
157
121
|
)
|
|
158
122
|
|
|
159
123
|
|
|
@@ -161,54 +125,13 @@ class AsyncCheckoutClient:
|
|
|
161
125
|
await client.checkout.create_subscription_checkout_session(
|
|
162
126
|
subject_id="subject_id",
|
|
163
127
|
rate_card_id="rate_card_id",
|
|
128
|
+
callback_url="callback_url",
|
|
164
129
|
)
|
|
165
130
|
|
|
166
131
|
|
|
167
132
|
asyncio.run(main())
|
|
168
133
|
"""
|
|
169
134
|
_response = await self._raw_client.create_subscription_checkout_session(
|
|
170
|
-
subject_id=subject_id,
|
|
171
|
-
rate_card_id=rate_card_id,
|
|
172
|
-
rate_card_overrides=rate_card_overrides,
|
|
173
|
-
request_options=request_options,
|
|
174
|
-
)
|
|
175
|
-
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",
|
|
135
|
+
subject_id=subject_id, rate_card_id=rate_card_id, callback_url=callback_url, request_options=request_options
|
|
202
136
|
)
|
|
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
137
|
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,7 @@ class RawCheckoutClient:
|
|
|
27
25
|
*,
|
|
28
26
|
subject_id: str,
|
|
29
27
|
rate_card_id: str,
|
|
30
|
-
|
|
28
|
+
callback_url: str,
|
|
31
29
|
request_options: typing.Optional[RequestOptions] = None,
|
|
32
30
|
) -> HttpResponse[CreateSubscriptionCheckoutSessionResponse]:
|
|
33
31
|
"""
|
|
@@ -37,7 +35,7 @@ class RawCheckoutClient:
|
|
|
37
35
|
|
|
38
36
|
rate_card_id : str
|
|
39
37
|
|
|
40
|
-
|
|
38
|
+
callback_url : str
|
|
41
39
|
|
|
42
40
|
request_options : typing.Optional[RequestOptions]
|
|
43
41
|
Request-specific configuration.
|
|
@@ -53,7 +51,7 @@ class RawCheckoutClient:
|
|
|
53
51
|
json={
|
|
54
52
|
"subject_id": subject_id,
|
|
55
53
|
"rate_card_id": rate_card_id,
|
|
56
|
-
"
|
|
54
|
+
"callback_url": callback_url,
|
|
57
55
|
},
|
|
58
56
|
headers={
|
|
59
57
|
"content-type": "application/json",
|
|
@@ -87,53 +85,6 @@ class RawCheckoutClient:
|
|
|
87
85
|
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
88
86
|
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
89
87
|
|
|
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
88
|
|
|
138
89
|
class AsyncRawCheckoutClient:
|
|
139
90
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
@@ -144,7 +95,7 @@ class AsyncRawCheckoutClient:
|
|
|
144
95
|
*,
|
|
145
96
|
subject_id: str,
|
|
146
97
|
rate_card_id: str,
|
|
147
|
-
|
|
98
|
+
callback_url: str,
|
|
148
99
|
request_options: typing.Optional[RequestOptions] = None,
|
|
149
100
|
) -> AsyncHttpResponse[CreateSubscriptionCheckoutSessionResponse]:
|
|
150
101
|
"""
|
|
@@ -154,7 +105,7 @@ class AsyncRawCheckoutClient:
|
|
|
154
105
|
|
|
155
106
|
rate_card_id : str
|
|
156
107
|
|
|
157
|
-
|
|
108
|
+
callback_url : str
|
|
158
109
|
|
|
159
110
|
request_options : typing.Optional[RequestOptions]
|
|
160
111
|
Request-specific configuration.
|
|
@@ -170,7 +121,7 @@ class AsyncRawCheckoutClient:
|
|
|
170
121
|
json={
|
|
171
122
|
"subject_id": subject_id,
|
|
172
123
|
"rate_card_id": rate_card_id,
|
|
173
|
-
"
|
|
124
|
+
"callback_url": callback_url,
|
|
174
125
|
},
|
|
175
126
|
headers={
|
|
176
127
|
"content-type": "application/json",
|
|
@@ -203,50 +154,3 @@ class AsyncRawCheckoutClient:
|
|
|
203
154
|
except JSONDecodeError:
|
|
204
155
|
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
205
156
|
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,13 @@ 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 .pricing_metrics.client import AsyncPricingMetricsClient, PricingMetricsClient
|
|
13
16
|
from .rate_cards.client import AsyncRateCardsClient, RateCardsClient
|
|
14
17
|
from .subjects.client import AsyncSubjectsClient, SubjectsClient
|
|
15
18
|
from .subscriptions.client import AsyncSubscriptionsClient, SubscriptionsClient
|
|
@@ -22,9 +25,18 @@ class Lark:
|
|
|
22
25
|
|
|
23
26
|
Parameters
|
|
24
27
|
----------
|
|
25
|
-
base_url : str
|
|
28
|
+
base_url : typing.Optional[str]
|
|
26
29
|
The base url to use for requests from the client.
|
|
27
30
|
|
|
31
|
+
environment : LarkEnvironment
|
|
32
|
+
The environment to use for requests from the client. from .environment import LarkEnvironment
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
Defaults to LarkEnvironment.DEFAULT
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
28
40
|
api_key : str
|
|
29
41
|
headers : typing.Optional[typing.Dict[str, str]]
|
|
30
42
|
Additional headers to send with every request.
|
|
@@ -44,14 +56,14 @@ class Lark:
|
|
|
44
56
|
|
|
45
57
|
client = Lark(
|
|
46
58
|
api_key="YOUR_API_KEY",
|
|
47
|
-
base_url="https://yourhost.com/path/to/api",
|
|
48
59
|
)
|
|
49
60
|
"""
|
|
50
61
|
|
|
51
62
|
def __init__(
|
|
52
63
|
self,
|
|
53
64
|
*,
|
|
54
|
-
base_url: str,
|
|
65
|
+
base_url: typing.Optional[str] = None,
|
|
66
|
+
environment: LarkEnvironment = LarkEnvironment.DEFAULT,
|
|
55
67
|
api_key: str,
|
|
56
68
|
headers: typing.Optional[typing.Dict[str, str]] = None,
|
|
57
69
|
timeout: typing.Optional[float] = None,
|
|
@@ -62,7 +74,7 @@ class Lark:
|
|
|
62
74
|
timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
|
|
63
75
|
)
|
|
64
76
|
self._client_wrapper = SyncClientWrapper(
|
|
65
|
-
base_url=base_url,
|
|
77
|
+
base_url=_get_base_url(base_url=base_url, environment=environment),
|
|
66
78
|
api_key=api_key,
|
|
67
79
|
headers=headers,
|
|
68
80
|
httpx_client=httpx_client
|
|
@@ -73,11 +85,13 @@ class Lark:
|
|
|
73
85
|
timeout=_defaulted_timeout,
|
|
74
86
|
)
|
|
75
87
|
self._checkout: typing.Optional[CheckoutClient] = None
|
|
88
|
+
self._customer_portal: typing.Optional[CustomerPortalClient] = None
|
|
76
89
|
self._rate_cards: typing.Optional[RateCardsClient] = None
|
|
77
90
|
self._usage_events: typing.Optional[UsageEventsClient] = None
|
|
78
91
|
self._subscriptions: typing.Optional[SubscriptionsClient] = None
|
|
79
|
-
self._feature_access: typing.Optional[FeatureAccessClient] = None
|
|
80
92
|
self._subjects: typing.Optional[SubjectsClient] = None
|
|
93
|
+
self._pricing_metrics: typing.Optional[PricingMetricsClient] = None
|
|
94
|
+
self._customer_access: typing.Optional[CustomerAccessClient] = None
|
|
81
95
|
|
|
82
96
|
@property
|
|
83
97
|
def checkout(self):
|
|
@@ -87,6 +101,14 @@ class Lark:
|
|
|
87
101
|
self._checkout = CheckoutClient(client_wrapper=self._client_wrapper)
|
|
88
102
|
return self._checkout
|
|
89
103
|
|
|
104
|
+
@property
|
|
105
|
+
def customer_portal(self):
|
|
106
|
+
if self._customer_portal is None:
|
|
107
|
+
from .customer_portal.client import CustomerPortalClient # noqa: E402
|
|
108
|
+
|
|
109
|
+
self._customer_portal = CustomerPortalClient(client_wrapper=self._client_wrapper)
|
|
110
|
+
return self._customer_portal
|
|
111
|
+
|
|
90
112
|
@property
|
|
91
113
|
def rate_cards(self):
|
|
92
114
|
if self._rate_cards is None:
|
|
@@ -111,14 +133,6 @@ class Lark:
|
|
|
111
133
|
self._subscriptions = SubscriptionsClient(client_wrapper=self._client_wrapper)
|
|
112
134
|
return self._subscriptions
|
|
113
135
|
|
|
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
136
|
@property
|
|
123
137
|
def subjects(self):
|
|
124
138
|
if self._subjects is None:
|
|
@@ -127,6 +141,22 @@ class Lark:
|
|
|
127
141
|
self._subjects = SubjectsClient(client_wrapper=self._client_wrapper)
|
|
128
142
|
return self._subjects
|
|
129
143
|
|
|
144
|
+
@property
|
|
145
|
+
def pricing_metrics(self):
|
|
146
|
+
if self._pricing_metrics is None:
|
|
147
|
+
from .pricing_metrics.client import PricingMetricsClient # noqa: E402
|
|
148
|
+
|
|
149
|
+
self._pricing_metrics = PricingMetricsClient(client_wrapper=self._client_wrapper)
|
|
150
|
+
return self._pricing_metrics
|
|
151
|
+
|
|
152
|
+
@property
|
|
153
|
+
def customer_access(self):
|
|
154
|
+
if self._customer_access is None:
|
|
155
|
+
from .customer_access.client import CustomerAccessClient # noqa: E402
|
|
156
|
+
|
|
157
|
+
self._customer_access = CustomerAccessClient(client_wrapper=self._client_wrapper)
|
|
158
|
+
return self._customer_access
|
|
159
|
+
|
|
130
160
|
|
|
131
161
|
class AsyncLark:
|
|
132
162
|
"""
|
|
@@ -134,9 +164,18 @@ class AsyncLark:
|
|
|
134
164
|
|
|
135
165
|
Parameters
|
|
136
166
|
----------
|
|
137
|
-
base_url : str
|
|
167
|
+
base_url : typing.Optional[str]
|
|
138
168
|
The base url to use for requests from the client.
|
|
139
169
|
|
|
170
|
+
environment : LarkEnvironment
|
|
171
|
+
The environment to use for requests from the client. from .environment import LarkEnvironment
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
Defaults to LarkEnvironment.DEFAULT
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
140
179
|
api_key : str
|
|
141
180
|
headers : typing.Optional[typing.Dict[str, str]]
|
|
142
181
|
Additional headers to send with every request.
|
|
@@ -156,14 +195,14 @@ class AsyncLark:
|
|
|
156
195
|
|
|
157
196
|
client = AsyncLark(
|
|
158
197
|
api_key="YOUR_API_KEY",
|
|
159
|
-
base_url="https://yourhost.com/path/to/api",
|
|
160
198
|
)
|
|
161
199
|
"""
|
|
162
200
|
|
|
163
201
|
def __init__(
|
|
164
202
|
self,
|
|
165
203
|
*,
|
|
166
|
-
base_url: str,
|
|
204
|
+
base_url: typing.Optional[str] = None,
|
|
205
|
+
environment: LarkEnvironment = LarkEnvironment.DEFAULT,
|
|
167
206
|
api_key: str,
|
|
168
207
|
headers: typing.Optional[typing.Dict[str, str]] = None,
|
|
169
208
|
timeout: typing.Optional[float] = None,
|
|
@@ -174,7 +213,7 @@ class AsyncLark:
|
|
|
174
213
|
timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
|
|
175
214
|
)
|
|
176
215
|
self._client_wrapper = AsyncClientWrapper(
|
|
177
|
-
base_url=base_url,
|
|
216
|
+
base_url=_get_base_url(base_url=base_url, environment=environment),
|
|
178
217
|
api_key=api_key,
|
|
179
218
|
headers=headers,
|
|
180
219
|
httpx_client=httpx_client
|
|
@@ -185,11 +224,13 @@ class AsyncLark:
|
|
|
185
224
|
timeout=_defaulted_timeout,
|
|
186
225
|
)
|
|
187
226
|
self._checkout: typing.Optional[AsyncCheckoutClient] = None
|
|
227
|
+
self._customer_portal: typing.Optional[AsyncCustomerPortalClient] = None
|
|
188
228
|
self._rate_cards: typing.Optional[AsyncRateCardsClient] = None
|
|
189
229
|
self._usage_events: typing.Optional[AsyncUsageEventsClient] = None
|
|
190
230
|
self._subscriptions: typing.Optional[AsyncSubscriptionsClient] = None
|
|
191
|
-
self._feature_access: typing.Optional[AsyncFeatureAccessClient] = None
|
|
192
231
|
self._subjects: typing.Optional[AsyncSubjectsClient] = None
|
|
232
|
+
self._pricing_metrics: typing.Optional[AsyncPricingMetricsClient] = None
|
|
233
|
+
self._customer_access: typing.Optional[AsyncCustomerAccessClient] = None
|
|
193
234
|
|
|
194
235
|
@property
|
|
195
236
|
def checkout(self):
|
|
@@ -199,6 +240,14 @@ class AsyncLark:
|
|
|
199
240
|
self._checkout = AsyncCheckoutClient(client_wrapper=self._client_wrapper)
|
|
200
241
|
return self._checkout
|
|
201
242
|
|
|
243
|
+
@property
|
|
244
|
+
def customer_portal(self):
|
|
245
|
+
if self._customer_portal is None:
|
|
246
|
+
from .customer_portal.client import AsyncCustomerPortalClient # noqa: E402
|
|
247
|
+
|
|
248
|
+
self._customer_portal = AsyncCustomerPortalClient(client_wrapper=self._client_wrapper)
|
|
249
|
+
return self._customer_portal
|
|
250
|
+
|
|
202
251
|
@property
|
|
203
252
|
def rate_cards(self):
|
|
204
253
|
if self._rate_cards is None:
|
|
@@ -223,14 +272,6 @@ class AsyncLark:
|
|
|
223
272
|
self._subscriptions = AsyncSubscriptionsClient(client_wrapper=self._client_wrapper)
|
|
224
273
|
return self._subscriptions
|
|
225
274
|
|
|
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
275
|
@property
|
|
235
276
|
def subjects(self):
|
|
236
277
|
if self._subjects is None:
|
|
@@ -238,3 +279,28 @@ class AsyncLark:
|
|
|
238
279
|
|
|
239
280
|
self._subjects = AsyncSubjectsClient(client_wrapper=self._client_wrapper)
|
|
240
281
|
return self._subjects
|
|
282
|
+
|
|
283
|
+
@property
|
|
284
|
+
def pricing_metrics(self):
|
|
285
|
+
if self._pricing_metrics is None:
|
|
286
|
+
from .pricing_metrics.client import AsyncPricingMetricsClient # noqa: E402
|
|
287
|
+
|
|
288
|
+
self._pricing_metrics = AsyncPricingMetricsClient(client_wrapper=self._client_wrapper)
|
|
289
|
+
return self._pricing_metrics
|
|
290
|
+
|
|
291
|
+
@property
|
|
292
|
+
def customer_access(self):
|
|
293
|
+
if self._customer_access is None:
|
|
294
|
+
from .customer_access.client import AsyncCustomerAccessClient # noqa: E402
|
|
295
|
+
|
|
296
|
+
self._customer_access = AsyncCustomerAccessClient(client_wrapper=self._client_wrapper)
|
|
297
|
+
return self._customer_access
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
def _get_base_url(*, base_url: typing.Optional[str] = None, environment: LarkEnvironment) -> str:
|
|
301
|
+
if base_url is not None:
|
|
302
|
+
return base_url
|
|
303
|
+
elif environment is not None:
|
|
304
|
+
return environment.value
|
|
305
|
+
else:
|
|
306
|
+
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.7",
|
|
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.7",
|
|
29
29
|
**(self.get_custom_headers() or {}),
|
|
30
30
|
}
|
|
31
31
|
headers["X-API-Key"] = self.api_key
|