marketplace refactoring

This commit is contained in:
2025-10-04 13:38:10 +02:00
parent 32be301d83
commit c971674ec2
68 changed files with 1102 additions and 1128 deletions

View File

@@ -29,13 +29,13 @@ from .auth import (
UserAlreadyExistsException
)
from .product import (
ProductNotFoundException,
ProductAlreadyExistsException,
InvalidProductDataException,
ProductValidationException,
from .marketplace_product import (
MarketplaceProductNotFoundException,
MarketplaceProductAlreadyExistsException,
InvalidMarketplaceProductDataException,
MarketplaceProductValidationException,
InvalidGTINException,
ProductCSVImportException,
MarketplaceProductCSVImportException,
)
from .stock import (
@@ -61,7 +61,7 @@ from .shop import (
ShopValidationException,
)
from .marketplace import (
from .marketplace_import_job import (
MarketplaceImportException,
ImportJobNotFoundException,
ImportJobNotOwnedException,
@@ -107,13 +107,13 @@ __all__ = [
"AdminRequiredException",
"UserAlreadyExistsException",
# Product exceptions
"ProductNotFoundException",
"ProductAlreadyExistsException",
"InvalidProductDataException",
"ProductValidationException",
# MarketplaceProduct exceptions
"MarketplaceProductNotFoundException",
"MarketplaceProductAlreadyExistsException",
"InvalidMarketplaceProductDataException",
"MarketplaceProductValidationException",
"InvalidGTINException",
"ProductCSVImportException",
"MarketplaceProductCSVImportException",
# Stock exceptions
"StockNotFoundException",
@@ -136,7 +136,7 @@ __all__ = [
"MaxShopsReachedException",
"ShopValidationException",
# Marketplace exceptions
# Marketplace import exceptions
"MarketplaceImportException",
"ImportJobNotFoundException",
"ImportJobNotOwnedException",

View File

@@ -1,4 +1,4 @@
# app/exceptions/marketplace.py
# app/exceptions/marketplace_import_job.py
"""
Marketplace import specific exceptions.
"""

View File

@@ -1,36 +1,36 @@
# app/exceptions/product.py
# app/exceptions/marketplace_products.py
"""
Product management specific exceptions.
MarketplaceProduct management specific exceptions.
"""
from typing import Any, Dict, Optional
from .base import ResourceNotFoundException, ConflictException, ValidationException, BusinessLogicException
class ProductNotFoundException(ResourceNotFoundException):
class MarketplaceProductNotFoundException(ResourceNotFoundException):
"""Raised when a product is not found."""
def __init__(self, product_id: str):
def __init__(self, marketplace_product_id: str):
super().__init__(
resource_type="Product",
identifier=product_id,
message=f"Product with ID '{product_id}' not found",
resource_type="MarketplaceProduct",
identifier=marketplace_product_id,
message=f"MarketplaceProduct with ID '{marketplace_product_id}' not found",
error_code="PRODUCT_NOT_FOUND",
)
class ProductAlreadyExistsException(ConflictException):
class MarketplaceProductAlreadyExistsException(ConflictException):
"""Raised when trying to create a product that already exists."""
def __init__(self, product_id: str):
def __init__(self, marketplace_product_id: str):
super().__init__(
message=f"Product with ID '{product_id}' already exists",
message=f"MarketplaceProduct with ID '{marketplace_product_id}' already exists",
error_code="PRODUCT_ALREADY_EXISTS",
details={"product_id": product_id},
details={"marketplace_product_id": marketplace_product_id},
)
class InvalidProductDataException(ValidationException):
class InvalidMarketplaceProductDataException(ValidationException):
"""Raised when product data is invalid."""
def __init__(
@@ -47,7 +47,7 @@ class InvalidProductDataException(ValidationException):
self.error_code = "INVALID_PRODUCT_DATA"
class ProductValidationException(ValidationException):
class MarketplaceProductValidationException(ValidationException):
"""Raised when product validation fails."""
def __init__(
@@ -80,12 +80,12 @@ class InvalidGTINException(ValidationException):
self.error_code = "INVALID_GTIN"
class ProductCSVImportException(BusinessLogicException):
class MarketplaceProductCSVImportException(BusinessLogicException):
"""Raised when product CSV import fails."""
def __init__(
self,
message: str = "Product CSV import failed",
message: str = "MarketplaceProduct CSV import failed",
row_number: Optional[int] = None,
errors: Optional[Dict[str, Any]] = None,
):

View File

@@ -98,13 +98,13 @@ class InvalidShopDataException(ValidationException):
class ShopProductAlreadyExistsException(ConflictException):
"""Raised when trying to add a product that already exists in shop."""
def __init__(self, shop_code: str, product_id: str):
def __init__(self, shop_code: str, marketplace_product_id: str):
super().__init__(
message=f"Product '{product_id}' already exists in shop '{shop_code}'",
message=f"MarketplaceProduct '{marketplace_product_id}' already exists in shop '{shop_code}'",
error_code="SHOP_PRODUCT_ALREADY_EXISTS",
details={
"shop_code": shop_code,
"product_id": product_id,
"marketplace_product_id": marketplace_product_id,
},
)
@@ -112,11 +112,11 @@ class ShopProductAlreadyExistsException(ConflictException):
class ShopProductNotFoundException(ResourceNotFoundException):
"""Raised when a shop product relationship is not found."""
def __init__(self, shop_code: str, product_id: str):
def __init__(self, shop_code: str, marketplace_product_id: str):
super().__init__(
resource_type="ShopProduct",
identifier=f"{shop_code}/{product_id}",
message=f"Product '{product_id}' not found in shop '{shop_code}'",
identifier=f"{shop_code}/{marketplace_product_id}",
message=f"MarketplaceProduct '{marketplace_product_id}' not found in shop '{shop_code}'",
error_code="SHOP_PRODUCT_NOT_FOUND",
)