demarches-normaliennes/app/jobs/etablissement_update_job.rb
Pierre de La Morinerie 150ddab660 zeitwerk: Api -> API
2021-02-09 13:07:30 +01:00

18 lines
585 B
Ruby

class EtablissementUpdateJob < ApplicationJob
def perform(dossier, siret)
begin
etablissement_attributes = APIEntrepriseService.get_etablissement_params_for_siret(siret, dossier.procedure.id)
rescue
return
end
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