class CategoryHelper

  def self.category_data(opts = {})
    # Returns table name and name of the button containing the url link based on category arg
    category_data = {}
    case opts[:category]
    when 'asset_conflict'
      category_data[:header] = 'Asset conflicts'
      category_data[:report_name] = 'Asset conflict report'
      category_data[:tab_name] = 'assets'
    when 'asset'
      category_data[:header] = 'Assets'
      category_data[:report_name] = 'Asset'
      category_data[:tab_name] = 'assets'
    when 'claim'
      category_data[:header] = 'Claims'
      category_data[:report_name] = 'Report in CSV'
      category_data[:tab_name] = 'claims'
    when 'rev_claim'
      category_data[:header] = 'Ads revenue'
      category_data[:report_name] = 'Claim summary'
      category_data[:tab_name] = 'financial'
    when 'rev_claim_raw'
      category_data[:header] = /Ads revenue/
      category_data[:report_name] = 'Claim'
      category_data[:tab_name] = 'financial'
    when 'rev_video'
      category_data[:header] = 'Ads revenue'
      category_data[:report_name] = 'Video'
      category_data[:tab_name] = 'financial'
    when 'video'
      category_data[:header] = 'Videos'
      category_data[:report_name] = 'Video'
      category_data[:tab_name] = 'videos'
    when 'sub_rev'
      category_data[:header] = /Subscription revenue/
      category_data[:tab_name] = 'financial'
    when 'payment_summary'
      category_data[:header] = 'Payment summary'
      category_data[:report_name] = 'Summary'
      category_data[:tab_name] = 'summary'
    when 'audio_tier_revenue'
      category_data[:header] = /Audio tier revenue/
      category_data[:tab_name] = 'financial'
    when 'paid_features'
      category_data[:header] = /Paid features/
      category_data[:tab_name] = 'financial'
    when 'ads_adjustments_revenue'
      category_data[:header] = /Ads adjustments revenue/
      category_data[:tab_name] = 'financial'
    when 'subscription_adjustments_revenue'
      category_data[:header] = /Subscription adjustments revenue/
      category_data[:tab_name] = 'financial'
    when 'transactions_revenue'
      category_data[:header] = /Transactions revenue/
      category_data[:tab_name] = 'financial'
    when 'other'
      category_data[:header] = /Other/
      category_data[:tab_name] = 'financial'
    when 'shorts'
      category_data[:header] = 'Shorts'
      category_data[:tab_name] = 'claims'
    else
      fail('Not a valid category')
    end
    if opts[:reportname]
      category_data[:report_name] = opts[:reportname]
    end
    category_data[:version] = select_version(opts)
    if opts[:location]
      category_data[:location] = opts[:location]
    end
    category_data
  end

  def self.select_version(opts = {})
    # Returns text of version button based on reportversion and/or category args
    if opts[:reportversion] == '1.1'
      'Version 1.1'
    elsif opts[:reportversion] == '1.2' || opts[:category].include?('asset')
      'Version 1.2'
    elsif opts[:reportversion] == '1.0' || opts[:category] == 'claim'
      'Version 1.0'
    elsif opts[:reportversion] == '1.3' || opts[:category] == 'video'
      'Version 1.3'
    elsif opts[:reportversion] == '1.4'
      'Version 1.4'
    else
      fail('Version/category not currently supported.')
    end
  end
end
