"""
Views for billing and subscription management.
"""
from rest_framework.decorators import api_view, permission_classes
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response


@api_view(['GET'])
@permission_classes([IsAuthenticated])
def usage_stats(request):
    """Get user usage statistics."""
    user = request.user
    limits = user.get_usage_limits()
    
    # This would be implemented with actual usage tracking
    current_usage = {
        'api_calls_this_month': 0,
        'reports_this_month': 0,
        'forecast_requests_this_month': 0,
    }
    
    return Response({
        'subscription_type': user.subscription_type,
        'limits': limits,
        'current_usage': current_usage,
    })


@api_view(['GET'])
@permission_classes([IsAuthenticated])
def subscription_info(request):
    """Get subscription information."""
    user = request.user
    limits = user.get_usage_limits()
    
    return Response({
        'subscription_type': user.subscription_type,
        'limits': limits,
        'is_api_enabled': user.is_api_enabled,
    })

