"""
URL patterns for billing module
"""
from django.urls import path, include
from rest_framework.routers import DefaultRouter
from .views import (
    CreditBalanceViewSet, 
    CreditUsageViewSet, 
    CreditTransactionViewSet,
    BillingOverviewViewSet,
    AdminBillingViewSet
)

router = DefaultRouter()
router.register(r'credits/balance', CreditBalanceViewSet, basename='credit-balance')
router.register(r'credits/usage', CreditUsageViewSet, basename='credit-usage')
router.register(r'credits/transactions', CreditTransactionViewSet, basename='credit-transactions')

urlpatterns = [
    path('', include(router.urls)),
    # User-facing billing overview
    path('account_balance/', BillingOverviewViewSet.as_view({'get': 'account_balance'}), name='account-balance'),
    # Canonical credit balance endpoint
    path('credits/balance/', CreditBalanceViewSet.as_view({'get': 'list'}), name='credit-balance-canonical'),
    # Alias for frontend compatibility (transactions/balance/)
    path('transactions/balance/', CreditBalanceViewSet.as_view({'get': 'list'}), name='transactions-balance'),
    # Explicit list endpoints
    path('transactions/', CreditTransactionViewSet.as_view({'get': 'list'}), name='transactions'),
    path('usage/', CreditUsageViewSet.as_view({'get': 'list'}), name='usage'),
    # Admin billing endpoints
    path('admin/billing/stats/', AdminBillingViewSet.as_view({'get': 'stats'}), name='admin-billing-stats'),
    path('admin/users/', AdminBillingViewSet.as_view({'get': 'list_users'}), name='admin-users-list'),
    path('admin/credit-costs/', AdminBillingViewSet.as_view({'get': 'credit_costs'}), name='admin-credit-costs'),
]

