2021-01-13 18:58:59 +01:00
|
|
|
class AnnuaireEducationUpdateJob < ApplicationJob
|
|
|
|
def perform(champ)
|
2021-01-14 23:55:34 +01:00
|
|
|
external_id = champ.external_id
|
2021-01-13 18:58:59 +01:00
|
|
|
|
2021-01-14 23:55:34 +01:00
|
|
|
if external_id.present?
|
2020-08-05 18:40:47 +02:00
|
|
|
data = APIEducation::AnnuaireEducationAdapter.new(external_id).to_params
|
2021-01-13 18:58:59 +01:00
|
|
|
|
|
|
|
if data.present?
|
|
|
|
champ.data = data
|
|
|
|
else
|
2021-01-14 23:55:34 +01:00
|
|
|
champ.external_id = nil
|
2021-01-13 18:58:59 +01:00
|
|
|
end
|
|
|
|
champ.save!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|