demarches-normaliennes/app/controllers/api/v1/procedures_controller.rb

18 lines
643 B
Ruby
Raw Normal View History

2015-12-21 17:51:49 +01:00
class API::V1::ProceduresController < APIController
api :GET, '/procedures/:id', 'Informations concernant une procédure'
param :id, Integer, desc: "L'identifiant de la procédure", required: true
2016-02-26 14:16:17 +01:00
param :token, String, desc: "Token administrateur", required: true
error code: 401, desc: "Non authorisé"
error code: 404, desc: "Procédure inconnue"
def show
2016-11-15 09:54:17 +01:00
procedure = current_administrateur.procedures.find(params[:id]).decorate
2015-12-21 17:51:49 +01:00
2016-11-15 09:54:17 +01:00
render json: {procedure: ProcedureSerializer.new(procedure).as_json}
2015-12-21 17:51:49 +01:00
rescue ActiveRecord::RecordNotFound => e
Rails.logger.error(e.message)
render json: {}, status: 404
end
2016-02-22 17:53:00 +01:00
2015-12-21 17:51:49 +01:00
end