demarches-normaliennes/app/jobs/etablissement_update_job.rb

22 lines
704 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2018-04-05 14:52:29 +02:00
class EtablissementUpdateJob < ApplicationJob
2024-09-24 21:24:22 +02:00
queue_as :critical # reporting will be done asap, but no occurence found. maube dead?
2018-04-05 14:52:29 +02:00
def perform(dossier, siret)
begin
2020-08-05 18:40:47 +02:00
etablissement_attributes = APIEntrepriseService.get_etablissement_params_for_siret(siret, dossier.procedure.id)
rescue
return
end
2018-04-05 14:52:29 +02:00
if etablissement_attributes.present?
if dossier.etablissement.present?
dossier.etablissement.destroy
end
etablissement_attributes = ActionController::Parameters.new(etablissement_attributes).permit!
etablissement = dossier.build_etablissement(etablissement_attributes)
etablissement.save
end
end
end