49 lines
1.5 KiB
Ruby
49 lines
1.5 KiB
Ruby
# == Schema Information
|
|
#
|
|
# Table name: champs
|
|
#
|
|
# id :integer not null, primary key
|
|
# data :jsonb
|
|
# fetch_external_data_exceptions :string is an Array
|
|
# prefilled :boolean default(FALSE)
|
|
# private :boolean default(FALSE), not null
|
|
# rebased_at :datetime
|
|
# row :integer
|
|
# type :string
|
|
# value :string
|
|
# value_json :jsonb
|
|
# created_at :datetime
|
|
# updated_at :datetime
|
|
# dossier_id :integer
|
|
# etablissement_id :integer
|
|
# external_id :string
|
|
# parent_id :bigint
|
|
# row_id :string
|
|
# type_de_champ_id :integer
|
|
#
|
|
class Champs::MesriChamp < Champs::TextChamp
|
|
# see https://github.com/betagouv/api-particulier/blob/master/src/presentation/middlewares/mesri-input-validation.middleware.ts
|
|
store_accessor :value_json, :ine
|
|
|
|
def blank?
|
|
external_id.nil?
|
|
end
|
|
|
|
def fetch_external_data?
|
|
true
|
|
end
|
|
|
|
def fetch_external_data
|
|
return if !valid?
|
|
|
|
APIParticulier::MesriAdapter.new(
|
|
procedure.api_particulier_token,
|
|
ine,
|
|
procedure.api_particulier_sources
|
|
).to_params
|
|
end
|
|
|
|
def external_id
|
|
{ ine: ine }.to_json if ine.present?
|
|
end
|
|
end
|