payi 0.1.0a26__py3-none-any.whl → 0.1.0a28__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 payi might be problematic. Click here for more details.
- payi/_base_client.py +9 -2
- payi/_client.py +16 -0
- payi/_compat.py +5 -3
- payi/_models.py +11 -8
- payi/_response.py +3 -0
- payi/_types.py +4 -2
- payi/_utils/__init__.py +1 -0
- payi/_utils/_transform.py +12 -2
- payi/_utils/_utils.py +17 -0
- payi/_version.py +1 -1
- payi/resources/__init__.py +28 -0
- payi/resources/billing_models.py +492 -0
- payi/resources/budgets/budgets.py +4 -4
- payi/resources/categories/resources.py +5 -9
- payi/resources/ingest.py +19 -10
- payi/resources/price_modifiers.py +353 -0
- payi/types/__init__.py +8 -0
- payi/types/billing_model.py +29 -0
- payi/types/billing_model_create_params.py +20 -0
- payi/types/billing_model_list_response.py +10 -0
- payi/types/billing_model_update_params.py +20 -0
- payi/types/budget_create_params.py +2 -2
- payi/types/budget_response.py +2 -2
- payi/types/categories/resource_create_params.py +9 -5
- payi/types/category_resource_response.py +9 -5
- payi/types/cost_data.py +0 -1
- payi/types/csat.py +0 -1
- payi/types/experience_instance.py +0 -1
- payi/types/experiences/experience_type.py +0 -1
- payi/types/ingest_event_param.py +12 -6
- payi/types/ingest_response.py +7 -1
- payi/types/ingest_units_params.py +11 -6
- payi/types/paged_budget_list.py +2 -2
- payi/types/price_modifier.py +26 -0
- payi/types/price_modifier_create_params.py +17 -0
- payi/types/price_modifier_retrieve_response.py +10 -0
- payi/types/price_modifier_update_params.py +17 -0
- payi/types/requests_data.py +2 -1
- payi/types/total_cost_data.py +0 -1
- {payi-0.1.0a26.dist-info → payi-0.1.0a28.dist-info}/METADATA +11 -11
- {payi-0.1.0a26.dist-info → payi-0.1.0a28.dist-info}/RECORD +43 -37
- {payi-0.1.0a26.dist-info → payi-0.1.0a28.dist-info}/WHEEL +1 -1
- payi/types/evaluations/__init__.py +0 -6
- payi/types/evaluations/experience_create_params.py +0 -14
- payi/types/evaluations/request_create_params.py +0 -14
- payi/types/shared/__init__.py +0 -2
- {payi-0.1.0a26.dist-info → payi-0.1.0a28.dist-info}/licenses/LICENSE +0 -0
payi/_base_client.py
CHANGED
|
@@ -143,6 +143,12 @@ class PageInfo:
|
|
|
143
143
|
self.url = url
|
|
144
144
|
self.params = params
|
|
145
145
|
|
|
146
|
+
@override
|
|
147
|
+
def __repr__(self) -> str:
|
|
148
|
+
if self.url:
|
|
149
|
+
return f"{self.__class__.__name__}(url={self.url})"
|
|
150
|
+
return f"{self.__class__.__name__}(params={self.params})"
|
|
151
|
+
|
|
146
152
|
|
|
147
153
|
class BasePage(GenericModel, Generic[_T]):
|
|
148
154
|
"""
|
|
@@ -689,7 +695,8 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
|
|
|
689
695
|
if retry_after is not None and 0 < retry_after <= 60:
|
|
690
696
|
return retry_after
|
|
691
697
|
|
|
692
|
-
|
|
698
|
+
# Also cap retry count to 1000 to avoid any potential overflows with `pow`
|
|
699
|
+
nb_retries = min(max_retries - remaining_retries, 1000)
|
|
693
700
|
|
|
694
701
|
# Apply exponential backoff, but not more than the max.
|
|
695
702
|
sleep_seconds = min(INITIAL_RETRY_DELAY * pow(2.0, nb_retries), MAX_RETRY_DELAY)
|
|
@@ -1568,7 +1575,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
|
|
|
1568
1575
|
except Exception as err:
|
|
1569
1576
|
log.debug("Encountered Exception", exc_info=True)
|
|
1570
1577
|
|
|
1571
|
-
if
|
|
1578
|
+
if remaining_retries > 0:
|
|
1572
1579
|
return await self._retry_request(
|
|
1573
1580
|
input_options,
|
|
1574
1581
|
cast_to,
|
payi/_client.py
CHANGED
|
@@ -51,6 +51,8 @@ class Payi(SyncAPIClient):
|
|
|
51
51
|
categories: resources.CategoriesResource
|
|
52
52
|
experiences: resources.ExperiencesResource
|
|
53
53
|
csat: resources.CsatResource
|
|
54
|
+
billing_models: resources.BillingModelsResource
|
|
55
|
+
price_modifiers: resources.PriceModifiersResource
|
|
54
56
|
with_raw_response: PayiWithRawResponse
|
|
55
57
|
with_streaming_response: PayiWithStreamedResponse
|
|
56
58
|
|
|
@@ -113,6 +115,8 @@ class Payi(SyncAPIClient):
|
|
|
113
115
|
self.categories = resources.CategoriesResource(self)
|
|
114
116
|
self.experiences = resources.ExperiencesResource(self)
|
|
115
117
|
self.csat = resources.CsatResource(self)
|
|
118
|
+
self.billing_models = resources.BillingModelsResource(self)
|
|
119
|
+
self.price_modifiers = resources.PriceModifiersResource(self)
|
|
116
120
|
self.with_raw_response = PayiWithRawResponse(self)
|
|
117
121
|
self.with_streaming_response = PayiWithStreamedResponse(self)
|
|
118
122
|
|
|
@@ -227,6 +231,8 @@ class AsyncPayi(AsyncAPIClient):
|
|
|
227
231
|
categories: resources.AsyncCategoriesResource
|
|
228
232
|
experiences: resources.AsyncExperiencesResource
|
|
229
233
|
csat: resources.AsyncCsatResource
|
|
234
|
+
billing_models: resources.AsyncBillingModelsResource
|
|
235
|
+
price_modifiers: resources.AsyncPriceModifiersResource
|
|
230
236
|
with_raw_response: AsyncPayiWithRawResponse
|
|
231
237
|
with_streaming_response: AsyncPayiWithStreamedResponse
|
|
232
238
|
|
|
@@ -289,6 +295,8 @@ class AsyncPayi(AsyncAPIClient):
|
|
|
289
295
|
self.categories = resources.AsyncCategoriesResource(self)
|
|
290
296
|
self.experiences = resources.AsyncExperiencesResource(self)
|
|
291
297
|
self.csat = resources.AsyncCsatResource(self)
|
|
298
|
+
self.billing_models = resources.AsyncBillingModelsResource(self)
|
|
299
|
+
self.price_modifiers = resources.AsyncPriceModifiersResource(self)
|
|
292
300
|
self.with_raw_response = AsyncPayiWithRawResponse(self)
|
|
293
301
|
self.with_streaming_response = AsyncPayiWithStreamedResponse(self)
|
|
294
302
|
|
|
@@ -404,6 +412,8 @@ class PayiWithRawResponse:
|
|
|
404
412
|
self.categories = resources.CategoriesResourceWithRawResponse(client.categories)
|
|
405
413
|
self.experiences = resources.ExperiencesResourceWithRawResponse(client.experiences)
|
|
406
414
|
self.csat = resources.CsatResourceWithRawResponse(client.csat)
|
|
415
|
+
self.billing_models = resources.BillingModelsResourceWithRawResponse(client.billing_models)
|
|
416
|
+
self.price_modifiers = resources.PriceModifiersResourceWithRawResponse(client.price_modifiers)
|
|
407
417
|
|
|
408
418
|
|
|
409
419
|
class AsyncPayiWithRawResponse:
|
|
@@ -413,6 +423,8 @@ class AsyncPayiWithRawResponse:
|
|
|
413
423
|
self.categories = resources.AsyncCategoriesResourceWithRawResponse(client.categories)
|
|
414
424
|
self.experiences = resources.AsyncExperiencesResourceWithRawResponse(client.experiences)
|
|
415
425
|
self.csat = resources.AsyncCsatResourceWithRawResponse(client.csat)
|
|
426
|
+
self.billing_models = resources.AsyncBillingModelsResourceWithRawResponse(client.billing_models)
|
|
427
|
+
self.price_modifiers = resources.AsyncPriceModifiersResourceWithRawResponse(client.price_modifiers)
|
|
416
428
|
|
|
417
429
|
|
|
418
430
|
class PayiWithStreamedResponse:
|
|
@@ -422,6 +434,8 @@ class PayiWithStreamedResponse:
|
|
|
422
434
|
self.categories = resources.CategoriesResourceWithStreamingResponse(client.categories)
|
|
423
435
|
self.experiences = resources.ExperiencesResourceWithStreamingResponse(client.experiences)
|
|
424
436
|
self.csat = resources.CsatResourceWithStreamingResponse(client.csat)
|
|
437
|
+
self.billing_models = resources.BillingModelsResourceWithStreamingResponse(client.billing_models)
|
|
438
|
+
self.price_modifiers = resources.PriceModifiersResourceWithStreamingResponse(client.price_modifiers)
|
|
425
439
|
|
|
426
440
|
|
|
427
441
|
class AsyncPayiWithStreamedResponse:
|
|
@@ -431,6 +445,8 @@ class AsyncPayiWithStreamedResponse:
|
|
|
431
445
|
self.categories = resources.AsyncCategoriesResourceWithStreamingResponse(client.categories)
|
|
432
446
|
self.experiences = resources.AsyncExperiencesResourceWithStreamingResponse(client.experiences)
|
|
433
447
|
self.csat = resources.AsyncCsatResourceWithStreamingResponse(client.csat)
|
|
448
|
+
self.billing_models = resources.AsyncBillingModelsResourceWithStreamingResponse(client.billing_models)
|
|
449
|
+
self.price_modifiers = resources.AsyncPriceModifiersResourceWithStreamingResponse(client.price_modifiers)
|
|
434
450
|
|
|
435
451
|
|
|
436
452
|
Client = Payi
|
payi/_compat.py
CHANGED
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from typing import TYPE_CHECKING, Any, Union, Generic, TypeVar, Callable, cast, overload
|
|
4
4
|
from datetime import date, datetime
|
|
5
|
-
from typing_extensions import Self
|
|
5
|
+
from typing_extensions import Self, Literal
|
|
6
6
|
|
|
7
7
|
import pydantic
|
|
8
8
|
from pydantic.fields import FieldInfo
|
|
@@ -133,13 +133,15 @@ def model_json(model: pydantic.BaseModel, *, indent: int | None = None) -> str:
|
|
|
133
133
|
def model_dump(
|
|
134
134
|
model: pydantic.BaseModel,
|
|
135
135
|
*,
|
|
136
|
-
exclude: IncEx = None,
|
|
136
|
+
exclude: IncEx | None = None,
|
|
137
137
|
exclude_unset: bool = False,
|
|
138
138
|
exclude_defaults: bool = False,
|
|
139
139
|
warnings: bool = True,
|
|
140
|
+
mode: Literal["json", "python"] = "python",
|
|
140
141
|
) -> dict[str, Any]:
|
|
141
|
-
if PYDANTIC_V2:
|
|
142
|
+
if PYDANTIC_V2 or hasattr(model, "model_dump"):
|
|
142
143
|
return model.model_dump(
|
|
144
|
+
mode=mode,
|
|
143
145
|
exclude=exclude,
|
|
144
146
|
exclude_unset=exclude_unset,
|
|
145
147
|
exclude_defaults=exclude_defaults,
|
payi/_models.py
CHANGED
|
@@ -37,6 +37,7 @@ from ._utils import (
|
|
|
37
37
|
PropertyInfo,
|
|
38
38
|
is_list,
|
|
39
39
|
is_given,
|
|
40
|
+
json_safe,
|
|
40
41
|
lru_cache,
|
|
41
42
|
is_mapping,
|
|
42
43
|
parse_date,
|
|
@@ -176,7 +177,7 @@ class BaseModel(pydantic.BaseModel):
|
|
|
176
177
|
# Based on https://github.com/samuelcolvin/pydantic/issues/1168#issuecomment-817742836.
|
|
177
178
|
@classmethod
|
|
178
179
|
@override
|
|
179
|
-
def construct(
|
|
180
|
+
def construct( # pyright: ignore[reportIncompatibleMethodOverride]
|
|
180
181
|
cls: Type[ModelT],
|
|
181
182
|
_fields_set: set[str] | None = None,
|
|
182
183
|
**values: object,
|
|
@@ -248,8 +249,8 @@ class BaseModel(pydantic.BaseModel):
|
|
|
248
249
|
self,
|
|
249
250
|
*,
|
|
250
251
|
mode: Literal["json", "python"] | str = "python",
|
|
251
|
-
include: IncEx = None,
|
|
252
|
-
exclude: IncEx = None,
|
|
252
|
+
include: IncEx | None = None,
|
|
253
|
+
exclude: IncEx | None = None,
|
|
253
254
|
by_alias: bool = False,
|
|
254
255
|
exclude_unset: bool = False,
|
|
255
256
|
exclude_defaults: bool = False,
|
|
@@ -279,8 +280,8 @@ class BaseModel(pydantic.BaseModel):
|
|
|
279
280
|
Returns:
|
|
280
281
|
A dictionary representation of the model.
|
|
281
282
|
"""
|
|
282
|
-
if mode
|
|
283
|
-
raise ValueError("mode
|
|
283
|
+
if mode not in {"json", "python"}:
|
|
284
|
+
raise ValueError("mode must be either 'json' or 'python'")
|
|
284
285
|
if round_trip != False:
|
|
285
286
|
raise ValueError("round_trip is only supported in Pydantic v2")
|
|
286
287
|
if warnings != True:
|
|
@@ -289,7 +290,7 @@ class BaseModel(pydantic.BaseModel):
|
|
|
289
290
|
raise ValueError("context is only supported in Pydantic v2")
|
|
290
291
|
if serialize_as_any != False:
|
|
291
292
|
raise ValueError("serialize_as_any is only supported in Pydantic v2")
|
|
292
|
-
|
|
293
|
+
dumped = super().dict( # pyright: ignore[reportDeprecated]
|
|
293
294
|
include=include,
|
|
294
295
|
exclude=exclude,
|
|
295
296
|
by_alias=by_alias,
|
|
@@ -298,13 +299,15 @@ class BaseModel(pydantic.BaseModel):
|
|
|
298
299
|
exclude_none=exclude_none,
|
|
299
300
|
)
|
|
300
301
|
|
|
302
|
+
return cast(dict[str, Any], json_safe(dumped)) if mode == "json" else dumped
|
|
303
|
+
|
|
301
304
|
@override
|
|
302
305
|
def model_dump_json(
|
|
303
306
|
self,
|
|
304
307
|
*,
|
|
305
308
|
indent: int | None = None,
|
|
306
|
-
include: IncEx = None,
|
|
307
|
-
exclude: IncEx = None,
|
|
309
|
+
include: IncEx | None = None,
|
|
310
|
+
exclude: IncEx | None = None,
|
|
308
311
|
by_alias: bool = False,
|
|
309
312
|
exclude_unset: bool = False,
|
|
310
313
|
exclude_defaults: bool = False,
|
payi/_response.py
CHANGED
|
@@ -192,6 +192,9 @@ class BaseAPIResponse(Generic[R]):
|
|
|
192
192
|
if cast_to == float:
|
|
193
193
|
return cast(R, float(response.text))
|
|
194
194
|
|
|
195
|
+
if cast_to == bool:
|
|
196
|
+
return cast(R, response.text.lower() == "true")
|
|
197
|
+
|
|
195
198
|
origin = get_origin(cast_to) or cast_to
|
|
196
199
|
|
|
197
200
|
if origin == APIResponse:
|
payi/_types.py
CHANGED
|
@@ -16,7 +16,7 @@ from typing import (
|
|
|
16
16
|
Optional,
|
|
17
17
|
Sequence,
|
|
18
18
|
)
|
|
19
|
-
from typing_extensions import Literal, Protocol, TypeAlias, TypedDict, override, runtime_checkable
|
|
19
|
+
from typing_extensions import Set, Literal, Protocol, TypeAlias, TypedDict, override, runtime_checkable
|
|
20
20
|
|
|
21
21
|
import httpx
|
|
22
22
|
import pydantic
|
|
@@ -193,7 +193,9 @@ StrBytesIntFloat = Union[str, bytes, int, float]
|
|
|
193
193
|
|
|
194
194
|
# Note: copied from Pydantic
|
|
195
195
|
# https://github.com/pydantic/pydantic/blob/32ea570bf96e84234d2992e1ddf40ab8a565925a/pydantic/main.py#L49
|
|
196
|
-
IncEx: TypeAlias =
|
|
196
|
+
IncEx: TypeAlias = Union[
|
|
197
|
+
Set[int], Set[str], Mapping[int, Union["IncEx", Literal[True]]], Mapping[str, Union["IncEx", Literal[True]]]
|
|
198
|
+
]
|
|
197
199
|
|
|
198
200
|
PostParser = Callable[[Any], Any]
|
|
199
201
|
|
payi/_utils/__init__.py
CHANGED
payi/_utils/_transform.py
CHANGED
|
@@ -173,6 +173,11 @@ def _transform_recursive(
|
|
|
173
173
|
# Iterable[T]
|
|
174
174
|
or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str))
|
|
175
175
|
):
|
|
176
|
+
# dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually
|
|
177
|
+
# intended as an iterable, so we don't transform it.
|
|
178
|
+
if isinstance(data, dict):
|
|
179
|
+
return cast(object, data)
|
|
180
|
+
|
|
176
181
|
inner_type = extract_type_arg(stripped_type, 0)
|
|
177
182
|
return [_transform_recursive(d, annotation=annotation, inner_type=inner_type) for d in data]
|
|
178
183
|
|
|
@@ -186,7 +191,7 @@ def _transform_recursive(
|
|
|
186
191
|
return data
|
|
187
192
|
|
|
188
193
|
if isinstance(data, pydantic.BaseModel):
|
|
189
|
-
return model_dump(data, exclude_unset=True)
|
|
194
|
+
return model_dump(data, exclude_unset=True, mode="json")
|
|
190
195
|
|
|
191
196
|
annotated_type = _get_annotated_type(annotation)
|
|
192
197
|
if annotated_type is None:
|
|
@@ -311,6 +316,11 @@ async def _async_transform_recursive(
|
|
|
311
316
|
# Iterable[T]
|
|
312
317
|
or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str))
|
|
313
318
|
):
|
|
319
|
+
# dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually
|
|
320
|
+
# intended as an iterable, so we don't transform it.
|
|
321
|
+
if isinstance(data, dict):
|
|
322
|
+
return cast(object, data)
|
|
323
|
+
|
|
314
324
|
inner_type = extract_type_arg(stripped_type, 0)
|
|
315
325
|
return [await _async_transform_recursive(d, annotation=annotation, inner_type=inner_type) for d in data]
|
|
316
326
|
|
|
@@ -324,7 +334,7 @@ async def _async_transform_recursive(
|
|
|
324
334
|
return data
|
|
325
335
|
|
|
326
336
|
if isinstance(data, pydantic.BaseModel):
|
|
327
|
-
return model_dump(data, exclude_unset=True)
|
|
337
|
+
return model_dump(data, exclude_unset=True, mode="json")
|
|
328
338
|
|
|
329
339
|
annotated_type = _get_annotated_type(annotation)
|
|
330
340
|
if annotated_type is None:
|
payi/_utils/_utils.py
CHANGED
|
@@ -16,6 +16,7 @@ from typing import (
|
|
|
16
16
|
overload,
|
|
17
17
|
)
|
|
18
18
|
from pathlib import Path
|
|
19
|
+
from datetime import date, datetime
|
|
19
20
|
from typing_extensions import TypeGuard
|
|
20
21
|
|
|
21
22
|
import sniffio
|
|
@@ -395,3 +396,19 @@ def lru_cache(*, maxsize: int | None = 128) -> Callable[[CallableT], CallableT]:
|
|
|
395
396
|
maxsize=maxsize,
|
|
396
397
|
)
|
|
397
398
|
return cast(Any, wrapper) # type: ignore[no-any-return]
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
def json_safe(data: object) -> object:
|
|
402
|
+
"""Translates a mapping / sequence recursively in the same fashion
|
|
403
|
+
as `pydantic` v2's `model_dump(mode="json")`.
|
|
404
|
+
"""
|
|
405
|
+
if is_mapping(data):
|
|
406
|
+
return {json_safe(key): json_safe(value) for key, value in data.items()}
|
|
407
|
+
|
|
408
|
+
if is_iterable(data) and not isinstance(data, (str, bytes, bytearray)):
|
|
409
|
+
return [json_safe(item) for item in data]
|
|
410
|
+
|
|
411
|
+
if isinstance(data, (datetime, date)):
|
|
412
|
+
return data.isoformat()
|
|
413
|
+
|
|
414
|
+
return data
|
payi/_version.py
CHANGED
payi/resources/__init__.py
CHANGED
|
@@ -40,6 +40,22 @@ from .experiences import (
|
|
|
40
40
|
ExperiencesResourceWithStreamingResponse,
|
|
41
41
|
AsyncExperiencesResourceWithStreamingResponse,
|
|
42
42
|
)
|
|
43
|
+
from .billing_models import (
|
|
44
|
+
BillingModelsResource,
|
|
45
|
+
AsyncBillingModelsResource,
|
|
46
|
+
BillingModelsResourceWithRawResponse,
|
|
47
|
+
AsyncBillingModelsResourceWithRawResponse,
|
|
48
|
+
BillingModelsResourceWithStreamingResponse,
|
|
49
|
+
AsyncBillingModelsResourceWithStreamingResponse,
|
|
50
|
+
)
|
|
51
|
+
from .price_modifiers import (
|
|
52
|
+
PriceModifiersResource,
|
|
53
|
+
AsyncPriceModifiersResource,
|
|
54
|
+
PriceModifiersResourceWithRawResponse,
|
|
55
|
+
AsyncPriceModifiersResourceWithRawResponse,
|
|
56
|
+
PriceModifiersResourceWithStreamingResponse,
|
|
57
|
+
AsyncPriceModifiersResourceWithStreamingResponse,
|
|
58
|
+
)
|
|
43
59
|
|
|
44
60
|
__all__ = [
|
|
45
61
|
"BudgetsResource",
|
|
@@ -72,4 +88,16 @@ __all__ = [
|
|
|
72
88
|
"AsyncCsatResourceWithRawResponse",
|
|
73
89
|
"CsatResourceWithStreamingResponse",
|
|
74
90
|
"AsyncCsatResourceWithStreamingResponse",
|
|
91
|
+
"BillingModelsResource",
|
|
92
|
+
"AsyncBillingModelsResource",
|
|
93
|
+
"BillingModelsResourceWithRawResponse",
|
|
94
|
+
"AsyncBillingModelsResourceWithRawResponse",
|
|
95
|
+
"BillingModelsResourceWithStreamingResponse",
|
|
96
|
+
"AsyncBillingModelsResourceWithStreamingResponse",
|
|
97
|
+
"PriceModifiersResource",
|
|
98
|
+
"AsyncPriceModifiersResource",
|
|
99
|
+
"PriceModifiersResourceWithRawResponse",
|
|
100
|
+
"AsyncPriceModifiersResourceWithRawResponse",
|
|
101
|
+
"PriceModifiersResourceWithStreamingResponse",
|
|
102
|
+
"AsyncPriceModifiersResourceWithStreamingResponse",
|
|
75
103
|
]
|