Pyiiko 0.4.0__tar.gz → 0.6.0__tar.gz
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.
- pyiiko-0.6.0/MANIFEST.in +1 -0
- {pyiiko-0.4.0/Pyiiko.egg-info → pyiiko-0.6.0}/PKG-INFO +33 -21
- {pyiiko-0.4.0 → pyiiko-0.6.0}/Pyiiko/__init__.py +1 -1
- pyiiko-0.6.0/Pyiiko/_base.py +122 -0
- pyiiko-0.6.0/Pyiiko/_server_entities.py +103 -0
- {pyiiko-0.4.0 → pyiiko-0.6.0}/Pyiiko/_server_nomenclature.py +2 -2
- {pyiiko-0.4.0 → pyiiko-0.6.0}/Pyiiko/_web_docs.py +21 -1
- {pyiiko-0.4.0 → pyiiko-0.6.0}/Pyiiko/iiko_web.py +13 -0
- {pyiiko-0.4.0 → pyiiko-0.6.0}/Pyiiko/server.py +57 -15
- {pyiiko-0.4.0 → pyiiko-0.6.0}/Pyiiko/transport.py +83 -33
- pyiiko-0.4.0/README.md → pyiiko-0.6.0/Pyiiko.egg-info/PKG-INFO +61 -13
- {pyiiko-0.4.0 → pyiiko-0.6.0}/Pyiiko.egg-info/SOURCES.txt +4 -0
- {pyiiko-0.4.0 → pyiiko-0.6.0}/Pyiiko.egg-info/requires.txt +3 -4
- pyiiko-0.4.0/PKG-INFO → pyiiko-0.6.0/README.md +25 -49
- {pyiiko-0.4.0 → pyiiko-0.6.0}/pyproject.toml +11 -11
- pyiiko-0.6.0/tests/__init__.py +0 -0
- pyiiko-0.6.0/tests/conftest.py +63 -0
- {pyiiko-0.4.0 → pyiiko-0.6.0}/tests/test_server.py +196 -8
- {pyiiko-0.4.0 → pyiiko-0.6.0}/tests/test_transport.py +87 -9
- pyiiko-0.4.0/Pyiiko/_base.py +0 -83
- {pyiiko-0.4.0 → pyiiko-0.6.0}/LICENSE +0 -0
- {pyiiko-0.4.0 → pyiiko-0.6.0}/Pyiiko/exceptions.py +0 -0
- {pyiiko-0.4.0 → pyiiko-0.6.0}/Pyiiko/py.typed +0 -0
- {pyiiko-0.4.0 → pyiiko-0.6.0}/Pyiiko.egg-info/dependency_links.txt +0 -0
- {pyiiko-0.4.0 → pyiiko-0.6.0}/Pyiiko.egg-info/top_level.txt +0 -0
- {pyiiko-0.4.0 → pyiiko-0.6.0}/setup.cfg +0 -0
- {pyiiko-0.4.0 → pyiiko-0.6.0}/tests/test_iiko_web.py +0 -0
pyiiko-0.6.0/MANIFEST.in
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include tests/__init__.py tests/conftest.py
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: Pyiiko
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: Python library for iiko ERP API
|
|
5
5
|
Author-email: Gadzhibala Pirmagomedov <gadzhibala@protonmail.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -12,25 +12,25 @@ Keywords: iiko,restaurant,erp,api,horeca
|
|
|
12
12
|
Classifier: Development Status :: 4 - Beta
|
|
13
13
|
Classifier: Intended Audience :: Developers
|
|
14
14
|
Classifier: Programming Language :: Python :: 3
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
17
15
|
Classifier: Programming Language :: Python :: 3.11
|
|
18
16
|
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
19
20
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
21
|
Classifier: Typing :: Typed
|
|
21
|
-
Requires-Python: >=3.
|
|
22
|
+
Requires-Python: >=3.11
|
|
22
23
|
Description-Content-Type: text/markdown
|
|
23
24
|
License-File: LICENSE
|
|
24
|
-
Requires-Dist: requests>=2.
|
|
25
|
-
Requires-Dist: lxml>=
|
|
26
|
-
Requires-Dist: urllib3>=
|
|
25
|
+
Requires-Dist: requests>=2.34.2
|
|
26
|
+
Requires-Dist: lxml>=6.1.3
|
|
27
|
+
Requires-Dist: urllib3>=2.8.0
|
|
27
28
|
Provides-Extra: dev
|
|
28
29
|
Requires-Dist: pytest>=7.4; extra == "dev"
|
|
29
30
|
Requires-Dist: pytest-cov>=4.1; extra == "dev"
|
|
30
31
|
Requires-Dist: responses>=0.23.0; extra == "dev"
|
|
31
32
|
Requires-Dist: ruff>=0.4.0; extra == "dev"
|
|
32
33
|
Requires-Dist: mypy>=1.9; extra == "dev"
|
|
33
|
-
Requires-Dist: types-requests>=2.31; extra == "dev"
|
|
34
34
|
Requires-Dist: lxml-stubs>=0.5; extra == "dev"
|
|
35
35
|
Dynamic: license-file
|
|
36
36
|
|
|
@@ -56,7 +56,7 @@ Dynamic: license-file
|
|
|
56
56
|
- **iiko Server API** — on-premise установки (складской учёт, номенклатура, отчёты OLAP, сотрудники, накладные, EDI)
|
|
57
57
|
- **iiko Transport API** — облачный API (организации, терминалы, доставки, города, улицы)
|
|
58
58
|
- **iiko Public Web API** — облачный API нового поколения (документооборот, номенклатура, закупки)
|
|
59
|
-
-
|
|
59
|
+
- До трёх повторов операций чтения при временных сетевых сбоях и HTTP 500, 502, 503, 504
|
|
60
60
|
- Единая иерархия исключений: `IikoError` → `IikoAuthError` / `IikoAPIError`
|
|
61
61
|
- Context manager для автоматического освобождения ресурсов
|
|
62
62
|
- Type hints, PEP 561 `py.typed`
|
|
@@ -67,7 +67,7 @@ Dynamic: license-file
|
|
|
67
67
|
pip install Pyiiko
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
-
**Требования:** Python 3.
|
|
70
|
+
**Требования:** Python 3.11+
|
|
71
71
|
|
|
72
72
|
## Быстрый старт
|
|
73
73
|
|
|
@@ -88,7 +88,7 @@ print(server.departments()) # XML с иерархией подраздел
|
|
|
88
88
|
print(server.products()) # XML с номенклатурой
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
При выходе из контекста клиент освобождает лицензионный слот, если сам получил токен:
|
|
92
92
|
|
|
93
93
|
```python
|
|
94
94
|
with IikoServer(ip="...", login="...", password="...") as server:
|
|
@@ -103,6 +103,12 @@ with IikoServer(ip="...", login="...", password="...") as server:
|
|
|
103
103
|
server = IikoServer(ip="https://...", token="your-existing-token")
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
+
Переданный токен остаётся под управлением вызывающего кода. Для его отзыва можно явно вызвать
|
|
107
|
+
`quit_token()`. Указание имени хоста без схемы выбирает HTTPS. Для старых установок можно явно
|
|
108
|
+
указать `http://`, при этом учётные данные передаются без шифрования. Для iikoServer используйте
|
|
109
|
+
конечный адрес без перенаправлений. Протокол iikoServer передаёт `pass` и `key` в URL. Исключите
|
|
110
|
+
query-параметры из журналов прокси и оставьте DEBUG-логгер `urllib3.connectionpool` выключенным.
|
|
111
|
+
|
|
106
112
|
### iiko Public Web API
|
|
107
113
|
|
|
108
114
|
```python
|
|
@@ -138,13 +144,17 @@ client = IikoWeb(token={"token": "eyJ...", "expires_in": 9999999999})
|
|
|
138
144
|
```python
|
|
139
145
|
from Pyiiko import Transport
|
|
140
146
|
|
|
141
|
-
client = Transport(key="your-api-
|
|
147
|
+
client = Transport(key="your-api-key", app_id="your-app-id", client_secret="your-secret")
|
|
142
148
|
|
|
143
149
|
orgs = client.organization()
|
|
144
150
|
terminals = client.terminal(org_id="org-guid-...")
|
|
145
151
|
cities = client.cities(org_id="org-guid-...")
|
|
146
152
|
```
|
|
147
153
|
|
|
154
|
+
Для iiko Cloud используйте авторизацию v2 с `key`, `app_id` и `client_secret` или передайте
|
|
155
|
+
готовый `token`. Вызов `Transport(key=...)` сохранён для интеграций с авторизацией v1.
|
|
156
|
+
[Инструкция по авторизации iiko](https://api.iiko.help/docs/concepts/authorization/)
|
|
157
|
+
|
|
148
158
|
Создание доставки:
|
|
149
159
|
|
|
150
160
|
```python
|
|
@@ -165,12 +175,10 @@ response = client.delivery_create(order_info=order)
|
|
|
165
175
|
from Pyiiko import IikoServer, IikoAuthError, IikoAPIError
|
|
166
176
|
|
|
167
177
|
try:
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
try:
|
|
173
|
-
data = server.departments()
|
|
178
|
+
with IikoServer(ip="iiko.example.com", login="user", password="password-sha1") as server:
|
|
179
|
+
data = server.departments()
|
|
180
|
+
except IikoAuthError as e:
|
|
181
|
+
print(f"Ошибка получения токена: {e}")
|
|
174
182
|
except IikoAPIError as e:
|
|
175
183
|
print(f"Ошибка API: HTTP {e.status_code}")
|
|
176
184
|
```
|
|
@@ -178,8 +186,12 @@ except IikoAPIError as e:
|
|
|
178
186
|
| Исключение | Когда возникает |
|
|
179
187
|
|---|---|
|
|
180
188
|
| `IikoError` | Базовый класс всех ошибок pyiiko |
|
|
181
|
-
| `IikoAuthError` |
|
|
182
|
-
| `IikoAPIError` |
|
|
189
|
+
| `IikoAuthError` | Пустой токен или неполные параметры авторизации Transport |
|
|
190
|
+
| `IikoAPIError` | Перенаправление или HTTP 4xx/5xx, включая 401 при авторизации |
|
|
191
|
+
|
|
192
|
+
После 5xx или таймаута операции записи проверьте её результат в iiko перед ручным повтором.
|
|
193
|
+
Для операций чтения клиент учитывает `Retry-After` до 60 секунд. При большей задержке
|
|
194
|
+
он возвращает HTTP-ошибку сразу, чтобы вызывающий код мог запланировать повтор.
|
|
183
195
|
|
|
184
196
|
## Справочник методов
|
|
185
197
|
|
|
@@ -222,7 +234,7 @@ except IikoAPIError as e:
|
|
|
222
234
|
| Метод | Описание |
|
|
223
235
|
|---|---|
|
|
224
236
|
| `organization()` | Список организаций |
|
|
225
|
-
| `terminal(org_id)` | Терминальные группы |
|
|
237
|
+
| `terminal(org_id, include=False)` | Терминальные группы с опцией включения отключённых групп |
|
|
226
238
|
| `regions(org_id)` | Регионы доставки |
|
|
227
239
|
| `cities(org_id)` | Города |
|
|
228
240
|
| `streets_by_city(org_id, city)` | Улицы города |
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"""Shared HTTP session, retry logic, and error handling for iiko API clients."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import logging
|
|
5
|
+
from time import sleep
|
|
6
|
+
from types import TracebackType
|
|
7
|
+
from typing import Any, Self
|
|
8
|
+
from urllib.parse import urlsplit
|
|
9
|
+
|
|
10
|
+
import requests
|
|
11
|
+
from requests.exceptions import ConnectionError, RequestException, SSLError, Timeout
|
|
12
|
+
from urllib3.exceptions import InvalidHeader
|
|
13
|
+
from urllib3.util import Retry
|
|
14
|
+
|
|
15
|
+
from .exceptions import IikoAPIError
|
|
16
|
+
|
|
17
|
+
logger = logging.getLogger(__name__)
|
|
18
|
+
|
|
19
|
+
DEFAULT_TIMEOUT = 10
|
|
20
|
+
_RETRY_DELAYS = (0, 1, 2)
|
|
21
|
+
_RETRY_STATUS_CODES = (500, 502, 503, 504)
|
|
22
|
+
_MAX_RETRY_AFTER = 60
|
|
23
|
+
_RETRY_AFTER_PARSER = Retry()
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _http_retry_delay(response: requests.Response, backoff: int) -> float | None:
|
|
27
|
+
retry_after = response.headers.get("Retry-After")
|
|
28
|
+
delay = None
|
|
29
|
+
if retry_after:
|
|
30
|
+
try:
|
|
31
|
+
delay = _RETRY_AFTER_PARSER.parse_retry_after(retry_after)
|
|
32
|
+
except InvalidHeader:
|
|
33
|
+
pass
|
|
34
|
+
if response.status_code not in _RETRY_STATUS_CODES and (
|
|
35
|
+
delay is None or response.status_code not in Retry.RETRY_AFTER_STATUS_CODES
|
|
36
|
+
):
|
|
37
|
+
return None
|
|
38
|
+
if delay is not None and delay > _MAX_RETRY_AFTER:
|
|
39
|
+
return None
|
|
40
|
+
return max(backoff, delay or 0)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class BaseIikoClient:
|
|
44
|
+
"""Base class for all iiko API clients.
|
|
45
|
+
|
|
46
|
+
Provides a shared requests.Session, retries for read-only operations,
|
|
47
|
+
and HTTP errors that omit credentials.
|
|
48
|
+
|
|
49
|
+
Supports use as a context manager::
|
|
50
|
+
|
|
51
|
+
with IikoServer(ip=..., login=..., password=...) as client:
|
|
52
|
+
data = client.departments()
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
def __init__(self, base_url: str, timeout: int = DEFAULT_TIMEOUT) -> None:
|
|
56
|
+
self._base_url = base_url.rstrip("/")
|
|
57
|
+
self._timeout = timeout
|
|
58
|
+
self._session = requests.Session()
|
|
59
|
+
|
|
60
|
+
def _send(self, method: str, url: str, operation: str, **kwargs: Any) -> requests.Response:
|
|
61
|
+
error: Exception
|
|
62
|
+
try:
|
|
63
|
+
return self._session.request(
|
|
64
|
+
method, url, timeout=self._timeout, allow_redirects=False, **kwargs
|
|
65
|
+
)
|
|
66
|
+
except RequestException as exc:
|
|
67
|
+
error = type(exc)(f"{type(exc).__name__} for {operation}")
|
|
68
|
+
except ValueError:
|
|
69
|
+
error = ValueError(f"Invalid HTTP request or response for {operation}")
|
|
70
|
+
# The original exception can include the query string, headers or body.
|
|
71
|
+
raise error
|
|
72
|
+
|
|
73
|
+
def _request(
|
|
74
|
+
self, method: str, path: str, *, retry: bool, **kwargs: Any
|
|
75
|
+
) -> requests.Response:
|
|
76
|
+
url = f"{self._base_url}/{path.lstrip('/')}"
|
|
77
|
+
operation = f"{method} {urlsplit(path).path}"
|
|
78
|
+
logger.debug("%s", operation)
|
|
79
|
+
for backoff in _RETRY_DELAYS if retry else ():
|
|
80
|
+
delay: float | None = backoff
|
|
81
|
+
try:
|
|
82
|
+
response = self._send(method, url, operation, **kwargs)
|
|
83
|
+
except SSLError:
|
|
84
|
+
raise
|
|
85
|
+
except (Timeout, ConnectionError):
|
|
86
|
+
pass
|
|
87
|
+
else:
|
|
88
|
+
delay = _http_retry_delay(response, backoff)
|
|
89
|
+
if delay is None:
|
|
90
|
+
break
|
|
91
|
+
response.close()
|
|
92
|
+
if delay:
|
|
93
|
+
sleep(delay)
|
|
94
|
+
else:
|
|
95
|
+
response = self._send(method, url, operation, **kwargs)
|
|
96
|
+
|
|
97
|
+
status = response.status_code
|
|
98
|
+
if 300 <= status < 600:
|
|
99
|
+
response.close()
|
|
100
|
+
raise IikoAPIError(f"HTTP {status} for {operation}", status_code=status)
|
|
101
|
+
return response
|
|
102
|
+
|
|
103
|
+
def _get(self, path: str, *, retry: bool = True, **kwargs: Any) -> requests.Response:
|
|
104
|
+
return self._request("GET", path, retry=retry, **kwargs)
|
|
105
|
+
|
|
106
|
+
def _post(self, path: str, *, retry: bool = False, **kwargs: Any) -> requests.Response:
|
|
107
|
+
return self._request("POST", path, retry=retry, **kwargs)
|
|
108
|
+
|
|
109
|
+
def close(self) -> None:
|
|
110
|
+
"""Close the underlying HTTP session."""
|
|
111
|
+
self._session.close()
|
|
112
|
+
|
|
113
|
+
def __enter__(self) -> Self:
|
|
114
|
+
return self
|
|
115
|
+
|
|
116
|
+
def __exit__(
|
|
117
|
+
self,
|
|
118
|
+
exc_type: type[BaseException] | None,
|
|
119
|
+
exc: BaseException | None,
|
|
120
|
+
tb: TracebackType | None,
|
|
121
|
+
) -> None:
|
|
122
|
+
self.close()
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"""Reference-data (v2 справочники) mixin for IikoServer — keeps server.py under 800 lines."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from typing import TYPE_CHECKING, Any
|
|
5
|
+
|
|
6
|
+
if TYPE_CHECKING:
|
|
7
|
+
import requests
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class _EntitiesMixin:
|
|
11
|
+
"""Mixin providing v2 reference-data (справочники) endpoints for IikoServer.
|
|
12
|
+
|
|
13
|
+
Two endpoints are exposed:
|
|
14
|
+
|
|
15
|
+
* ``GET /api/v2/entities/list`` — return common reference records for one
|
|
16
|
+
or more entity types (available since iiko 5.0).
|
|
17
|
+
* ``GET /api/v2/entities/{entityType}/ids`` — return the list of UUIDs for
|
|
18
|
+
an entity type (available since iiko 9.2.1028.0).
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
if TYPE_CHECKING:
|
|
22
|
+
def _get(self, path: str, *, retry: bool = True, **kwargs: Any) -> requests.Response: ...
|
|
23
|
+
|
|
24
|
+
def _key(self, **extra: Any) -> dict[str, Any]: # satisfied by IikoServer
|
|
25
|
+
raise NotImplementedError
|
|
26
|
+
|
|
27
|
+
# ------------------------------------------------------------------
|
|
28
|
+
# Справочники
|
|
29
|
+
# ------------------------------------------------------------------
|
|
30
|
+
|
|
31
|
+
def entities_list(
|
|
32
|
+
self,
|
|
33
|
+
root_types: list[str],
|
|
34
|
+
include_deleted: bool = True,
|
|
35
|
+
revision_from: int = -1,
|
|
36
|
+
) -> Any:
|
|
37
|
+
"""Return reference data for one or more entity types (v2 API).
|
|
38
|
+
|
|
39
|
+
:param root_types: One or more entity type names, e.g.
|
|
40
|
+
``["DiscountType", "PaymentType"]``. Supported values include
|
|
41
|
+
``Account``, ``DiscountType``, ``PaymentType``, ``TaxCategory``,
|
|
42
|
+
``LocalTax``, ``OrderType``, ``ProductSize``, and others.
|
|
43
|
+
:param include_deleted: Include deleted records (default ``True``,
|
|
44
|
+
matching the API default).
|
|
45
|
+
:param revision_from: Return only items whose revision is strictly
|
|
46
|
+
greater than this value. ``-1`` disables the filter (default).
|
|
47
|
+
:returns: Parsed JSON list. Each element contains ``id``,
|
|
48
|
+
``rootType``, ``deleted``, ``code``, ``name``. Some types expose
|
|
49
|
+
additional fields:
|
|
50
|
+
|
|
51
|
+
* ``OrderType`` → ``orderServiceType``, ``defaultForServiceType``
|
|
52
|
+
* ``ProductSize`` → ``shortName``
|
|
53
|
+
* ``TaxCategory`` → ``vatPercent``
|
|
54
|
+
* ``LocalTax`` → ``appliedVAT``, ``vatCategoryId``,
|
|
55
|
+
``ordersTypesIds``, ``allOrderTypes``, ``categoriesIds``,
|
|
56
|
+
``departmentsSettings``, ``reporting``, ``createdAt``,
|
|
57
|
+
``updatedAt``
|
|
58
|
+
|
|
59
|
+
Available since iiko 5.0.
|
|
60
|
+
|
|
61
|
+
Example::
|
|
62
|
+
|
|
63
|
+
data = server.entities_list(
|
|
64
|
+
["DiscountType", "PaymentType"],
|
|
65
|
+
include_deleted=False,
|
|
66
|
+
)
|
|
67
|
+
"""
|
|
68
|
+
params: list[tuple[str, Any]] = [
|
|
69
|
+
("key", self._key()["key"]),
|
|
70
|
+
("includeDeleted", str(include_deleted).lower()),
|
|
71
|
+
("revisionFrom", revision_from),
|
|
72
|
+
]
|
|
73
|
+
for rt in root_types:
|
|
74
|
+
params.append(("rootType", rt))
|
|
75
|
+
return self._get("api/v2/entities/list", params=params).json()
|
|
76
|
+
|
|
77
|
+
def entities_ids(
|
|
78
|
+
self,
|
|
79
|
+
entity_type: str,
|
|
80
|
+
include_deleted: bool = True,
|
|
81
|
+
revision_from: int = -1,
|
|
82
|
+
) -> Any:
|
|
83
|
+
"""Return the list of UUID identifiers for an entity type (v2 API).
|
|
84
|
+
|
|
85
|
+
:param entity_type: Entity type name, e.g. ``"Account"``.
|
|
86
|
+
:param include_deleted: Include deleted records (default ``True``).
|
|
87
|
+
:param revision_from: Return only items whose revision is strictly
|
|
88
|
+
greater than this value. ``-1`` disables the filter (default).
|
|
89
|
+
:returns: Parsed JSON list of UUID strings.
|
|
90
|
+
|
|
91
|
+
Available since iiko 9.2.1028.0.
|
|
92
|
+
|
|
93
|
+
Example::
|
|
94
|
+
|
|
95
|
+
ids = server.entities_ids("Account", include_deleted=False, revision_from=10)
|
|
96
|
+
"""
|
|
97
|
+
return self._get(
|
|
98
|
+
f"api/v2/entities/{entity_type}/ids",
|
|
99
|
+
params=self._key(
|
|
100
|
+
includeDeleted=str(include_deleted).lower(),
|
|
101
|
+
revisionFrom=revision_from,
|
|
102
|
+
),
|
|
103
|
+
).json()
|
|
@@ -16,8 +16,8 @@ class _NomenclatureMixin:
|
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
18
|
if TYPE_CHECKING:
|
|
19
|
-
def _get(self, path: str, **kwargs: Any) -> requests.Response: ...
|
|
20
|
-
def _post(self, path: str, **kwargs: Any) -> requests.Response: ...
|
|
19
|
+
def _get(self, path: str, *, retry: bool = True, **kwargs: Any) -> requests.Response: ...
|
|
20
|
+
def _post(self, path: str, *, retry: bool = False, **kwargs: Any) -> requests.Response: ...
|
|
21
21
|
|
|
22
22
|
def _key(self, **extra: Any) -> dict[str, Any]: # satisfied by IikoServer
|
|
23
23
|
raise NotImplementedError
|
|
@@ -11,7 +11,7 @@ class _DocsMixin:
|
|
|
11
11
|
"""Mixin providing all document-processing endpoints for IikoWeb."""
|
|
12
12
|
|
|
13
13
|
if TYPE_CHECKING:
|
|
14
|
-
def _post(self, path: str, **kwargs: Any) -> requests.Response: ...
|
|
14
|
+
def _post(self, path: str, *, retry: bool = False, **kwargs: Any) -> requests.Response: ...
|
|
15
15
|
|
|
16
16
|
def _auth(self) -> dict[str, str]: # satisfied by IikoWeb
|
|
17
17
|
raise NotImplementedError
|
|
@@ -46,6 +46,7 @@ class _DocsMixin:
|
|
|
46
46
|
}
|
|
47
47
|
return self._post(
|
|
48
48
|
"document-processing/counteragents",
|
|
49
|
+
retry=True,
|
|
49
50
|
headers=self._auth(),
|
|
50
51
|
json=body,
|
|
51
52
|
)
|
|
@@ -94,6 +95,7 @@ class _DocsMixin:
|
|
|
94
95
|
}
|
|
95
96
|
return self._post(
|
|
96
97
|
"document-processing/incoming-invoice/export",
|
|
98
|
+
retry=True,
|
|
97
99
|
headers=self._auth(),
|
|
98
100
|
json=body,
|
|
99
101
|
)
|
|
@@ -105,6 +107,7 @@ class _DocsMixin:
|
|
|
105
107
|
"""
|
|
106
108
|
return self._post(
|
|
107
109
|
"document-processing/incoming-invoice/export/by-number",
|
|
110
|
+
retry=True,
|
|
108
111
|
headers=self._auth(),
|
|
109
112
|
json=payload,
|
|
110
113
|
)
|
|
@@ -175,6 +178,7 @@ class _DocsMixin:
|
|
|
175
178
|
"""
|
|
176
179
|
return self._post(
|
|
177
180
|
"document-processing/incoming-service/export",
|
|
181
|
+
retry=True,
|
|
178
182
|
headers=self._auth(),
|
|
179
183
|
json=payload,
|
|
180
184
|
)
|
|
@@ -186,6 +190,7 @@ class _DocsMixin:
|
|
|
186
190
|
"""
|
|
187
191
|
return self._post(
|
|
188
192
|
"document-processing/incoming-service/get-document",
|
|
193
|
+
retry=True,
|
|
189
194
|
headers=self._auth(),
|
|
190
195
|
json=payload,
|
|
191
196
|
)
|
|
@@ -223,6 +228,7 @@ class _DocsMixin:
|
|
|
223
228
|
"""
|
|
224
229
|
return self._post(
|
|
225
230
|
"document-processing/internal-transfer/export",
|
|
231
|
+
retry=True,
|
|
226
232
|
headers=self._auth(),
|
|
227
233
|
json=payload,
|
|
228
234
|
)
|
|
@@ -234,6 +240,7 @@ class _DocsMixin:
|
|
|
234
240
|
"""
|
|
235
241
|
return self._post(
|
|
236
242
|
"document-processing/internal-transfer/export/by-id",
|
|
243
|
+
retry=True,
|
|
237
244
|
headers=self._auth(),
|
|
238
245
|
json=payload,
|
|
239
246
|
)
|
|
@@ -245,6 +252,7 @@ class _DocsMixin:
|
|
|
245
252
|
"""
|
|
246
253
|
return self._post(
|
|
247
254
|
"document-processing/internal-transfer/export/by-number",
|
|
255
|
+
retry=True,
|
|
248
256
|
headers=self._auth(),
|
|
249
257
|
json=payload,
|
|
250
258
|
)
|
|
@@ -271,6 +279,7 @@ class _DocsMixin:
|
|
|
271
279
|
"""
|
|
272
280
|
return self._post(
|
|
273
281
|
"document-processing/outgoing-invoice/export",
|
|
282
|
+
retry=True,
|
|
274
283
|
headers=self._auth(),
|
|
275
284
|
json=payload,
|
|
276
285
|
)
|
|
@@ -282,6 +291,7 @@ class _DocsMixin:
|
|
|
282
291
|
"""
|
|
283
292
|
return self._post(
|
|
284
293
|
"document-processing/outgoing-invoice/export/by-number",
|
|
294
|
+
retry=True,
|
|
285
295
|
headers=self._auth(),
|
|
286
296
|
json=payload,
|
|
287
297
|
)
|
|
@@ -293,6 +303,7 @@ class _DocsMixin:
|
|
|
293
303
|
"""
|
|
294
304
|
return self._post(
|
|
295
305
|
"document-processing/outgoing-invoice/get-cost-prices",
|
|
306
|
+
retry=True,
|
|
296
307
|
headers=self._auth(),
|
|
297
308
|
json=payload,
|
|
298
309
|
)
|
|
@@ -363,6 +374,7 @@ class _DocsMixin:
|
|
|
363
374
|
"""
|
|
364
375
|
return self._post(
|
|
365
376
|
"document-processing/outgoing-service/export",
|
|
377
|
+
retry=True,
|
|
366
378
|
headers=self._auth(),
|
|
367
379
|
json=payload,
|
|
368
380
|
)
|
|
@@ -374,6 +386,7 @@ class _DocsMixin:
|
|
|
374
386
|
"""
|
|
375
387
|
return self._post(
|
|
376
388
|
"document-processing/outgoing-service/get-document",
|
|
389
|
+
retry=True,
|
|
377
390
|
headers=self._auth(),
|
|
378
391
|
json=payload,
|
|
379
392
|
)
|
|
@@ -411,6 +424,7 @@ class _DocsMixin:
|
|
|
411
424
|
"""
|
|
412
425
|
return self._post(
|
|
413
426
|
"document-processing/production-document/export",
|
|
427
|
+
retry=True,
|
|
414
428
|
headers=self._auth(),
|
|
415
429
|
json=payload,
|
|
416
430
|
)
|
|
@@ -422,6 +436,7 @@ class _DocsMixin:
|
|
|
422
436
|
"""
|
|
423
437
|
return self._post(
|
|
424
438
|
"document-processing/production-document/get-document",
|
|
439
|
+
retry=True,
|
|
425
440
|
headers=self._auth(),
|
|
426
441
|
json=payload,
|
|
427
442
|
)
|
|
@@ -459,6 +474,7 @@ class _DocsMixin:
|
|
|
459
474
|
"""
|
|
460
475
|
return self._post(
|
|
461
476
|
"document-processing/sales-document/export",
|
|
477
|
+
retry=True,
|
|
462
478
|
headers=self._auth(),
|
|
463
479
|
json=payload,
|
|
464
480
|
)
|
|
@@ -470,6 +486,7 @@ class _DocsMixin:
|
|
|
470
486
|
"""
|
|
471
487
|
return self._post(
|
|
472
488
|
"document-processing/sales-document/get-document",
|
|
489
|
+
retry=True,
|
|
473
490
|
headers=self._auth(),
|
|
474
491
|
json=payload,
|
|
475
492
|
)
|
|
@@ -507,6 +524,7 @@ class _DocsMixin:
|
|
|
507
524
|
"""
|
|
508
525
|
return self._post(
|
|
509
526
|
"document-processing/writeoff-document/export",
|
|
527
|
+
retry=True,
|
|
510
528
|
headers=self._auth(),
|
|
511
529
|
json=payload,
|
|
512
530
|
)
|
|
@@ -518,6 +536,7 @@ class _DocsMixin:
|
|
|
518
536
|
"""
|
|
519
537
|
return self._post(
|
|
520
538
|
"document-processing/writeoff-document/export/by-id",
|
|
539
|
+
retry=True,
|
|
521
540
|
headers=self._auth(),
|
|
522
541
|
json=payload,
|
|
523
542
|
)
|
|
@@ -529,6 +548,7 @@ class _DocsMixin:
|
|
|
529
548
|
"""
|
|
530
549
|
return self._post(
|
|
531
550
|
"document-processing/writeoff-document/export/by-number",
|
|
551
|
+
retry=True,
|
|
532
552
|
headers=self._auth(),
|
|
533
553
|
json=payload,
|
|
534
554
|
)
|
|
@@ -78,6 +78,7 @@ class IikoWeb(_DocsMixin, BaseIikoClient):
|
|
|
78
78
|
"""Return the list of all stores."""
|
|
79
79
|
return self._post(
|
|
80
80
|
"entities/store/list",
|
|
81
|
+
retry=True,
|
|
81
82
|
headers=self._auth(),
|
|
82
83
|
json={},
|
|
83
84
|
)
|
|
@@ -89,6 +90,7 @@ class IikoWeb(_DocsMixin, BaseIikoClient):
|
|
|
89
90
|
"""
|
|
90
91
|
return self._post(
|
|
91
92
|
"entities/store/get",
|
|
93
|
+
retry=True,
|
|
92
94
|
headers=self._auth(),
|
|
93
95
|
json={"id": store_id},
|
|
94
96
|
)
|
|
@@ -112,6 +114,7 @@ class IikoWeb(_DocsMixin, BaseIikoClient):
|
|
|
112
114
|
}
|
|
113
115
|
return self._post(
|
|
114
116
|
"entities/products/list",
|
|
117
|
+
retry=True,
|
|
115
118
|
headers=self._auth(),
|
|
116
119
|
json=body,
|
|
117
120
|
)
|
|
@@ -135,6 +138,7 @@ class IikoWeb(_DocsMixin, BaseIikoClient):
|
|
|
135
138
|
}
|
|
136
139
|
return self._post(
|
|
137
140
|
"entities/product-category/list",
|
|
141
|
+
retry=True,
|
|
138
142
|
headers=self._auth(),
|
|
139
143
|
json=body,
|
|
140
144
|
)
|
|
@@ -158,6 +162,7 @@ class IikoWeb(_DocsMixin, BaseIikoClient):
|
|
|
158
162
|
}
|
|
159
163
|
return self._post(
|
|
160
164
|
"entities/product-size/list",
|
|
165
|
+
retry=True,
|
|
161
166
|
headers=self._auth(),
|
|
162
167
|
json=body,
|
|
163
168
|
)
|
|
@@ -181,6 +186,7 @@ class IikoWeb(_DocsMixin, BaseIikoClient):
|
|
|
181
186
|
}
|
|
182
187
|
return self._post(
|
|
183
188
|
"entities/user/list",
|
|
189
|
+
retry=True,
|
|
184
190
|
headers=self._auth(),
|
|
185
191
|
json=body,
|
|
186
192
|
)
|
|
@@ -204,6 +210,7 @@ class IikoWeb(_DocsMixin, BaseIikoClient):
|
|
|
204
210
|
}
|
|
205
211
|
return self._post(
|
|
206
212
|
"entities/payment-type/list",
|
|
213
|
+
retry=True,
|
|
207
214
|
headers=self._auth(),
|
|
208
215
|
json=body,
|
|
209
216
|
)
|
|
@@ -227,6 +234,7 @@ class IikoWeb(_DocsMixin, BaseIikoClient):
|
|
|
227
234
|
}
|
|
228
235
|
return self._post(
|
|
229
236
|
"entities/cash-flow-category/list",
|
|
237
|
+
retry=True,
|
|
230
238
|
headers=self._auth(),
|
|
231
239
|
json=body,
|
|
232
240
|
)
|
|
@@ -284,6 +292,7 @@ class IikoWeb(_DocsMixin, BaseIikoClient):
|
|
|
284
292
|
"""
|
|
285
293
|
return self._post(
|
|
286
294
|
"purchasing/orders/get",
|
|
295
|
+
retry=True,
|
|
287
296
|
headers=self._auth(),
|
|
288
297
|
json={"id": order_id},
|
|
289
298
|
)
|
|
@@ -295,6 +304,7 @@ class IikoWeb(_DocsMixin, BaseIikoClient):
|
|
|
295
304
|
"""
|
|
296
305
|
return self._post(
|
|
297
306
|
"purchasing/orders/list",
|
|
307
|
+
retry=True,
|
|
298
308
|
headers=self._auth(),
|
|
299
309
|
json=payload,
|
|
300
310
|
)
|
|
@@ -328,6 +338,7 @@ class IikoWeb(_DocsMixin, BaseIikoClient):
|
|
|
328
338
|
"""
|
|
329
339
|
return self._post(
|
|
330
340
|
"purchasing/orders/task-status",
|
|
341
|
+
retry=True,
|
|
331
342
|
headers=self._auth(),
|
|
332
343
|
json={"taskId": task_id},
|
|
333
344
|
)
|
|
@@ -376,6 +387,7 @@ class IikoWeb(_DocsMixin, BaseIikoClient):
|
|
|
376
387
|
"""
|
|
377
388
|
return self._post(
|
|
378
389
|
"purchasing/workflows/get",
|
|
390
|
+
retry=True,
|
|
379
391
|
headers=self._auth(),
|
|
380
392
|
json={"id": workflow_id},
|
|
381
393
|
)
|
|
@@ -387,6 +399,7 @@ class IikoWeb(_DocsMixin, BaseIikoClient):
|
|
|
387
399
|
"""
|
|
388
400
|
return self._post(
|
|
389
401
|
"purchasing/workflows/list",
|
|
402
|
+
retry=True,
|
|
390
403
|
headers=self._auth(),
|
|
391
404
|
json=payload or {},
|
|
392
405
|
)
|