schedules_controller.rb 608 Bytes
Newer Older
Zac Wood's avatar
Zac Wood committed
1 2 3 4 5 6 7
class API::SchedulesController < ApplicationController
  resource_description do
    short 'Endpoints for generating iCal files'
  end
  # Render an iCal file containing the schedules of all the
  # course sections with the given CRNs.
  api :GET, '/schedules', 'Generate an iCal file with events for the given CRNs'
8
  param :crns, String, desc: 'Comma separated list of crns to include as events in the calendar', required: true
Zac Wood's avatar
Zac Wood committed
9
  def index
10
    crns = params["crns"].split ','
Zac Wood's avatar
Zac Wood committed
11
    @schedule = Schedule.new(crns, @semester.season)
Zac Wood's avatar
Zac Wood committed
12 13 14
    render plain: @schedule.to_ical # render a plaintext iCal file
  end
end