Create the Cellar trust level

Stephen Paul Weber created

Change summary

lib/trust_level.rb | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)

Detailed changes

lib/trust_level.rb 🔗

@@ -69,6 +69,49 @@ module TrustLevel
 		end
 	end
 
+	class Cellar
+		TrustLevel.register do |manual:, **|
+			new if manual == "Cellar"
+		end
+
+		def write_cdr?
+			true
+		end
+
+		def support_call?(*)
+			false
+		end
+
+		def send_message?(*)
+			false
+		end
+
+		def validate_credit_card_transaction!(amount, declines)
+			raise DeclinedError.new(declines, max_declines) if declines > max_declines
+			return unless amount > max_top_up_amount
+
+			raise AmountTooHighError.new(amount, max_top_up_amount)
+		end
+
+		def create_subaccount?(*)
+			false
+		end
+
+		def to_s
+			"Cellar"
+		end
+
+		def max_top_up_amount
+			35
+		end
+
+	protected
+
+		def max_declines
+			2
+		end
+	end
+
 	class Basement
 		TrustLevel.register do |manual:, settled_amount:, **|
 			new if manual == "Basement" || (!manual && settled_amount < 10)