from django.urls import path
from rest_framework.routers import DefaultRouter

from .views import AdminBillingViewSet

router = DefaultRouter()

urlpatterns = [
    path('billing/stats/', AdminBillingViewSet.as_view({'get': 'stats'}), name='admin-billing-stats'),
    path('users/', AdminBillingViewSet.as_view({'get': 'list_users'}), name='admin-users-list'),
    path('users/<int:user_id>/adjust-credits/', AdminBillingViewSet.as_view({'post': 'adjust_credits'}), name='admin-adjust-credits'),
    path('credit-costs/', AdminBillingViewSet.as_view({'get': 'list_credit_costs', 'post': 'update_credit_costs'}), name='admin-credit-costs'),
    # Unified admin billing endpoints (legacy aliases routed to AdminBillingViewSet)
    path('billing/invoices/', AdminBillingViewSet.as_view({'get': 'invoices'}), name='admin-billing-invoices'),
    path('billing/payments/', AdminBillingViewSet.as_view({'get': 'payments'}), name='admin-billing-payments'),
    path('billing/pending_payments/', AdminBillingViewSet.as_view({'get': 'pending_payments'}), name='admin-billing-pending-payments'),
    path('billing/<int:pk>/approve_payment/', AdminBillingViewSet.as_view({'post': 'approve_payment'}), name='admin-billing-approve-payment'),
    path('billing/<int:pk>/reject_payment/', AdminBillingViewSet.as_view({'post': 'reject_payment'}), name='admin-billing-reject-payment'),
    path('billing/payment-method-configs/', AdminBillingViewSet.as_view({'get': 'payment_method_configs', 'post': 'payment_method_configs'}), name='admin-billing-payment-method-configs'),
    path('billing/payment-method-configs/<int:pk>/', AdminBillingViewSet.as_view({
        'get': 'payment_method_config',
        'patch': 'payment_method_config',
        'put': 'payment_method_config',
        'delete': 'payment_method_config',
    }), name='admin-billing-payment-method-config'),
    path('billing/account-payment-methods/', AdminBillingViewSet.as_view({'get': 'account_payment_methods', 'post': 'account_payment_methods'}), name='admin-billing-account-payment-methods'),
    path('billing/account-payment-methods/<int:pk>/', AdminBillingViewSet.as_view({
        'get': 'account_payment_method',
        'patch': 'account_payment_method',
        'put': 'account_payment_method',
        'delete': 'account_payment_method',
    }), name='admin-billing-account-payment-method'),
    path('billing/account-payment-methods/<int:pk>/set_default/', AdminBillingViewSet.as_view({'post': 'set_default_account_payment_method'}), name='admin-billing-account-payment-method-set-default'),
]

urlpatterns += router.urls
