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.

Files changed (154) hide show
  1. lark/__init__.py +92 -369
  2. lark/checkout/client.py +20 -79
  3. lark/checkout/raw_client.py +18 -102
  4. lark/client.py +112 -27
  5. lark/core/client_wrapper.py +2 -2
  6. lark/core/http_sse/__init__.py +42 -0
  7. lark/core/http_sse/_api.py +112 -0
  8. lark/core/http_sse/_decoders.py +61 -0
  9. lark/{types/credit_grant.py → core/http_sse/_exceptions.py} +4 -2
  10. lark/core/http_sse/_models.py +17 -0
  11. lark/core/pydantic_utilities.py +3 -1
  12. lark/{feature_access → customer_access}/client.py +30 -24
  13. lark/{feature_access → customer_access}/raw_client.py +22 -17
  14. lark/{types/rate_card.py → customer_portal/__init__.py} +1 -2
  15. lark/customer_portal/client.py +115 -0
  16. lark/customer_portal/raw_client.py +134 -0
  17. lark/environment.py +7 -0
  18. lark/{types/dimension.py → invoices/__init__.py} +1 -2
  19. lark/invoices/client.py +136 -0
  20. lark/invoices/raw_client.py +147 -0
  21. lark/pricing_metrics/__init__.py +38 -0
  22. lark/pricing_metrics/client.py +288 -0
  23. lark/pricing_metrics/raw_client.py +369 -0
  24. lark/pricing_metrics/types/__init__.py +42 -0
  25. lark/{types/credit_grant_resource_input_schedule.py → pricing_metrics/types/pricing_metric_aggregation.py} +7 -8
  26. lark/rate_cards/__init__.py +0 -15
  27. lark/rate_cards/client.py +30 -542
  28. lark/rate_cards/raw_client.py +34 -370
  29. lark/rate_cards/types/__init__.py +0 -17
  30. lark/rate_cards/types/create_rate_card_request_usage_based_rates_item.py +3 -29
  31. lark/subjects/client.py +18 -54
  32. lark/subjects/raw_client.py +14 -24
  33. lark/subscriptions/client.py +104 -80
  34. lark/subscriptions/raw_client.py +186 -53
  35. lark/types/__init__.py +63 -379
  36. lark/types/aggregation.py +1 -43
  37. lark/types/amount.py +5 -1
  38. lark/types/{credit_grant_date_time_expiration_interface.py → billing_state_response.py} +3 -2
  39. lark/types/{credit_grant_schedule_one_time_resource.py → count_aggregation_pricing_metric_resource.py} +1 -1
  40. lark/types/{create_dimension_interface.py → create_customer_portal_session_response.py} +3 -3
  41. lark/types/{create_dimension_coordinate_interface.py → create_fixed_rate_request.py} +5 -3
  42. lark/types/{pricing_metric_interface.py → create_pricing_metric_response.py} +2 -5
  43. lark/types/{create_simple_usage_based_rate_interface.py → create_simple_usage_based_rate_request.py} +6 -9
  44. lark/types/create_subject_response.py +30 -6
  45. lark/types/create_subscription_checkout_session_response.py +1 -2
  46. lark/types/create_usage_event_summary_response.py +1 -1
  47. lark/types/fixed_rate_interface.py +0 -6
  48. lark/types/{create_pricing_metric_interface.py → get_pricing_metric_response.py} +3 -5
  49. lark/types/{complete_subscription_checkout_response.py → invoice_line_item_resource.py} +4 -2
  50. lark/types/invoice_resource.py +31 -0
  51. lark/types/invoice_status.py +5 -0
  52. lark/types/{check_feature_access_response.py → list_invoices_response.py} +4 -4
  53. lark/types/{check_feature_access_request.py → list_pricing_metrics_response.py} +4 -7
  54. lark/types/package_price.py +2 -2
  55. lark/types/package_price_input_rounding_behavior.py +5 -0
  56. lark/types/package_price_output_rounding_behavior.py +5 -0
  57. lark/types/period_resource.py +23 -0
  58. lark/types/price.py +39 -1
  59. lark/types/pricing_metric_resource.py +24 -0
  60. lark/types/rate_card_resource.py +0 -6
  61. lark/types/rate_card_resource_usage_based_rates_item.py +2 -29
  62. lark/types/simple_usage_based_rate_interface.py +1 -7
  63. lark/types/subject_resource.py +30 -6
  64. lark/types/subscription_resource.py +6 -4
  65. lark/types/subscription_status.py +5 -0
  66. lark/types/{credit_grant_date_time_expiration_resource.py → sum_aggregation_pricing_metric_resource.py} +2 -2
  67. lark/types/{subject.py → value.py} +1 -1
  68. lark/usage_events/client.py +8 -21
  69. lark/usage_events/raw_client.py +6 -6
  70. {lark_billing-0.0.6.dist-info → lark_billing-0.0.8.dist-info}/METADATA +4 -3
  71. lark_billing-0.0.8.dist-info/RECORD +107 -0
  72. lark/rate_cards/types/create_rate_card_version_request_usage_based_rates_item.py +0 -58
  73. lark/rate_cards/types/create_rate_card_version_request_version_type.py +0 -5
  74. lark/types/create_credit_grant_interface.py +0 -27
  75. lark/types/create_credit_grant_interface_expiration.py +0 -27
  76. lark/types/create_credit_pool_request.py +0 -5
  77. lark/types/create_dimensional_usage_based_rate_interface.py +0 -32
  78. lark/types/create_fixed_rate_interface.py +0 -28
  79. lark/types/create_pricing_matrix_cell_interface.py +0 -22
  80. lark/types/create_pricing_matrix_interface.py +0 -20
  81. lark/types/create_pricing_plan_request.py +0 -5
  82. lark/types/create_rate_card_response.py +0 -36
  83. lark/types/create_rate_card_response_billing_interval.py +0 -5
  84. lark/types/create_rate_card_response_usage_based_rates_item.py +0 -58
  85. lark/types/create_rate_card_version_response.py +0 -36
  86. lark/types/create_rate_card_version_response_billing_interval.py +0 -5
  87. lark/types/create_rate_card_version_response_usage_based_rates_item.py +0 -59
  88. lark/types/credit_grant_duration_expiration_interface.py +0 -21
  89. lark/types/credit_grant_duration_expiration_resource.py +0 -21
  90. lark/types/credit_grant_interface.py +0 -28
  91. lark/types/credit_grant_interface_input_expiration.py +0 -27
  92. lark/types/credit_grant_interface_output_expiration.py +0 -43
  93. lark/types/credit_grant_interface_output_schedule.py +0 -41
  94. lark/types/credit_grant_resource.py +0 -28
  95. lark/types/credit_grant_resource_input_expiration.py +0 -27
  96. lark/types/credit_grant_resource_output_expiration.py +0 -43
  97. lark/types/credit_grant_resource_output_schedule.py +0 -39
  98. lark/types/credit_grant_schedule.py +0 -5
  99. lark/types/credit_grant_schedule_one_time_interface.py +0 -19
  100. lark/types/credit_grant_schedule_rate_cycle_start_interface.py +0 -19
  101. lark/types/credit_grant_schedule_rate_cycle_start_resource.py +0 -17
  102. lark/types/credit_grant_subject_granting_config_interface.py +0 -20
  103. lark/types/credit_pool.py +0 -5
  104. lark/types/credit_pool_rollover_config.py +0 -5
  105. lark/types/custom_aggregation_pricing_metric_interface.py +0 -22
  106. lark/types/custom_pricing_metric.py +0 -5
  107. lark/types/custom_unit.py +0 -5
  108. lark/types/custom_unit_amount.py +0 -5
  109. lark/types/dimension_coordinate.py +0 -5
  110. lark/types/dimension_coordinate_interface.py +0 -20
  111. lark/types/dimension_coordinate_set.py +0 -5
  112. lark/types/dimension_interface.py +0 -20
  113. lark/types/dimensional_rate_matrix.py +0 -5
  114. lark/types/dimensional_rate_matrix_cell.py +0 -5
  115. lark/types/dimensional_usage_based_rate.py +0 -5
  116. lark/types/dimensional_usage_based_rate_input.py +0 -5
  117. lark/types/dimensional_usage_based_rate_interface.py +0 -33
  118. lark/types/feature_access_resource.py +0 -21
  119. lark/types/get_rate_card_response.py +0 -36
  120. lark/types/get_rate_card_response_billing_interval.py +0 -5
  121. lark/types/get_rate_card_response_usage_based_rates_item.py +0 -58
  122. lark/types/grant_credits_request.py +0 -5
  123. lark/types/last_aggregation_pricing_metric_interface.py +0 -22
  124. lark/types/license_based_rate.py +0 -5
  125. lark/types/license_based_rate_input.py +0 -5
  126. lark/types/max_aggregation_pricing_metric_interface.py +0 -22
  127. lark/types/monetary_amount.py +0 -5
  128. lark/types/package_price_rounding_behavior.py +0 -5
  129. lark/types/package_price_wrapper.py +0 -5
  130. lark/types/pricing_matrix_cell_interface.py +0 -22
  131. lark/types/pricing_matrix_interface.py +0 -20
  132. lark/types/pricing_metric.py +0 -5
  133. lark/types/pricing_plan.py +0 -5
  134. lark/types/pricing_plan_subscription.py +0 -5
  135. lark/types/pricing_tier.py +0 -5
  136. lark/types/rate_card_version.py +0 -5
  137. lark/types/rate_card_version_input.py +0 -5
  138. lark/types/simple_usage_based_rate.py +0 -5
  139. lark/types/simple_usage_based_rate_input.py +0 -5
  140. lark/types/status.py +0 -5
  141. lark/types/subject_granting_config.py +0 -5
  142. lark/types/subject_granting_config_resource.py +0 -20
  143. lark/types/tiered_price.py +0 -5
  144. lark/types/tiered_price_wrapper.py +0 -5
  145. lark/types/unit.py +0 -5
  146. lark/types/update_pricing_plan_request.py +0 -5
  147. lark/types/update_rate_card_request.py +0 -5
  148. lark/types/update_subscription_request.py +0 -5
  149. lark/types/usage_based_rate.py +0 -5
  150. lark/types/usage_based_rate_input.py +0 -5
  151. lark/types/usage_unit.py +0 -5
  152. lark_billing-0.0.6.dist-info/RECORD +0 -167
  153. /lark/{feature_access → customer_access}/__init__.py +0 -0
  154. {lark_billing-0.0.6.dist-info → lark_billing-0.0.8.dist-info}/WHEEL +0 -0
@@ -0,0 +1,112 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import re
4
+ from contextlib import asynccontextmanager, contextmanager
5
+ from typing import Any, AsyncGenerator, AsyncIterator, Iterator, cast
6
+
7
+ import httpx
8
+ from ._decoders import SSEDecoder
9
+ from ._exceptions import SSEError
10
+ from ._models import ServerSentEvent
11
+
12
+
13
+ class EventSource:
14
+ def __init__(self, response: httpx.Response) -> None:
15
+ self._response = response
16
+
17
+ def _check_content_type(self) -> None:
18
+ content_type = self._response.headers.get("content-type", "").partition(";")[0]
19
+ if "text/event-stream" not in content_type:
20
+ raise SSEError(
21
+ f"Expected response header Content-Type to contain 'text/event-stream', got {content_type!r}"
22
+ )
23
+
24
+ def _get_charset(self) -> str:
25
+ """Extract charset from Content-Type header, fallback to UTF-8."""
26
+ content_type = self._response.headers.get("content-type", "")
27
+
28
+ # Parse charset parameter using regex
29
+ charset_match = re.search(r"charset=([^;\s]+)", content_type, re.IGNORECASE)
30
+ if charset_match:
31
+ charset = charset_match.group(1).strip("\"'")
32
+ # Validate that it's a known encoding
33
+ try:
34
+ # Test if the charset is valid by trying to encode/decode
35
+ "test".encode(charset).decode(charset)
36
+ return charset
37
+ except (LookupError, UnicodeError):
38
+ # If charset is invalid, fall back to UTF-8
39
+ pass
40
+
41
+ # Default to UTF-8 if no charset specified or invalid charset
42
+ return "utf-8"
43
+
44
+ @property
45
+ def response(self) -> httpx.Response:
46
+ return self._response
47
+
48
+ def iter_sse(self) -> Iterator[ServerSentEvent]:
49
+ self._check_content_type()
50
+ decoder = SSEDecoder()
51
+ charset = self._get_charset()
52
+
53
+ buffer = ""
54
+ for chunk in self._response.iter_bytes():
55
+ # Decode chunk using detected charset
56
+ text_chunk = chunk.decode(charset, errors="replace")
57
+ buffer += text_chunk
58
+
59
+ # Process complete lines
60
+ while "\n" in buffer:
61
+ line, buffer = buffer.split("\n", 1)
62
+ line = line.rstrip("\r")
63
+ sse = decoder.decode(line)
64
+ # when we reach a "\n\n" => line = ''
65
+ # => decoder will attempt to return an SSE Event
66
+ if sse is not None:
67
+ yield sse
68
+
69
+ # Process any remaining data in buffer
70
+ if buffer.strip():
71
+ line = buffer.rstrip("\r")
72
+ sse = decoder.decode(line)
73
+ if sse is not None:
74
+ yield sse
75
+
76
+ async def aiter_sse(self) -> AsyncGenerator[ServerSentEvent, None]:
77
+ self._check_content_type()
78
+ decoder = SSEDecoder()
79
+ lines = cast(AsyncGenerator[str, None], self._response.aiter_lines())
80
+ try:
81
+ async for line in lines:
82
+ line = line.rstrip("\n")
83
+ sse = decoder.decode(line)
84
+ if sse is not None:
85
+ yield sse
86
+ finally:
87
+ await lines.aclose()
88
+
89
+
90
+ @contextmanager
91
+ def connect_sse(client: httpx.Client, method: str, url: str, **kwargs: Any) -> Iterator[EventSource]:
92
+ headers = kwargs.pop("headers", {})
93
+ headers["Accept"] = "text/event-stream"
94
+ headers["Cache-Control"] = "no-store"
95
+
96
+ with client.stream(method, url, headers=headers, **kwargs) as response:
97
+ yield EventSource(response)
98
+
99
+
100
+ @asynccontextmanager
101
+ async def aconnect_sse(
102
+ client: httpx.AsyncClient,
103
+ method: str,
104
+ url: str,
105
+ **kwargs: Any,
106
+ ) -> AsyncIterator[EventSource]:
107
+ headers = kwargs.pop("headers", {})
108
+ headers["Accept"] = "text/event-stream"
109
+ headers["Cache-Control"] = "no-store"
110
+
111
+ async with client.stream(method, url, headers=headers, **kwargs) as response:
112
+ yield EventSource(response)
@@ -0,0 +1,61 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from typing import List, Optional
4
+
5
+ from ._models import ServerSentEvent
6
+
7
+
8
+ class SSEDecoder:
9
+ def __init__(self) -> None:
10
+ self._event = ""
11
+ self._data: List[str] = []
12
+ self._last_event_id = ""
13
+ self._retry: Optional[int] = None
14
+
15
+ def decode(self, line: str) -> Optional[ServerSentEvent]:
16
+ # See: https://html.spec.whatwg.org/multipage/server-sent-events.html#event-stream-interpretation # noqa: E501
17
+
18
+ if not line:
19
+ if not self._event and not self._data and not self._last_event_id and self._retry is None:
20
+ return None
21
+
22
+ sse = ServerSentEvent(
23
+ event=self._event,
24
+ data="\n".join(self._data),
25
+ id=self._last_event_id,
26
+ retry=self._retry,
27
+ )
28
+
29
+ # NOTE: as per the SSE spec, do not reset last_event_id.
30
+ self._event = ""
31
+ self._data = []
32
+ self._retry = None
33
+
34
+ return sse
35
+
36
+ if line.startswith(":"):
37
+ return None
38
+
39
+ fieldname, _, value = line.partition(":")
40
+
41
+ if value.startswith(" "):
42
+ value = value[1:]
43
+
44
+ if fieldname == "event":
45
+ self._event = value
46
+ elif fieldname == "data":
47
+ self._data.append(value)
48
+ elif fieldname == "id":
49
+ if "\0" in value:
50
+ pass
51
+ else:
52
+ self._last_event_id = value
53
+ elif fieldname == "retry":
54
+ try:
55
+ self._retry = int(value)
56
+ except (TypeError, ValueError):
57
+ pass
58
+ else:
59
+ pass # Field is ignored.
60
+
61
+ return None
@@ -1,5 +1,7 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
- import typing
3
+ import httpx
4
4
 
5
- CreditGrant = typing.Optional[typing.Any]
5
+
6
+ class SSEError(httpx.TransportError):
7
+ pass
@@ -0,0 +1,17 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import json
4
+ from dataclasses import dataclass
5
+ from typing import Any, Optional
6
+
7
+
8
+ @dataclass(frozen=True)
9
+ class ServerSentEvent:
10
+ event: str = "message"
11
+ data: str = ""
12
+ id: str = ""
13
+ retry: Optional[int] = None
14
+
15
+ def json(self) -> Any:
16
+ """Parse the data field as JSON."""
17
+ return json.loads(self.data)
@@ -220,7 +220,9 @@ def universal_root_validator(
220
220
  ) -> Callable[[AnyCallable], AnyCallable]:
221
221
  def decorator(func: AnyCallable) -> AnyCallable:
222
222
  if IS_PYDANTIC_V2:
223
- return cast(AnyCallable, pydantic.model_validator(mode="before" if pre else "after")(func)) # type: ignore[attr-defined]
223
+ # In Pydantic v2, for RootModel we always use "before" mode
224
+ # The custom validators transform the input value before the model is created
225
+ return cast(AnyCallable, pydantic.model_validator(mode="before")(func)) # type: ignore[attr-defined]
224
226
  return cast(AnyCallable, pydantic.root_validator(pre=pre)(func)) # type: ignore[call-overload]
225
227
 
226
228
  return decorator
@@ -4,37 +4,39 @@ import typing
4
4
 
5
5
  from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
6
6
  from ..core.request_options import RequestOptions
7
- from ..types.check_feature_access_response import CheckFeatureAccessResponse
8
- from .raw_client import AsyncRawFeatureAccessClient, RawFeatureAccessClient
7
+ from ..types.billing_state_response import BillingStateResponse
8
+ from .raw_client import AsyncRawCustomerAccessClient, RawCustomerAccessClient
9
9
 
10
10
 
11
- class FeatureAccessClient:
11
+ class CustomerAccessClient:
12
12
  def __init__(self, *, client_wrapper: SyncClientWrapper):
13
- self._raw_client = RawFeatureAccessClient(client_wrapper=client_wrapper)
13
+ self._raw_client = RawCustomerAccessClient(client_wrapper=client_wrapper)
14
14
 
15
15
  @property
16
- def with_raw_response(self) -> RawFeatureAccessClient:
16
+ def with_raw_response(self) -> RawCustomerAccessClient:
17
17
  """
18
18
  Retrieves a raw implementation of this client that returns raw responses.
19
19
 
20
20
  Returns
21
21
  -------
22
- RawFeatureAccessClient
22
+ RawCustomerAccessClient
23
23
  """
24
24
  return self._raw_client
25
25
 
26
- def get_feature_access(
27
- self, *, request_options: typing.Optional[RequestOptions] = None
28
- ) -> CheckFeatureAccessResponse:
26
+ def get_billing_state(
27
+ self, subject_id: str, *, request_options: typing.Optional[RequestOptions] = None
28
+ ) -> BillingStateResponse:
29
29
  """
30
30
  Parameters
31
31
  ----------
32
+ subject_id : str
33
+
32
34
  request_options : typing.Optional[RequestOptions]
33
35
  Request-specific configuration.
34
36
 
35
37
  Returns
36
38
  -------
37
- CheckFeatureAccessResponse
39
+ BillingStateResponse
38
40
  Successful Response
39
41
 
40
42
  Examples
@@ -43,41 +45,44 @@ class FeatureAccessClient:
43
45
 
44
46
  client = Lark(
45
47
  api_key="YOUR_API_KEY",
46
- base_url="https://yourhost.com/path/to/api",
47
48
  )
48
- client.feature_access.get_feature_access()
49
+ client.customer_access.get_billing_state(
50
+ subject_id="subject_id",
51
+ )
49
52
  """
50
- _response = self._raw_client.get_feature_access(request_options=request_options)
53
+ _response = self._raw_client.get_billing_state(subject_id, request_options=request_options)
51
54
  return _response.data
52
55
 
53
56
 
54
- class AsyncFeatureAccessClient:
57
+ class AsyncCustomerAccessClient:
55
58
  def __init__(self, *, client_wrapper: AsyncClientWrapper):
56
- self._raw_client = AsyncRawFeatureAccessClient(client_wrapper=client_wrapper)
59
+ self._raw_client = AsyncRawCustomerAccessClient(client_wrapper=client_wrapper)
57
60
 
58
61
  @property
59
- def with_raw_response(self) -> AsyncRawFeatureAccessClient:
62
+ def with_raw_response(self) -> AsyncRawCustomerAccessClient:
60
63
  """
61
64
  Retrieves a raw implementation of this client that returns raw responses.
62
65
 
63
66
  Returns
64
67
  -------
65
- AsyncRawFeatureAccessClient
68
+ AsyncRawCustomerAccessClient
66
69
  """
67
70
  return self._raw_client
68
71
 
69
- async def get_feature_access(
70
- self, *, request_options: typing.Optional[RequestOptions] = None
71
- ) -> CheckFeatureAccessResponse:
72
+ async def get_billing_state(
73
+ self, subject_id: str, *, request_options: typing.Optional[RequestOptions] = None
74
+ ) -> BillingStateResponse:
72
75
  """
73
76
  Parameters
74
77
  ----------
78
+ subject_id : str
79
+
75
80
  request_options : typing.Optional[RequestOptions]
76
81
  Request-specific configuration.
77
82
 
78
83
  Returns
79
84
  -------
80
- CheckFeatureAccessResponse
85
+ BillingStateResponse
81
86
  Successful Response
82
87
 
83
88
  Examples
@@ -88,15 +93,16 @@ class AsyncFeatureAccessClient:
88
93
 
89
94
  client = AsyncLark(
90
95
  api_key="YOUR_API_KEY",
91
- base_url="https://yourhost.com/path/to/api",
92
96
  )
93
97
 
94
98
 
95
99
  async def main() -> None:
96
- await client.feature_access.get_feature_access()
100
+ await client.customer_access.get_billing_state(
101
+ subject_id="subject_id",
102
+ )
97
103
 
98
104
 
99
105
  asyncio.run(main())
100
106
  """
101
- _response = await self._raw_client.get_feature_access(request_options=request_options)
107
+ _response = await self._raw_client.get_billing_state(subject_id, request_options=request_options)
102
108
  return _response.data
@@ -6,42 +6,45 @@ 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
9
10
  from ..core.pydantic_utilities import parse_obj_as
10
11
  from ..core.request_options import RequestOptions
11
12
  from ..errors.unprocessable_entity_error import UnprocessableEntityError
12
- from ..types.check_feature_access_response import CheckFeatureAccessResponse
13
+ from ..types.billing_state_response import BillingStateResponse
13
14
  from ..types.http_validation_error import HttpValidationError
14
15
 
15
16
 
16
- class RawFeatureAccessClient:
17
+ class RawCustomerAccessClient:
17
18
  def __init__(self, *, client_wrapper: SyncClientWrapper):
18
19
  self._client_wrapper = client_wrapper
19
20
 
20
- def get_feature_access(
21
- self, *, request_options: typing.Optional[RequestOptions] = None
22
- ) -> HttpResponse[CheckFeatureAccessResponse]:
21
+ def get_billing_state(
22
+ self, subject_id: str, *, request_options: typing.Optional[RequestOptions] = None
23
+ ) -> HttpResponse[BillingStateResponse]:
23
24
  """
24
25
  Parameters
25
26
  ----------
27
+ subject_id : str
28
+
26
29
  request_options : typing.Optional[RequestOptions]
27
30
  Request-specific configuration.
28
31
 
29
32
  Returns
30
33
  -------
31
- HttpResponse[CheckFeatureAccessResponse]
34
+ HttpResponse[BillingStateResponse]
32
35
  Successful Response
33
36
  """
34
37
  _response = self._client_wrapper.httpx_client.request(
35
- "feature-access",
38
+ f"customer-access/{jsonable_encoder(subject_id)}/billing-state",
36
39
  method="GET",
37
40
  request_options=request_options,
38
41
  )
39
42
  try:
40
43
  if 200 <= _response.status_code < 300:
41
44
  _data = typing.cast(
42
- CheckFeatureAccessResponse,
45
+ BillingStateResponse,
43
46
  parse_obj_as(
44
- type_=CheckFeatureAccessResponse, # type: ignore
47
+ type_=BillingStateResponse, # type: ignore
45
48
  object_=_response.json(),
46
49
  ),
47
50
  )
@@ -63,35 +66,37 @@ class RawFeatureAccessClient:
63
66
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
64
67
 
65
68
 
66
- class AsyncRawFeatureAccessClient:
69
+ class AsyncRawCustomerAccessClient:
67
70
  def __init__(self, *, client_wrapper: AsyncClientWrapper):
68
71
  self._client_wrapper = client_wrapper
69
72
 
70
- async def get_feature_access(
71
- self, *, request_options: typing.Optional[RequestOptions] = None
72
- ) -> AsyncHttpResponse[CheckFeatureAccessResponse]:
73
+ async def get_billing_state(
74
+ self, subject_id: str, *, request_options: typing.Optional[RequestOptions] = None
75
+ ) -> AsyncHttpResponse[BillingStateResponse]:
73
76
  """
74
77
  Parameters
75
78
  ----------
79
+ subject_id : str
80
+
76
81
  request_options : typing.Optional[RequestOptions]
77
82
  Request-specific configuration.
78
83
 
79
84
  Returns
80
85
  -------
81
- AsyncHttpResponse[CheckFeatureAccessResponse]
86
+ AsyncHttpResponse[BillingStateResponse]
82
87
  Successful Response
83
88
  """
84
89
  _response = await self._client_wrapper.httpx_client.request(
85
- "feature-access",
90
+ f"customer-access/{jsonable_encoder(subject_id)}/billing-state",
86
91
  method="GET",
87
92
  request_options=request_options,
88
93
  )
89
94
  try:
90
95
  if 200 <= _response.status_code < 300:
91
96
  _data = typing.cast(
92
- CheckFeatureAccessResponse,
97
+ BillingStateResponse,
93
98
  parse_obj_as(
94
- type_=CheckFeatureAccessResponse, # type: ignore
99
+ type_=BillingStateResponse, # type: ignore
95
100
  object_=_response.json(),
96
101
  ),
97
102
  )
@@ -1,5 +1,4 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
- import typing
3
+ # isort: skip_file
4
4
 
5
- RateCard = typing.Optional[typing.Any]
@@ -0,0 +1,115 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
6
+ from ..core.request_options import RequestOptions
7
+ from ..types.create_customer_portal_session_response import CreateCustomerPortalSessionResponse
8
+ from .raw_client import AsyncRawCustomerPortalClient, RawCustomerPortalClient
9
+
10
+ # this is used as the default value for optional parameters
11
+ OMIT = typing.cast(typing.Any, ...)
12
+
13
+
14
+ class CustomerPortalClient:
15
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
16
+ self._raw_client = RawCustomerPortalClient(client_wrapper=client_wrapper)
17
+
18
+ @property
19
+ def with_raw_response(self) -> RawCustomerPortalClient:
20
+ """
21
+ Retrieves a raw implementation of this client that returns raw responses.
22
+
23
+ Returns
24
+ -------
25
+ RawCustomerPortalClient
26
+ """
27
+ return self._raw_client
28
+
29
+ def create_customer_portal_session(
30
+ self, *, subject_id: str, request_options: typing.Optional[RequestOptions] = None
31
+ ) -> CreateCustomerPortalSessionResponse:
32
+ """
33
+ Parameters
34
+ ----------
35
+ subject_id : str
36
+
37
+ request_options : typing.Optional[RequestOptions]
38
+ Request-specific configuration.
39
+
40
+ Returns
41
+ -------
42
+ CreateCustomerPortalSessionResponse
43
+ Successful Response
44
+
45
+ Examples
46
+ --------
47
+ from lark import Lark
48
+
49
+ client = Lark(
50
+ api_key="YOUR_API_KEY",
51
+ )
52
+ client.customer_portal.create_customer_portal_session(
53
+ subject_id="subject_id",
54
+ )
55
+ """
56
+ _response = self._raw_client.create_customer_portal_session(
57
+ subject_id=subject_id, request_options=request_options
58
+ )
59
+ return _response.data
60
+
61
+
62
+ class AsyncCustomerPortalClient:
63
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
64
+ self._raw_client = AsyncRawCustomerPortalClient(client_wrapper=client_wrapper)
65
+
66
+ @property
67
+ def with_raw_response(self) -> AsyncRawCustomerPortalClient:
68
+ """
69
+ Retrieves a raw implementation of this client that returns raw responses.
70
+
71
+ Returns
72
+ -------
73
+ AsyncRawCustomerPortalClient
74
+ """
75
+ return self._raw_client
76
+
77
+ async def create_customer_portal_session(
78
+ self, *, subject_id: str, request_options: typing.Optional[RequestOptions] = None
79
+ ) -> CreateCustomerPortalSessionResponse:
80
+ """
81
+ Parameters
82
+ ----------
83
+ subject_id : str
84
+
85
+ request_options : typing.Optional[RequestOptions]
86
+ Request-specific configuration.
87
+
88
+ Returns
89
+ -------
90
+ CreateCustomerPortalSessionResponse
91
+ Successful Response
92
+
93
+ Examples
94
+ --------
95
+ import asyncio
96
+
97
+ from lark import AsyncLark
98
+
99
+ client = AsyncLark(
100
+ api_key="YOUR_API_KEY",
101
+ )
102
+
103
+
104
+ async def main() -> None:
105
+ await client.customer_portal.create_customer_portal_session(
106
+ subject_id="subject_id",
107
+ )
108
+
109
+
110
+ asyncio.run(main())
111
+ """
112
+ _response = await self._raw_client.create_customer_portal_session(
113
+ subject_id=subject_id, request_options=request_options
114
+ )
115
+ return _response.data