- Auto-fixed 4,496 lint issues (import sorting, modern syntax, etc.) - Added ignore rules for patterns intentional in this codebase: E402 (late imports), E712 (SQLAlchemy filters), B904 (raise from), SIM108/SIM105/SIM117 (readability preferences) - Added per-file ignores for tests and scripts - Excluded broken scripts/rename_terminology.py (has curly quotes) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
108 lines
3.3 KiB
Python
108 lines
3.3 KiB
Python
# app/modules/marketplace/services/marketplace_features.py
|
|
"""
|
|
Marketplace feature provider for the billing feature system.
|
|
|
|
Declares marketplace-related billable features (letzshop sync, API access,
|
|
webhooks, custom integrations) for feature gating.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import logging
|
|
from typing import TYPE_CHECKING
|
|
|
|
from app.modules.contracts.features import (
|
|
FeatureDeclaration,
|
|
FeatureScope,
|
|
FeatureType,
|
|
FeatureUsage,
|
|
)
|
|
|
|
if TYPE_CHECKING:
|
|
from sqlalchemy.orm import Session
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class MarketplaceFeatureProvider:
|
|
"""Feature provider for the marketplace module.
|
|
|
|
Declares:
|
|
- letzshop_sync: binary merchant-level feature for Letzshop synchronization
|
|
- api_access: binary merchant-level feature for API access
|
|
- webhooks: binary merchant-level feature for webhook integrations
|
|
- custom_integrations: binary merchant-level feature for custom integrations
|
|
"""
|
|
|
|
@property
|
|
def feature_category(self) -> str:
|
|
return "marketplace"
|
|
|
|
def get_feature_declarations(self) -> list[FeatureDeclaration]:
|
|
return [
|
|
FeatureDeclaration(
|
|
code="letzshop_sync",
|
|
name_key="marketplace.features.letzshop_sync.name",
|
|
description_key="marketplace.features.letzshop_sync.description",
|
|
category="marketplace",
|
|
feature_type=FeatureType.BINARY,
|
|
scope=FeatureScope.MERCHANT,
|
|
ui_icon="refresh-cw",
|
|
display_order=10,
|
|
),
|
|
FeatureDeclaration(
|
|
code="api_access",
|
|
name_key="marketplace.features.api_access.name",
|
|
description_key="marketplace.features.api_access.description",
|
|
category="marketplace",
|
|
feature_type=FeatureType.BINARY,
|
|
scope=FeatureScope.MERCHANT,
|
|
ui_icon="terminal",
|
|
display_order=20,
|
|
),
|
|
FeatureDeclaration(
|
|
code="webhooks",
|
|
name_key="marketplace.features.webhooks.name",
|
|
description_key="marketplace.features.webhooks.description",
|
|
category="marketplace",
|
|
feature_type=FeatureType.BINARY,
|
|
scope=FeatureScope.MERCHANT,
|
|
ui_icon="webhook",
|
|
display_order=30,
|
|
),
|
|
FeatureDeclaration(
|
|
code="custom_integrations",
|
|
name_key="marketplace.features.custom_integrations.name",
|
|
description_key="marketplace.features.custom_integrations.description",
|
|
category="marketplace",
|
|
feature_type=FeatureType.BINARY,
|
|
scope=FeatureScope.MERCHANT,
|
|
ui_icon="puzzle",
|
|
display_order=40,
|
|
),
|
|
]
|
|
|
|
def get_store_usage(
|
|
self,
|
|
db: Session,
|
|
store_id: int,
|
|
) -> list[FeatureUsage]:
|
|
return []
|
|
|
|
def get_merchant_usage(
|
|
self,
|
|
db: Session,
|
|
merchant_id: int,
|
|
platform_id: int,
|
|
) -> list[FeatureUsage]:
|
|
return []
|
|
|
|
|
|
# Singleton instance for module registration
|
|
marketplace_feature_provider = MarketplaceFeatureProvider()
|
|
|
|
__all__ = [
|
|
"MarketplaceFeatureProvider",
|
|
"marketplace_feature_provider",
|
|
]
|