class Api::InstitutionServicesController < ApiController
  skip_before_filter :verify_authenticity_token

  def institutions
    @institutions = InstitutionService.where(institution_id: Institution.all).group(:institution_id).order(&:name).map{|a| [a.institution.id, a.institution.name]}
    respond_to do |format|
      format.json { render json: @institutions, callback: params[:callback] }
    end
  end

  def institution_service
    @institution_service = InstitutionService.find(params[:id])
    respond_to do |format|
      format.json { render json: @institution_service, callback: params[:callback] }
    end
  end

  def institution_service_categories
    @institution_service_categories = InstitutionServiceCategory.joins(:institution_services).where(institution_id: params[:id]).order("name ASC")
    respond_to do |format|
      format.json { render json: @institution_service_categories.to_json(:include => [:institution_services]), callback: params[:callback] }
    end
  end

  def institution_service_steps
    @institution_service_steps = InstitutionService.find(params[:id]).institution_service_steps
    respond_to do |format|
      format.json { render json: @institution_service_steps, callback: params[:callback] }
    end
  end

end