module Tournaments class EntitlementError < StandardError attr_reader :code, :billing_url def initialize(message, code:, billing_url: nil) super(message) @code = code @billing_url = billing_url end end class Entitlements def initialize(club) @club = club end def subscription @subscription ||= @club.subscription end def premium_full? subscription&.premium_full? == true end def billing_url "#{MatchLiveTv.app_public_url.chomp('/')}/clubs/#{@club.id}/billing" end def assert_creatable! assert_writable! end def assert_writable! unless premium_full? raise EntitlementError.new( "I tornei sono disponibili con il piano Premium Full.", code: "premium_full_required", billing_url: billing_url ) end end end end