~evanj/cms

ref: 7092668b038fb5c831981d303f6553b94b9c0bf8 cms/internal/m/tier/tier.go -rw-r--r-- 1.5 KiB
7092668bEvan M Jones Fix(rate limiting): Don't rely on MySQL time zone for rate limit 1 year, 2 months ago
                                                                                
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
package tier

type Tier struct {
	Name, Price, TimeUnit, StripePriceID string
	Opts                                 []TierOpt
}

type TierOpt struct {
	Text string
}

var (
	Free = Tier{
		"Free",
		"$0",
		"forever",
		"",
		[]TierOpt{
			{"Non-commercial use"},
			{"One space"},
			{"One user"},
			{"60 API requests/min"},
			{"Donation recommended"},
		},
	}

	Business = Tier{
		"Business",
		"$15",
		"mo",
		"price_1H4Eq2KQkRnlhurZmVtyjumS",
		[]TierOpt{
			{"Commercial use"},
			{"Five spaces"},
			{"15 users"},
			{"60 API requests/min"},
			{"File uploads"},
		},
	}

	Enterprise = Tier{
		"Enterprise",
		"$50",
		"mo",
		"price_1H4Eq2KQkRnlhurZHul3PwBB",
		[]TierOpt{
			{"Commercial use"},
			{"Unlimited spaces"},
			{"Unlimited users"},
			{"Unlimited API requests/min"},
			{"File uploads"},
		},
	}

	// SelfHost = Tier{
	// 	"Self host",
	// 	"$500",
	// 	"once",
	// 	[]TierOpt{
	// 		{"Commercial use"},
	// 		{"Unlimited spaces"},
	// 		{"Unlimited users"},
	// 		{"Unlimited API requests/min"},
	// 		{"Bring your object storage"},
	// 	},
	// }

	Tiers = []Tier{
		Free,
		Business,
		Enterprise,
		// SelfHost,
	}
)

func ByName(n string) (Tier, bool) {
	for _, t := range Tiers {
		if t.Name == n {
			return t, true
		}
	}
	return Tier{}, false
}

func ByStripePriceID(n string) (Tier, bool) {
	for _, t := range Tiers {
		if t.StripePriceID == n {
			return t, true
		}
	}
	return Tier{}, false
}

func (t Tier) Is(test Tier) bool {
	return t.Name == test.Name
}