2023-01-13 13:47:17 +01:00
|
|
|
module RNAChampAssociationFetchableConcern
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
def fetch_association!(rna)
|
|
|
|
data = APIEntreprise::RNAAdapter.new(rna, procedure_id).to_params
|
|
|
|
update!(data: data, value: rna)
|
|
|
|
nil
|
|
|
|
rescue APIEntreprise::API::Error, ActiveRecord::RecordInvalid => error
|
2023-01-13 14:52:16 +01:00
|
|
|
self.data = nil
|
|
|
|
self.value = rna
|
|
|
|
save(validate: false)
|
2023-01-13 13:47:17 +01:00
|
|
|
if error.try(:network_error?) && !APIEntrepriseService.api_up?
|
|
|
|
:network_error
|
|
|
|
else
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|