2021-01-14 17:29:57 +01:00
|
|
|
class Champs::AnnuaireEducationChamp < Champs::TextChamp
|
2021-02-09 12:35:23 +01:00
|
|
|
def fetch_external_data?
|
|
|
|
true
|
2021-01-14 17:29:57 +01:00
|
|
|
end
|
|
|
|
|
2021-02-09 12:35:23 +01:00
|
|
|
def fetch_external_data
|
2021-02-19 11:29:08 +01:00
|
|
|
APIEducation::AnnuaireEducationAdapter.new(external_id).to_params
|
2021-01-14 17:29:57 +01:00
|
|
|
end
|
2023-02-28 13:55:52 +01:00
|
|
|
|
|
|
|
def update_with_external_data!(data:)
|
|
|
|
if data&.is_a?(Hash) && data['nom_etablissement'].present? && data['nom_commune'].present? && data['identifiant_de_l_etablissement'].present?
|
|
|
|
update!(
|
|
|
|
data: data,
|
|
|
|
value: "#{data['nom_etablissement']}, #{data['nom_commune']} (#{data['identifiant_de_l_etablissement']})"
|
|
|
|
)
|
|
|
|
else
|
|
|
|
update!(data: data)
|
|
|
|
end
|
|
|
|
end
|
2021-01-14 17:29:57 +01:00
|
|
|
end
|