shopware-api-client 1.0.101__py3-none-any.whl → 1.0.103__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 shopware-api-client might be problematic. Click here for more details.
- shopware_api_client/base.py +11 -10
- shopware_api_client/client.py +2 -2
- {shopware_api_client-1.0.101.dist-info → shopware_api_client-1.0.103.dist-info}/METADATA +1 -1
- {shopware_api_client-1.0.101.dist-info → shopware_api_client-1.0.103.dist-info}/RECORD +6 -6
- {shopware_api_client-1.0.101.dist-info → shopware_api_client-1.0.103.dist-info}/LICENSE +0 -0
- {shopware_api_client-1.0.101.dist-info → shopware_api_client-1.0.103.dist-info}/WHEEL +0 -0
shopware_api_client/base.py
CHANGED
|
@@ -44,6 +44,8 @@ from .exceptions import (
|
|
|
44
44
|
)
|
|
45
45
|
from .logging import logger
|
|
46
46
|
|
|
47
|
+
APPLICATION_JSON = "application/json"
|
|
48
|
+
|
|
47
49
|
EndpointClass = TypeVar("EndpointClass", bound="EndpointBase[Any]")
|
|
48
50
|
ModelClass = TypeVar("ModelClass", bound="ApiModelBase[Any]")
|
|
49
51
|
|
|
@@ -63,7 +65,8 @@ class ClientBase:
|
|
|
63
65
|
self.raw = raw
|
|
64
66
|
|
|
65
67
|
async def __aenter__(self) -> "Self":
|
|
66
|
-
self.http_client
|
|
68
|
+
client = self.http_client
|
|
69
|
+
assert isinstance(client, httpx.AsyncClient), "http_client must be an instance of httpx.AsyncClient"
|
|
67
70
|
return self
|
|
68
71
|
|
|
69
72
|
async def __aexit__(self, *args: Any) -> None:
|
|
@@ -86,15 +89,13 @@ class ClientBase:
|
|
|
86
89
|
|
|
87
90
|
@cached_property
|
|
88
91
|
def http_client(self) -> httpx.AsyncClient:
|
|
89
|
-
return self.
|
|
92
|
+
return self._get_http_client()
|
|
90
93
|
|
|
91
|
-
def
|
|
92
|
-
# FIXME: rename _get_client -> _get_http_client to avoid confusion with ApiModelBase._get_client
|
|
93
|
-
# (fix middleware usage of private method usage first)
|
|
94
|
+
def _get_http_client(self) -> httpx.AsyncClient:
|
|
94
95
|
raise NotImplementedError()
|
|
95
96
|
|
|
96
97
|
def _get_headers(self) -> dict[str, str]:
|
|
97
|
-
headers = {"Content-Type":
|
|
98
|
+
headers = {"Content-Type": APPLICATION_JSON, "Accept": APPLICATION_JSON}
|
|
98
99
|
|
|
99
100
|
if self.language_id is not None:
|
|
100
101
|
headers["sw-language-id"] = str(self.language_id)
|
|
@@ -154,7 +155,7 @@ class ClientBase:
|
|
|
154
155
|
raise ValueError("`errors` attribute in json not a list/tuple!")
|
|
155
156
|
|
|
156
157
|
error: SWAPIError | SWAPIErrorList = SWAPIError.from_errors(errors)
|
|
157
|
-
except
|
|
158
|
+
except ValueError:
|
|
158
159
|
error: SWAPIError | SWAPIErrorList = SWAPIError.from_response(response) # type: ignore
|
|
159
160
|
|
|
160
161
|
if isinstance(error, SWAPIErrorList) and len(error.errors) == 1:
|
|
@@ -175,10 +176,11 @@ class ClientBase:
|
|
|
175
176
|
|
|
176
177
|
await self.retry_sleep(retry_wait_base, retry_count)
|
|
177
178
|
retry_count += 1
|
|
178
|
-
|
|
179
|
+
elif response.status_code == 200 and response.headers.get("Content-Type", "").startswith(APPLICATION_JSON):
|
|
179
180
|
# guard against "200 okay" responses with malformed json
|
|
180
181
|
try:
|
|
181
182
|
setattr(response, "json_cached", response.json())
|
|
183
|
+
return response
|
|
182
184
|
except json.JSONDecodeError:
|
|
183
185
|
# retries exhausted?
|
|
184
186
|
if retry_count >= retries:
|
|
@@ -193,8 +195,7 @@ class ClientBase:
|
|
|
193
195
|
# schedule retry
|
|
194
196
|
await self.retry_sleep(retry_wait_base, retry_count)
|
|
195
197
|
retry_count += 1
|
|
196
|
-
|
|
197
|
-
|
|
198
|
+
else:
|
|
198
199
|
return response
|
|
199
200
|
|
|
200
201
|
async def get(self, relative_url: str, **kwargs: Any) -> httpx.Response:
|
shopware_api_client/client.py
CHANGED
|
@@ -19,7 +19,7 @@ class AdminClient(ClientBase, AdminEndpoints):
|
|
|
19
19
|
self._client: httpx.AsyncClient | None = None
|
|
20
20
|
self.init_endpoints(self)
|
|
21
21
|
|
|
22
|
-
def
|
|
22
|
+
def _get_http_client(self) -> httpx.AsyncClient:
|
|
23
23
|
if self._client is None:
|
|
24
24
|
self._client = httpx.AsyncClient(
|
|
25
25
|
event_hooks={"request": [self.log_request], "response": [self.log_response]}
|
|
@@ -180,7 +180,7 @@ class StoreClient(ClientBase, StoreEndpoints):
|
|
|
180
180
|
self._client: httpx.AsyncClient | None = None
|
|
181
181
|
self.init_endpoints(self)
|
|
182
182
|
|
|
183
|
-
def
|
|
183
|
+
def _get_http_client(self) -> httpx.AsyncClient:
|
|
184
184
|
if self._client is None:
|
|
185
185
|
self._client = httpx.AsyncClient(
|
|
186
186
|
event_hooks={"request": [self.log_request], "response": [self.log_response]},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
shopware_api_client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
shopware_api_client/base.py,sha256=
|
|
3
|
-
shopware_api_client/client.py,sha256=
|
|
2
|
+
shopware_api_client/base.py,sha256=8iBg3_OvcsEETVGmW-QsSy2HU-6JLnnogA6NaupuE6k,25067
|
|
3
|
+
shopware_api_client/client.py,sha256=vkTZ8WLIu0Q3_73gXvidkTSpMJlWsJUjFyhDY2f2ISM,7583
|
|
4
4
|
shopware_api_client/config.py,sha256=HStgfQcClpo_aqaTRDrqdTUjqSGPFkIMjrPwSruVnM8,1565
|
|
5
5
|
shopware_api_client/endpoints/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
6
|
shopware_api_client/endpoints/admin/__init__.py,sha256=yfGXeIzGDoAIzVBp0zEGYMcWKoc-qrjMeot8HXOwfhA,17213
|
|
@@ -108,7 +108,7 @@ shopware_api_client/endpoints/store/core/cart.py,sha256=34eNwuv7H9WZUtJGf4TkTGHi
|
|
|
108
108
|
shopware_api_client/exceptions.py,sha256=AELVvzdjH0RABF0WgqQ-DbEuZB1k-5V8L_NkKZLV6tk,4459
|
|
109
109
|
shopware_api_client/logging.py,sha256=4QSTK1vcdBew4shvLG-fm-xDOlddhOZeyb5T9Og0fSA,251
|
|
110
110
|
shopware_api_client/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
111
|
-
shopware_api_client-1.0.
|
|
112
|
-
shopware_api_client-1.0.
|
|
113
|
-
shopware_api_client-1.0.
|
|
114
|
-
shopware_api_client-1.0.
|
|
111
|
+
shopware_api_client-1.0.103.dist-info/LICENSE,sha256=qTihFhbGE2ZJJ7Byc9hnEYBY33yDK2Jw87SpAm0IKUs,1107
|
|
112
|
+
shopware_api_client-1.0.103.dist-info/METADATA,sha256=EJbT2yypoylfWkxSQn5bc0Wndi8k4X0oBRrjksODWr4,22659
|
|
113
|
+
shopware_api_client-1.0.103.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
114
|
+
shopware_api_client-1.0.103.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|