diff --git a/lib/trust_level.rb b/lib/trust_level.rb index faedaa74f580b24a1e5742ab76620ab30b5fef5d..10668cac7dcc5116b887f91be939dee7488078cf 100644 --- a/lib/trust_level.rb +++ b/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)