lark-billing 0.5.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. lark/__init__.py +92 -0
  2. lark/_base_client.py +1995 -0
  3. lark/_client.py +459 -0
  4. lark/_compat.py +219 -0
  5. lark/_constants.py +14 -0
  6. lark/_exceptions.py +108 -0
  7. lark/_files.py +123 -0
  8. lark/_models.py +857 -0
  9. lark/_qs.py +150 -0
  10. lark/_resource.py +43 -0
  11. lark/_response.py +830 -0
  12. lark/_streaming.py +333 -0
  13. lark/_types.py +261 -0
  14. lark/_utils/__init__.py +64 -0
  15. lark/_utils/_compat.py +45 -0
  16. lark/_utils/_datetime_parse.py +136 -0
  17. lark/_utils/_logs.py +25 -0
  18. lark/_utils/_proxy.py +65 -0
  19. lark/_utils/_reflection.py +42 -0
  20. lark/_utils/_resources_proxy.py +24 -0
  21. lark/_utils/_streams.py +12 -0
  22. lark/_utils/_sync.py +58 -0
  23. lark/_utils/_transform.py +457 -0
  24. lark/_utils/_typing.py +156 -0
  25. lark/_utils/_utils.py +421 -0
  26. lark/_version.py +4 -0
  27. lark/lib/.keep +4 -0
  28. lark/py.typed +0 -0
  29. lark/resources/__init__.py +117 -0
  30. lark/resources/customer_access.py +167 -0
  31. lark/resources/customer_portal.py +187 -0
  32. lark/resources/invoices.py +191 -0
  33. lark/resources/pricing_metrics.py +499 -0
  34. lark/resources/rate_cards.py +395 -0
  35. lark/resources/subjects.py +579 -0
  36. lark/resources/subscriptions.py +647 -0
  37. lark/resources/usage_events.py +221 -0
  38. lark/types/__init__.py +53 -0
  39. lark/types/amount_input_param.py +16 -0
  40. lark/types/amount_output.py +13 -0
  41. lark/types/checkout_callback_param.py +15 -0
  42. lark/types/customer_access_retrieve_billing_state_response.py +40 -0
  43. lark/types/customer_portal_create_session_params.py +18 -0
  44. lark/types/customer_portal_create_session_response.py +18 -0
  45. lark/types/flat_price_input_param.py +17 -0
  46. lark/types/flat_price_output.py +17 -0
  47. lark/types/invoice_list_params.py +16 -0
  48. lark/types/invoice_list_response.py +49 -0
  49. lark/types/package_price_input_param.py +24 -0
  50. lark/types/package_price_output.py +24 -0
  51. lark/types/period.py +18 -0
  52. lark/types/period_param.py +21 -0
  53. lark/types/pricing_metric_create_params.py +98 -0
  54. lark/types/pricing_metric_create_summary_params.py +25 -0
  55. lark/types/pricing_metric_create_summary_response.py +36 -0
  56. lark/types/pricing_metric_list_params.py +11 -0
  57. lark/types/pricing_metric_list_response.py +14 -0
  58. lark/types/pricing_metric_resource.py +72 -0
  59. lark/types/rate_card_create_params.py +148 -0
  60. lark/types/rate_card_list_params.py +13 -0
  61. lark/types/rate_card_list_response.py +14 -0
  62. lark/types/rate_card_resource.py +141 -0
  63. lark/types/subject_create_params.py +29 -0
  64. lark/types/subject_create_response.py +34 -0
  65. lark/types/subject_list_params.py +13 -0
  66. lark/types/subject_list_response.py +14 -0
  67. lark/types/subject_resource.py +34 -0
  68. lark/types/subject_update_params.py +22 -0
  69. lark/types/subscription_cancel_params.py +16 -0
  70. lark/types/subscription_change_rate_card_params.py +29 -0
  71. lark/types/subscription_change_rate_card_response.py +55 -0
  72. lark/types/subscription_create_params.py +38 -0
  73. lark/types/subscription_create_response.py +55 -0
  74. lark/types/subscription_list_params.py +26 -0
  75. lark/types/subscription_list_response.py +14 -0
  76. lark/types/subscription_resource.py +49 -0
  77. lark/types/usage_event_create_params.py +41 -0
  78. lark_billing-0.5.0.dist-info/METADATA +431 -0
  79. lark_billing-0.5.0.dist-info/RECORD +81 -0
  80. lark_billing-0.5.0.dist-info/WHEEL +4 -0
  81. lark_billing-0.5.0.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,395 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Dict, Iterable, Optional
6
+ from typing_extensions import Literal
7
+
8
+ import httpx
9
+
10
+ from ..types import rate_card_list_params, rate_card_create_params
11
+ from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
12
+ from .._utils import maybe_transform, async_maybe_transform
13
+ from .._compat import cached_property
14
+ from .._resource import SyncAPIResource, AsyncAPIResource
15
+ from .._response import (
16
+ to_raw_response_wrapper,
17
+ to_streamed_response_wrapper,
18
+ async_to_raw_response_wrapper,
19
+ async_to_streamed_response_wrapper,
20
+ )
21
+ from .._base_client import make_request_options
22
+ from ..types.rate_card_resource import RateCardResource
23
+ from ..types.rate_card_list_response import RateCardListResponse
24
+
25
+ __all__ = ["RateCardsResource", "AsyncRateCardsResource"]
26
+
27
+
28
+ class RateCardsResource(SyncAPIResource):
29
+ @cached_property
30
+ def with_raw_response(self) -> RateCardsResourceWithRawResponse:
31
+ """
32
+ This property can be used as a prefix for any HTTP method call to return
33
+ the raw response object instead of the parsed content.
34
+
35
+ For more information, see https://www.github.com/uselark/lark-billing-python#accessing-raw-response-data-eg-headers
36
+ """
37
+ return RateCardsResourceWithRawResponse(self)
38
+
39
+ @cached_property
40
+ def with_streaming_response(self) -> RateCardsResourceWithStreamingResponse:
41
+ """
42
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
43
+
44
+ For more information, see https://www.github.com/uselark/lark-billing-python#with_streaming_response
45
+ """
46
+ return RateCardsResourceWithStreamingResponse(self)
47
+
48
+ def create(
49
+ self,
50
+ *,
51
+ billing_interval: Literal["monthly", "yearly"],
52
+ name: str,
53
+ description: Optional[str] | Omit = omit,
54
+ fixed_rates: Iterable[rate_card_create_params.FixedRate] | Omit = omit,
55
+ metadata: Dict[str, str] | Omit = omit,
56
+ usage_based_rates: Iterable[rate_card_create_params.UsageBasedRate] | Omit = omit,
57
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
58
+ # The extra values given here take precedence over values defined on the client or passed to this method.
59
+ extra_headers: Headers | None = None,
60
+ extra_query: Query | None = None,
61
+ extra_body: Body | None = None,
62
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
63
+ ) -> RateCardResource:
64
+ """
65
+ Create Rate Card
66
+
67
+ Args:
68
+ billing_interval: How often the customer will be billed for this rate card.
69
+
70
+ name: The name of the rate card displayed to the customer.
71
+
72
+ description: The description of the rate card displayed to the customer.
73
+
74
+ fixed_rates: The fixed rates of the rate card. These are billed at the start of each billing
75
+ cycle.
76
+
77
+ usage_based_rates: The usage based rates of the rate card. These are billed at the end of each
78
+ billing cycle.
79
+
80
+ extra_headers: Send extra headers
81
+
82
+ extra_query: Add additional query parameters to the request
83
+
84
+ extra_body: Add additional JSON properties to the request
85
+
86
+ timeout: Override the client-level default timeout for this request, in seconds
87
+ """
88
+ return self._post(
89
+ "/rate-cards",
90
+ body=maybe_transform(
91
+ {
92
+ "billing_interval": billing_interval,
93
+ "name": name,
94
+ "description": description,
95
+ "fixed_rates": fixed_rates,
96
+ "metadata": metadata,
97
+ "usage_based_rates": usage_based_rates,
98
+ },
99
+ rate_card_create_params.RateCardCreateParams,
100
+ ),
101
+ options=make_request_options(
102
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
103
+ ),
104
+ cast_to=RateCardResource,
105
+ )
106
+
107
+ def retrieve(
108
+ self,
109
+ rate_card_id: str,
110
+ *,
111
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
112
+ # The extra values given here take precedence over values defined on the client or passed to this method.
113
+ extra_headers: Headers | None = None,
114
+ extra_query: Query | None = None,
115
+ extra_body: Body | None = None,
116
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
117
+ ) -> RateCardResource:
118
+ """
119
+ Get Rate Card
120
+
121
+ Args:
122
+ extra_headers: Send extra headers
123
+
124
+ extra_query: Add additional query parameters to the request
125
+
126
+ extra_body: Add additional JSON properties to the request
127
+
128
+ timeout: Override the client-level default timeout for this request, in seconds
129
+ """
130
+ if not rate_card_id:
131
+ raise ValueError(f"Expected a non-empty value for `rate_card_id` but received {rate_card_id!r}")
132
+ return self._get(
133
+ f"/rate-cards/{rate_card_id}",
134
+ options=make_request_options(
135
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
136
+ ),
137
+ cast_to=RateCardResource,
138
+ )
139
+
140
+ def list(
141
+ self,
142
+ *,
143
+ limit: int | Omit = omit,
144
+ offset: int | Omit = omit,
145
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
146
+ # The extra values given here take precedence over values defined on the client or passed to this method.
147
+ extra_headers: Headers | None = None,
148
+ extra_query: Query | None = None,
149
+ extra_body: Body | None = None,
150
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
151
+ ) -> RateCardListResponse:
152
+ """
153
+ List Rate Cards
154
+
155
+ Args:
156
+ extra_headers: Send extra headers
157
+
158
+ extra_query: Add additional query parameters to the request
159
+
160
+ extra_body: Add additional JSON properties to the request
161
+
162
+ timeout: Override the client-level default timeout for this request, in seconds
163
+ """
164
+ return self._get(
165
+ "/rate-cards",
166
+ options=make_request_options(
167
+ extra_headers=extra_headers,
168
+ extra_query=extra_query,
169
+ extra_body=extra_body,
170
+ timeout=timeout,
171
+ query=maybe_transform(
172
+ {
173
+ "limit": limit,
174
+ "offset": offset,
175
+ },
176
+ rate_card_list_params.RateCardListParams,
177
+ ),
178
+ ),
179
+ cast_to=RateCardListResponse,
180
+ )
181
+
182
+
183
+ class AsyncRateCardsResource(AsyncAPIResource):
184
+ @cached_property
185
+ def with_raw_response(self) -> AsyncRateCardsResourceWithRawResponse:
186
+ """
187
+ This property can be used as a prefix for any HTTP method call to return
188
+ the raw response object instead of the parsed content.
189
+
190
+ For more information, see https://www.github.com/uselark/lark-billing-python#accessing-raw-response-data-eg-headers
191
+ """
192
+ return AsyncRateCardsResourceWithRawResponse(self)
193
+
194
+ @cached_property
195
+ def with_streaming_response(self) -> AsyncRateCardsResourceWithStreamingResponse:
196
+ """
197
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
198
+
199
+ For more information, see https://www.github.com/uselark/lark-billing-python#with_streaming_response
200
+ """
201
+ return AsyncRateCardsResourceWithStreamingResponse(self)
202
+
203
+ async def create(
204
+ self,
205
+ *,
206
+ billing_interval: Literal["monthly", "yearly"],
207
+ name: str,
208
+ description: Optional[str] | Omit = omit,
209
+ fixed_rates: Iterable[rate_card_create_params.FixedRate] | Omit = omit,
210
+ metadata: Dict[str, str] | Omit = omit,
211
+ usage_based_rates: Iterable[rate_card_create_params.UsageBasedRate] | Omit = omit,
212
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
213
+ # The extra values given here take precedence over values defined on the client or passed to this method.
214
+ extra_headers: Headers | None = None,
215
+ extra_query: Query | None = None,
216
+ extra_body: Body | None = None,
217
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
218
+ ) -> RateCardResource:
219
+ """
220
+ Create Rate Card
221
+
222
+ Args:
223
+ billing_interval: How often the customer will be billed for this rate card.
224
+
225
+ name: The name of the rate card displayed to the customer.
226
+
227
+ description: The description of the rate card displayed to the customer.
228
+
229
+ fixed_rates: The fixed rates of the rate card. These are billed at the start of each billing
230
+ cycle.
231
+
232
+ usage_based_rates: The usage based rates of the rate card. These are billed at the end of each
233
+ billing cycle.
234
+
235
+ extra_headers: Send extra headers
236
+
237
+ extra_query: Add additional query parameters to the request
238
+
239
+ extra_body: Add additional JSON properties to the request
240
+
241
+ timeout: Override the client-level default timeout for this request, in seconds
242
+ """
243
+ return await self._post(
244
+ "/rate-cards",
245
+ body=await async_maybe_transform(
246
+ {
247
+ "billing_interval": billing_interval,
248
+ "name": name,
249
+ "description": description,
250
+ "fixed_rates": fixed_rates,
251
+ "metadata": metadata,
252
+ "usage_based_rates": usage_based_rates,
253
+ },
254
+ rate_card_create_params.RateCardCreateParams,
255
+ ),
256
+ options=make_request_options(
257
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
258
+ ),
259
+ cast_to=RateCardResource,
260
+ )
261
+
262
+ async def retrieve(
263
+ self,
264
+ rate_card_id: str,
265
+ *,
266
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
267
+ # The extra values given here take precedence over values defined on the client or passed to this method.
268
+ extra_headers: Headers | None = None,
269
+ extra_query: Query | None = None,
270
+ extra_body: Body | None = None,
271
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
272
+ ) -> RateCardResource:
273
+ """
274
+ Get Rate Card
275
+
276
+ Args:
277
+ extra_headers: Send extra headers
278
+
279
+ extra_query: Add additional query parameters to the request
280
+
281
+ extra_body: Add additional JSON properties to the request
282
+
283
+ timeout: Override the client-level default timeout for this request, in seconds
284
+ """
285
+ if not rate_card_id:
286
+ raise ValueError(f"Expected a non-empty value for `rate_card_id` but received {rate_card_id!r}")
287
+ return await self._get(
288
+ f"/rate-cards/{rate_card_id}",
289
+ options=make_request_options(
290
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
291
+ ),
292
+ cast_to=RateCardResource,
293
+ )
294
+
295
+ async def list(
296
+ self,
297
+ *,
298
+ limit: int | Omit = omit,
299
+ offset: int | Omit = omit,
300
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
301
+ # The extra values given here take precedence over values defined on the client or passed to this method.
302
+ extra_headers: Headers | None = None,
303
+ extra_query: Query | None = None,
304
+ extra_body: Body | None = None,
305
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
306
+ ) -> RateCardListResponse:
307
+ """
308
+ List Rate Cards
309
+
310
+ Args:
311
+ extra_headers: Send extra headers
312
+
313
+ extra_query: Add additional query parameters to the request
314
+
315
+ extra_body: Add additional JSON properties to the request
316
+
317
+ timeout: Override the client-level default timeout for this request, in seconds
318
+ """
319
+ return await self._get(
320
+ "/rate-cards",
321
+ options=make_request_options(
322
+ extra_headers=extra_headers,
323
+ extra_query=extra_query,
324
+ extra_body=extra_body,
325
+ timeout=timeout,
326
+ query=await async_maybe_transform(
327
+ {
328
+ "limit": limit,
329
+ "offset": offset,
330
+ },
331
+ rate_card_list_params.RateCardListParams,
332
+ ),
333
+ ),
334
+ cast_to=RateCardListResponse,
335
+ )
336
+
337
+
338
+ class RateCardsResourceWithRawResponse:
339
+ def __init__(self, rate_cards: RateCardsResource) -> None:
340
+ self._rate_cards = rate_cards
341
+
342
+ self.create = to_raw_response_wrapper(
343
+ rate_cards.create,
344
+ )
345
+ self.retrieve = to_raw_response_wrapper(
346
+ rate_cards.retrieve,
347
+ )
348
+ self.list = to_raw_response_wrapper(
349
+ rate_cards.list,
350
+ )
351
+
352
+
353
+ class AsyncRateCardsResourceWithRawResponse:
354
+ def __init__(self, rate_cards: AsyncRateCardsResource) -> None:
355
+ self._rate_cards = rate_cards
356
+
357
+ self.create = async_to_raw_response_wrapper(
358
+ rate_cards.create,
359
+ )
360
+ self.retrieve = async_to_raw_response_wrapper(
361
+ rate_cards.retrieve,
362
+ )
363
+ self.list = async_to_raw_response_wrapper(
364
+ rate_cards.list,
365
+ )
366
+
367
+
368
+ class RateCardsResourceWithStreamingResponse:
369
+ def __init__(self, rate_cards: RateCardsResource) -> None:
370
+ self._rate_cards = rate_cards
371
+
372
+ self.create = to_streamed_response_wrapper(
373
+ rate_cards.create,
374
+ )
375
+ self.retrieve = to_streamed_response_wrapper(
376
+ rate_cards.retrieve,
377
+ )
378
+ self.list = to_streamed_response_wrapper(
379
+ rate_cards.list,
380
+ )
381
+
382
+
383
+ class AsyncRateCardsResourceWithStreamingResponse:
384
+ def __init__(self, rate_cards: AsyncRateCardsResource) -> None:
385
+ self._rate_cards = rate_cards
386
+
387
+ self.create = async_to_streamed_response_wrapper(
388
+ rate_cards.create,
389
+ )
390
+ self.retrieve = async_to_streamed_response_wrapper(
391
+ rate_cards.retrieve,
392
+ )
393
+ self.list = async_to_streamed_response_wrapper(
394
+ rate_cards.list,
395
+ )