from platforms.wallapop_platform import WallapopPlatform from platforms.vinted_platform import VintedPlatform class PlatformFactory: """Factory class for creating platform instances""" # Registry of available platforms _platforms = { 'wallapop': WallapopPlatform, 'vinted': VintedPlatform, # Add more platforms here as they are implemented: # 'buyee': BuyeePlatform, } @classmethod def create_platform(cls, platform_name, item_monitor): """ Create a platform instance based on the platform name Args: platform_name: Name of the platform (e.g., 'wallapop', 'vinted') item_monitor: ItemMonitor instance with search parameters Returns: BasePlatform: Instance of the requested platform Raises: ValueError: If platform is not supported """ platform_name = platform_name.lower() if platform_name not in cls._platforms: available = ', '.join(cls._platforms.keys()) raise ValueError( f"Platform '{platform_name}' is not supported. " f"Available platforms: {available}" ) platform_class = cls._platforms[platform_name] return platform_class(item_monitor) @classmethod def get_available_platforms(cls): """ Get list of available platform names Returns: list: List of supported platform names """ return list(cls._platforms.keys()) @classmethod def register_platform(cls, platform_name, platform_class): """ Register a new platform class Args: platform_name: Name identifier for the platform platform_class: Class implementing BasePlatform """ cls._platforms[platform_name.lower()] = platform_class