module Youtube class TeamStatus PLATFORM_LABEL = "Match Live TV".freeze def initialize(team) @team = team @ent = team.entitlements @mode = @ent.plan.youtube_mode end def selectable? return false unless @ent.youtube_enabled? case @mode when "matchlivetv_light" PlatformCredential.configured? when "team" @team.club.youtube_credential.present? || PlatformCredential.configured? else false end end def connected? selectable? end def uses_platform_channel? return false unless @ent.youtube_enabled? if @mode == "matchlivetv_light" PlatformCredential.configured? elsif @mode == "team" @team.club.youtube_credential.blank? && PlatformCredential.configured? else false end end def channel_title if uses_platform_channel? PLATFORM_LABEL else @team.club.youtube_credential&.channel_title end end def needs_team_oauth? @mode == "team" && @ent.premium_full? && @team.club.youtube_credential.blank? && !PlatformCredential.configured? end end end