class OneRoster::AcademicSessionsController < OneRoster::Controller
  include OneRoster::AcademicSessionScoped

  before_action :authorize_roster_scope
  after_action :set_total_count_header, only: :index

  def index
    render_success :ok, json: { academicSessions: academic_sessions }
  end

  def show
    render_success :ok, json: { academicSession: academic_session }
  end

  private
    def academic_session
      academic_sessions.find { |k| k[:sourcedId] == params[:id] }
    end

    def set_total_count_header
      response.set_header('X-Total-Count', academic_sessions.count.to_s)
    end
end
