1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
| from enum import Enum from typing import Dict, List
class PricingTier(Enum): FREE = "free" BASIC = "basic" PRO = "pro" ENTERPRISE = "enterprise"
class SubscriptionPlan: """Subscription plan"""
PLANS = { PricingTier.FREE: { 'name': 'Free', 'price': 0, 'features': [ '10 calls per month', 'Basic features', 'Community support' ], 'limits': { 'monthly_calls': 10, 'max_file_size': '5MB', 'support': 'community' } }, PricingTier.BASIC: { 'name': 'Basic', 'price': 29, 'features': [ '100 calls per month', 'All basic features', 'Email support', 'Data export' ], 'limits': { 'monthly_calls': 100, 'max_file_size': '50MB', 'support': 'email' } }, PricingTier.PRO: { 'name': 'Professional', 'price': 99, 'features': [ 'Unlimited calls', 'Advanced features', 'Priority support', 'API access', 'Custom configuration' ], 'limits': { 'monthly_calls': float('inf'), 'max_file_size': '500MB', 'support': 'priority' } }, PricingTier.ENTERPRISE: { 'name': 'Enterprise', 'price': None, 'features': [ 'Unlimited calls', 'All features', 'Dedicated support', 'Private deployment', 'Custom development', 'SLA guarantee' ], 'limits': { 'monthly_calls': float('inf'), 'max_file_size': '10GB', 'support': 'dedicated' } } }
@classmethod def get_plan(cls, tier: PricingTier) -> Dict: """Get plan details""" return cls.PLANS.get(tier)
@classmethod def check_feature_access(cls, tier: PricingTier, feature: str) -> bool: """Check feature access""" plan = cls.get_plan(tier) return feature in plan['features']
@classmethod def check_limit(cls, tier: PricingTier, limit_type: str, value: any) -> bool: """Check if limit exceeded""" plan = cls.get_plan(tier) limit = plan['limits'].get(limit_type)
if limit == float('inf'): return True
return value <= limit
|