diff --git a/app/lib/siade/entreprise_adapter.rb b/app/lib/siade/entreprise_adapter.rb index 0e2e15b86..c59e384d0 100644 --- a/app/lib/siade/entreprise_adapter.rb +++ b/app/lib/siade/entreprise_adapter.rb @@ -4,12 +4,6 @@ class SIADE::EntrepriseAdapter @procedure_id = procedure_id end - def data_source - @data_source ||= SIADE::API.entreprise(@siren, @procedure_id) - rescue - @data_source = nil - end - def success? data_source rescue @@ -26,6 +20,12 @@ class SIADE::EntrepriseAdapter private + def data_source + @data_source ||= SIADE::API.entreprise(@siren, @procedure_id) + rescue + @data_source = nil + end + def attr_to_fetch [ :siren, diff --git a/app/lib/siade/etablissement_adapter.rb b/app/lib/siade/etablissement_adapter.rb index 7c6591456..79551a009 100644 --- a/app/lib/siade/etablissement_adapter.rb +++ b/app/lib/siade/etablissement_adapter.rb @@ -4,10 +4,6 @@ class SIADE::EtablissementAdapter @procedure_id = procedure_id end - def data_source - @data_source ||= SIADE::API.etablissement(@siret, @procedure_id) - end - def success? data_source rescue @@ -26,6 +22,10 @@ class SIADE::EtablissementAdapter private + def data_source + @data_source ||= SIADE::API.etablissement(@siret, @procedure_id) + end + def attr_to_fetch [ :adresse, diff --git a/app/lib/siade/exercices_adapter.rb b/app/lib/siade/exercices_adapter.rb index 7e5308d9a..db8dbeb42 100644 --- a/app/lib/siade/exercices_adapter.rb +++ b/app/lib/siade/exercices_adapter.rb @@ -4,12 +4,6 @@ class SIADE::ExercicesAdapter @procedure_id = procedure_id end - def data_source - @data_source ||= SIADE::API.exercices(@siret, @procedure_id) - rescue - @data_source = nil - end - def to_params data_source[:exercices].map do |exercice| exercice.slice(*attr_to_fetch) @@ -20,6 +14,12 @@ class SIADE::ExercicesAdapter private + def data_source + @data_source ||= SIADE::API.exercices(@siret, @procedure_id) + rescue + @data_source = nil + end + def attr_to_fetch [:ca, :date_fin_exercice, :date_fin_exercice_timestamp] end diff --git a/app/lib/siade/rna_adapter.rb b/app/lib/siade/rna_adapter.rb index ff8a21f8d..d168684ab 100644 --- a/app/lib/siade/rna_adapter.rb +++ b/app/lib/siade/rna_adapter.rb @@ -4,10 +4,6 @@ class SIADE::RNAAdapter @procedure_id = procedure_id end - def data_source - @data_source ||= SIADE::API.rna(@siret, @procedure_id) - end - def to_params if data_source[:association][:id].nil? return nil @@ -21,6 +17,10 @@ class SIADE::RNAAdapter private + def data_source + @data_source ||= SIADE::API.rna(@siret, @procedure_id) + end + def attr_to_fetch [ :titre,