demarches-normaliennes/app/jobs/etablissement_update_job.rb
gregoirenovel a3fd271b00 Remove legacy
Update EtablissementUpdateJob
2018-05-24 17:54:51 +02:00

16 lines
562 B
Ruby

class EtablissementUpdateJob < ApplicationJob
queue_as :default
def perform(dossier, siret)
etablissement_attributes = ApiEntrepriseService.get_etablissement_params_for_siret(siret, dossier.procedure_id)
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