class Admin::Settings::TepIntegrationController < Admin::Controller
  def show
    render_success :ok, json: config_props
  end

  def update
    if school_config.update(config_params)
      render_success :ok
    else
      render_error :unprocessable_entity, errors: school_config
    end
  end

  def export
    Reporting::Tep::SchoolJob.perform_async(
      current_school.id,
      current_user.id
    )
  end

  private
    def school_config
      @school_config ||= current_school.school_config
    end

    def config_params
      params.permit(:tep_integration)
    end

    def config_props
      { tep_integration: school_config.tep_integration }
    end
end
