demarches-normaliennes/app/models/champs/rnf_champ.rb
krichtof 61654d65a2
Merge pull request #9740 from demarches-simplifiees/9670-expose-rnf-api
En tant que consommateur de l'API DS, je peux récupérer les infos RNF
2023-11-23 12:55:58 +00:00

35 lines
652 B
Ruby

class Champs::RNFChamp < Champ
store_accessor :data, :title, :email, :phone, :createdAt, :updatedAt, :dissolvedAt, :address, :status
def rnf_id
external_id
end
def value
rnf_id
end
def fetch_external_data
RNFService.new.(rnf_id:)
end
def fetch_external_data?
true
end
def poll_external_data?
true
end
def blank?
rnf_id.blank?
end
def for_export
if data
[rnf_id, data['title'], data.dig('address', 'label'), data.dig('address', 'cityCode'), "#{data['department']} - #{APIGeoService.departement_name(data['department'])}"]
else
[rnf_id, nil, nil, nil, nil]
end
end
end