from rest_framework import serializers
from .models import Plan, BillingCycle

# Serializer for BillingCycle
class BillingCycleSerializer(serializers.ModelSerializer):
    class Meta:
        model = BillingCycle
        fields = ['id', 'plan', 'type', 'price']

# Serializer for Plan
class PlanSerializer(serializers.ModelSerializer):
    billing_cycles = BillingCycleSerializer(many=True)  # Nested serializer for BillingCycle

    class Meta:
        model = Plan
        fields = ['id', 'plan_name', 'speed', 'base_price', 'data', 'wifi_router', 'tv_channels', 'otts', 'hotstar', 'prime', 'billing_cycles']
