producteca 2.0.39__tar.gz → 2.0.41__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.
Potentially problematic release.
This version of producteca might be problematic. Click here for more details.
- {producteca-2.0.39 → producteca-2.0.41}/PKG-INFO +1 -1
- {producteca-2.0.39 → producteca-2.0.41}/producteca/products/products.py +23 -25
- {producteca-2.0.39 → producteca-2.0.41}/pyproject.toml +1 -1
- {producteca-2.0.39 → producteca-2.0.41}/LICENSE +0 -0
- {producteca-2.0.39 → producteca-2.0.41}/README.md +0 -0
- {producteca-2.0.39 → producteca-2.0.41}/producteca/__init__.py +0 -0
- {producteca-2.0.39 → producteca-2.0.41}/producteca/abstract/__init__.py +0 -0
- {producteca-2.0.39 → producteca-2.0.41}/producteca/abstract/abstract_dataclass.py +0 -0
- {producteca-2.0.39 → producteca-2.0.41}/producteca/client.py +0 -0
- {producteca-2.0.39 → producteca-2.0.41}/producteca/config/__init__.py +0 -0
- {producteca-2.0.39 → producteca-2.0.41}/producteca/config/config.py +0 -0
- {producteca-2.0.39 → producteca-2.0.41}/producteca/payments/__init__.py +0 -0
- {producteca-2.0.39 → producteca-2.0.41}/producteca/payments/payments.py +0 -0
- {producteca-2.0.39 → producteca-2.0.41}/producteca/payments/tests/__init__.py +0 -0
- {producteca-2.0.39 → producteca-2.0.41}/producteca/payments/tests/test_payments.py +0 -0
- {producteca-2.0.39 → producteca-2.0.41}/producteca/products/__init__.py +0 -0
- {producteca-2.0.39 → producteca-2.0.41}/producteca/products/search_products.py +0 -0
- {producteca-2.0.39 → producteca-2.0.41}/producteca/products/tests/__init__.py +0 -0
- {producteca-2.0.39 → producteca-2.0.41}/producteca/products/tests/test_products.py +0 -0
- {producteca-2.0.39 → producteca-2.0.41}/producteca/products/tests/test_search_products.py +0 -0
- {producteca-2.0.39 → producteca-2.0.41}/producteca/sales_orders/__init__.py +0 -0
- {producteca-2.0.39 → producteca-2.0.41}/producteca/sales_orders/sales_orders.py +0 -0
- {producteca-2.0.39 → producteca-2.0.41}/producteca/sales_orders/search_sale_orders.py +0 -0
- {producteca-2.0.39 → producteca-2.0.41}/producteca/sales_orders/tests/__init__.py +0 -0
- {producteca-2.0.39 → producteca-2.0.41}/producteca/sales_orders/tests/search.json +0 -0
- {producteca-2.0.39 → producteca-2.0.41}/producteca/sales_orders/tests/test_sales_orders.py +0 -0
- {producteca-2.0.39 → producteca-2.0.41}/producteca/sales_orders/tests/test_search_so.py +0 -0
- {producteca-2.0.39 → producteca-2.0.41}/producteca/shipments/__init__.py +0 -0
- {producteca-2.0.39 → producteca-2.0.41}/producteca/shipments/shipment.py +0 -0
- {producteca-2.0.39 → producteca-2.0.41}/producteca/shipments/tests/__init__.py +0 -0
- {producteca-2.0.39 → producteca-2.0.41}/producteca/shipments/tests/test_shipment.py +0 -0
|
@@ -262,36 +262,34 @@ class ProductService(BaseService):
|
|
|
262
262
|
raise Exception("Sku or code should be provided to update the product")
|
|
263
263
|
data = product_variation.model_dump(by_alias=True, exclude_none=True)
|
|
264
264
|
response = requests.post(endpoint_url, json=data, headers=headers)
|
|
265
|
+
if not response.ok:
|
|
266
|
+
raise Exception(f"Error getting product {product_variation.sku} - {product_variation.code}\n {response.text}")
|
|
267
|
+
if response.status_code == 204:
|
|
268
|
+
raise Exception("Status code is 204, meaning nothing was updated or created")
|
|
269
|
+
|
|
270
|
+
_logger.info(f"response text: {response.text}")
|
|
265
271
|
response_data = response.json()
|
|
266
|
-
|
|
267
|
-
return Product(**response_data)
|
|
268
|
-
except ValidationError:
|
|
269
|
-
pass
|
|
272
|
+
_logger.debug(f"Response data: {response_data}")
|
|
270
273
|
if isinstance(response_data, list):
|
|
271
274
|
res = ListedSynchronizeResponse(results=response_data)
|
|
272
|
-
if
|
|
275
|
+
if res.results and hasattr(res.results[0], 'error_context') and res.results[0].error_context:
|
|
273
276
|
raise Exception(f"Errored while updating {res.results[0].error_context} {res.model_dump_json()}")
|
|
274
|
-
else
|
|
275
|
-
return res.results[0]
|
|
276
|
-
else:
|
|
277
|
-
try:
|
|
278
|
-
sync_resp = SynchronizeResponse(**response_data)
|
|
279
|
-
if sync_resp.error_context:
|
|
280
|
-
raise Exception(f"Errored while updating {sync_resp.error_context} - {sync_resp.model_dump_json()}")
|
|
281
|
-
else:
|
|
282
|
-
return sync_resp
|
|
283
|
-
except ValidationError:
|
|
284
|
-
try:
|
|
285
|
-
error_res = ErrorReason(**response_data)
|
|
286
|
-
raise Exception(f"Errored with the following message {error_res.message} - {error_res.model_dump_json()}")
|
|
287
|
-
except ValidationError:
|
|
288
|
-
pass
|
|
277
|
+
return res.results[0] if res.results else None
|
|
289
278
|
|
|
290
|
-
if
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
279
|
+
if isinstance(response_data, dict) and 'name' in response_data:
|
|
280
|
+
return Product(**response_data)
|
|
281
|
+
|
|
282
|
+
if isinstance(response_data, dict) and any(key in response_data for key in ['product', 'variation', 'statusCode']):
|
|
283
|
+
sync_resp = SynchronizeResponse(**response_data)
|
|
284
|
+
if sync_resp.error_context:
|
|
285
|
+
raise Exception(f"Errored while updating {sync_resp.error_context} - {sync_resp.model_dump_json()}")
|
|
286
|
+
return sync_resp
|
|
287
|
+
|
|
288
|
+
if isinstance(response_data, dict) and 'message' in response_data:
|
|
289
|
+
error_res = ErrorReason(**response_data)
|
|
290
|
+
raise Exception(f"Errored with the following message {error_res.message} - {error_res.model_dump_json()}")
|
|
291
|
+
|
|
292
|
+
raise Exception(f"Unhandled response format, check response {response.text}")
|
|
295
293
|
|
|
296
294
|
def get(self, product_id: int) -> "ProductService":
|
|
297
295
|
endpoint_url = self.config.get_endpoint(f'{self.endpoint}/{product_id}')
|
|
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
|
|
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
|