vatly-api-python 0.1.0a2__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.
- vatly/__init__.py +43 -0
- vatly/_model.py +13 -0
- vatly/_transport.py +284 -0
- vatly/_version.py +1 -0
- vatly/client.py +100 -0
- vatly/errors.py +86 -0
- vatly/models.py +3009 -0
- vatly/pagination.py +29 -0
- vatly/py.typed +1 -0
- vatly/resources.py +2003 -0
- vatly/webhooks.py +146 -0
- vatly_api_python-0.1.0a2.dist-info/METADATA +144 -0
- vatly_api_python-0.1.0a2.dist-info/RECORD +15 -0
- vatly_api_python-0.1.0a2.dist-info/WHEEL +4 -0
- vatly_api_python-0.1.0a2.dist-info/licenses/LICENSE +21 -0
vatly/pagination.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from typing import Any, Generic, TypeVar
|
|
2
|
+
from urllib.parse import parse_qs, urlparse
|
|
3
|
+
|
|
4
|
+
from pydantic import BaseModel, ConfigDict
|
|
5
|
+
|
|
6
|
+
from .models import PaginationLinks
|
|
7
|
+
|
|
8
|
+
T = TypeVar("T")
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Page(BaseModel, Generic[T]):
|
|
12
|
+
model_config = ConfigDict(extra="allow")
|
|
13
|
+
data: list[T]
|
|
14
|
+
count: int
|
|
15
|
+
links: PaginationLinks
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def next_params(page: Page[Any], params: dict[str, Any], seen: set[str]) -> dict[str, Any] | None:
|
|
19
|
+
if page.links.next is None:
|
|
20
|
+
return None
|
|
21
|
+
cursor = parse_qs(urlparse(page.links.next.href).query).get("startingAfter", [None])[0]
|
|
22
|
+
if not cursor or cursor in seen:
|
|
23
|
+
raise VatlyPaginationError("Invalid or repeated pagination cursor")
|
|
24
|
+
seen.add(cursor)
|
|
25
|
+
return {k: v for k, v in {**params, "startingAfter": cursor}.items() if k != "endingBefore"}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class VatlyPaginationError(ValueError):
|
|
29
|
+
pass
|
vatly/py.typed
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# PEP 561: this package includes inline type information.
|