# app/api/v1/merchant/__init__.py
"""
Merchant API router aggregation.

This module combines auto-discovered module routes for the merchant API.

Merchant routes provide the billing portal for business owners:
- billing: subscriptions, invoices, tier management, checkout
- tenancy: stores list, merchant profile

IMPORTANT:
- This router is for JSON API endpoints only
- HTML page routes are mounted separately in main.py
- Module routes are auto-discovered from app/modules/{module}/routes/api/merchant.py
"""

from fastapi import APIRouter

# Create merchant router
router = APIRouter()


# ============================================================================
# Auto-discovered Module Routes
# ============================================================================
# All routes from self-contained modules are auto-discovered and registered.
# Modules provide merchant routes at: routes/api/merchant.py

from app.modules.routes import get_merchant_api_routes

for route_info in get_merchant_api_routes():
    # Only pass prefix if custom_prefix is set (router already has internal prefix)
    if route_info.custom_prefix:
        router.include_router(
            route_info.router,
            prefix=route_info.custom_prefix,
            tags=route_info.tags,
        )
    else:
        router.include_router(
            route_info.router,
            tags=route_info.tags,
        )

# Export the router
__all__ = ["router"]
