2022-10-04 22:11:01 +02:00
|
|
|
class Champs::RNAController < ApplicationController
|
|
|
|
before_action :authenticate_logged_user!
|
|
|
|
|
|
|
|
def show
|
|
|
|
@champ = policy_scope(Champ).find(params[:champ_id])
|
|
|
|
@rna = read_param_value(@champ.input_name, 'value')
|
2022-10-05 12:31:34 +02:00
|
|
|
@network_error = false
|
2022-10-04 22:11:01 +02:00
|
|
|
begin
|
|
|
|
data = APIEntreprise::RNAAdapter.new(@rna, @champ.procedure_id).to_params
|
2022-10-11 15:11:51 +02:00
|
|
|
@champ.update!(data: data, value: @rna)
|
2022-10-05 12:31:34 +02:00
|
|
|
rescue APIEntreprise::API::Error, ActiveRecord::RecordInvalid => error
|
|
|
|
@network_error = true if error.try(:network_error?) && !APIEntrepriseService.api_up?
|
2022-10-11 15:11:51 +02:00
|
|
|
@champ.update(data: nil, value: nil)
|
2022-10-04 22:11:01 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|