2015-12-21 17:51:49 +01:00
|
|
|
class API::V1::ProceduresController < APIController
|
2018-09-26 16:38:35 +02:00
|
|
|
before_action :fetch_procedure_and_check_token
|
|
|
|
|
2018-03-16 10:10:43 +01:00
|
|
|
resource_description do
|
|
|
|
description AUTHENTICATION_TOKEN_DESCRIPTION
|
|
|
|
end
|
|
|
|
|
2018-09-05 14:48:42 +02:00
|
|
|
api :GET, '/procedures/:id', 'Informations concernant une démarche'
|
|
|
|
param :id, Integer, desc: "L'identifiant de la démarche", required: true
|
2016-02-22 19:42:47 +01:00
|
|
|
error code: 401, desc: "Non authorisé"
|
2018-09-05 14:48:42 +02:00
|
|
|
error code: 404, desc: "Démarche inconnue"
|
2016-02-22 19:42:47 +01:00
|
|
|
|
2016-02-02 18:11:44 +01:00
|
|
|
def show
|
2018-09-26 16:38:35 +02:00
|
|
|
render json: { procedure: ProcedureSerializer.new(@procedure.decorate).as_json }
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def fetch_procedure_and_check_token
|
|
|
|
@procedure = Procedure.includes(:administrateur).find(params[:id])
|
|
|
|
|
|
|
|
if !valid_token_for_administrateur?(@procedure.administrateur)
|
|
|
|
render json: {}, status: :unauthorized
|
|
|
|
end
|
2015-12-21 17:51:49 +01:00
|
|
|
|
2018-09-26 16:39:10 +02:00
|
|
|
rescue ActiveRecord::RecordNotFound
|
2018-09-26 16:38:35 +02:00
|
|
|
render json: {}, status: :not_found
|
2015-12-21 17:51:49 +01:00
|
|
|
end
|
|
|
|
end
|