b24api 0.7.1__tar.gz → 0.7.2__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.
- {b24api-0.7.1/b24api.egg-info → b24api-0.7.2}/PKG-INFO +1 -1
- {b24api-0.7.1 → b24api-0.7.2}/b24api/base_api.py +2 -2
- {b24api-0.7.1 → b24api-0.7.2}/b24api/entity.py +7 -3
- {b24api-0.7.1 → b24api-0.7.2}/b24api/error.py +4 -4
- {b24api-0.7.1 → b24api-0.7.2/b24api.egg-info}/PKG-INFO +1 -1
- {b24api-0.7.1 → b24api-0.7.2}/LICENSE +0 -0
- {b24api-0.7.1 → b24api-0.7.2}/MANIFEST.in +0 -0
- {b24api-0.7.1 → b24api-0.7.2}/README.md +0 -0
- {b24api-0.7.1 → b24api-0.7.2}/b24api/__init__.py +0 -0
- {b24api-0.7.1 → b24api-0.7.2}/b24api/async_api.py +0 -0
- {b24api-0.7.1 → b24api-0.7.2}/b24api/query.py +0 -0
- {b24api-0.7.1 → b24api-0.7.2}/b24api/settings.py +0 -0
- {b24api-0.7.1 → b24api-0.7.2}/b24api/sync_api.py +0 -0
- {b24api-0.7.1 → b24api-0.7.2}/b24api/type.py +0 -0
- {b24api-0.7.1 → b24api-0.7.2}/b24api.egg-info/SOURCES.txt +0 -0
- {b24api-0.7.1 → b24api-0.7.2}/b24api.egg-info/dependency_links.txt +0 -0
- {b24api-0.7.1 → b24api-0.7.2}/b24api.egg-info/requires.txt +0 -0
- {b24api-0.7.1 → b24api-0.7.2}/b24api.egg-info/top_level.txt +0 -0
- {b24api-0.7.1 → b24api-0.7.2}/pyproject.toml +0 -0
- {b24api-0.7.1 → b24api-0.7.2}/setup.cfg +0 -0
|
@@ -60,7 +60,7 @@ class BaseBitrix24(ABC):
|
|
|
60
60
|
def _validate_call_response(self, request: Request, response: httpx.Response) -> Response:
|
|
61
61
|
# Checking more informative errors first (content may exist with 5xx status)
|
|
62
62
|
with contextlib.suppress(httpx.ResponseNotRead, ValidationError):
|
|
63
|
-
ErrorResponse.model_validate_json(response.content).raise_error(request, self.settings
|
|
63
|
+
ErrorResponse.model_validate_json(response.content).raise_error(request, self.settings)
|
|
64
64
|
|
|
65
65
|
try:
|
|
66
66
|
response.raise_for_status()
|
|
@@ -102,7 +102,7 @@ class BaseBitrix24(ABC):
|
|
|
102
102
|
if key in result.result_error:
|
|
103
103
|
ErrorResponse.model_validate(result.result_error[key]).raise_error(
|
|
104
104
|
command,
|
|
105
|
-
self.settings
|
|
105
|
+
self.settings,
|
|
106
106
|
)
|
|
107
107
|
if key not in result.result:
|
|
108
108
|
raise ValueError(
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import logging
|
|
1
2
|
from datetime import datetime
|
|
2
3
|
from typing import Any
|
|
3
4
|
|
|
@@ -5,6 +6,7 @@ from pydantic import BaseModel, field_validator
|
|
|
5
6
|
|
|
6
7
|
from b24api.error import ApiResponseError, RetryApiResponseError
|
|
7
8
|
from b24api.query import build_query
|
|
9
|
+
from b24api.settings import Settings
|
|
8
10
|
from b24api.type import ApiTypes
|
|
9
11
|
|
|
10
12
|
|
|
@@ -57,12 +59,14 @@ class ErrorResponse(BaseModel):
|
|
|
57
59
|
value = value.lower()
|
|
58
60
|
return value
|
|
59
61
|
|
|
60
|
-
def raise_error(self, request: Request,
|
|
61
|
-
|
|
62
|
+
def raise_error(self, request: Request, settings: Settings) -> None:
|
|
63
|
+
logger = logging.getLogger(settings.logger_name)
|
|
64
|
+
logger.debug("Request: %s", request)
|
|
65
|
+
|
|
66
|
+
error_cls = RetryApiResponseError if self.error in settings.retry_errors else ApiResponseError
|
|
62
67
|
raise error_cls(
|
|
63
68
|
code=self.error,
|
|
64
69
|
description=self.error_description,
|
|
65
|
-
request=str(request),
|
|
66
70
|
)
|
|
67
71
|
|
|
68
72
|
|
|
@@ -8,13 +8,13 @@ class RetryHTTPStatusError(httpx.HTTPStatusError):
|
|
|
8
8
|
class ApiResponseError(Exception):
|
|
9
9
|
"""API error with description."""
|
|
10
10
|
|
|
11
|
-
def __init__(self, *, code: str, description: str | None
|
|
11
|
+
def __init__(self, *, code: str, description: str | None) -> None:
|
|
12
12
|
if code and description:
|
|
13
|
-
message = f"API error [{code}]: {description}
|
|
13
|
+
message = f"API error [{code}]: {description}"
|
|
14
14
|
elif code:
|
|
15
|
-
message = f"API error [{code}]
|
|
15
|
+
message = f"API error [{code}]"
|
|
16
16
|
else:
|
|
17
|
-
message = f"API error: {description}
|
|
17
|
+
message = f"API error: {description}"
|
|
18
18
|
super().__init__(message)
|
|
19
19
|
|
|
20
20
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|