namespace :employer_automation do

  desc "Employer Initialization Automation"
  # rake employer_automation:employer_initialize
  task employer_initialize: :environment do
    puts "Running Employer Init Automation"
    Employer.missing_keychain_initialization.map(&:sync_with_vhcs)
    Employer.missing_plans_initialization.map(&:sync_plans_with_vhcs)
    Employer.missing_members_initialization.map(&:sync_members_with_vhcs)
  end

  desc "Employer Initialization Automation Test"
  # rake employer_automation:employer_initialize_test
  task employer_initialize_test: :environment do
    if (missing_keychain = Employer.missing_keychain_initialization).exists?
      missing_keychain.map(&:sync_with_vhcs)
    elsif (missing_plans = Employer.missing_plans_initialization).exists?
      missing_plans.map(&:sync_plans_with_vhcs)
    elsif (missing_members = Employer.missing_members_initialization).exists?
      missing_members.map(&:sync_members_with_vhcs)
    end
  end



  desc "Employer Maintenance Automation"
  # rake employer_automation:employer_maintenance
  task employer_maintenance: :environment do
    Employer.automation_ready.map(&:sync_with_vhcs)
    Employer.with_active_id_card_setup.map(&:sync_plans_with_vhcs)
    Employer.with_active_id_card_setup.map(&:sync_members_with_vhcs)
  end

end
