File size: 1,077 Bytes
6d07d79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
using FlowAPI.Domain.Entities;

namespace FlowAPI.Application.Services
{
    /// <summary>
    /// Subscription plans. There are only two: Free (small creation limits) and Plus (no limits).
    /// Legacy values ("Pro", "Ultra") are treated as Plus.
    /// </summary>
    public static class Plans
    {
        public const string Free = "Free";
        public const string Plus = "Plus";

        public const int FreeMaxBoards = 5;
        public const int FreeMaxNodesPerBoard = 300;
        public const int FreeMaxGuestsPerBoard = 2;
        public const int FreeMaxTemplates = 3;
        public const int FreeMaxHabits = 3;

        public static string Normalize(string? tier) =>
            string.IsNullOrWhiteSpace(tier) || tier.Trim().Equals(Free, System.StringComparison.OrdinalIgnoreCase)
                ? Free
                : Plus;

        public static bool IsValid(string? tier) =>
            tier != null && (tier.Trim() == Free || tier.Trim() == Plus);

        public static bool IsPlus(User user) => Normalize(user.SubscriptionTier) == Plus;
    }
}