2015-11-16 11:23:29 +01:00
|
|
|
class SIADE::ExercicesAdapter
|
2018-03-15 12:02:45 +01:00
|
|
|
def initialize(siret, procedure_id)
|
2015-11-16 11:23:29 +01:00
|
|
|
@siret = siret
|
2018-03-15 12:02:45 +01:00
|
|
|
@procedure_id = procedure_id
|
2015-11-16 11:23:29 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def data_source
|
2018-03-15 14:23:57 +01:00
|
|
|
@data_source ||= SIADE::API.exercices(@siret, @procedure_id)
|
2015-11-16 11:23:29 +01:00
|
|
|
rescue
|
|
|
|
@data_source = nil
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_params
|
2017-12-01 10:56:29 +01:00
|
|
|
data_source[:exercices].map do |exercice|
|
2018-02-21 16:29:22 +01:00
|
|
|
exercice.slice(*attr_to_fetch)
|
2017-12-01 10:56:29 +01:00
|
|
|
end
|
2015-11-16 11:23:29 +01:00
|
|
|
rescue
|
2018-02-21 16:29:22 +01:00
|
|
|
[]
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def attr_to_fetch
|
|
|
|
[:ca, :date_fin_exercice, :date_fin_exercice_timestamp]
|
2015-11-16 11:23:29 +01:00
|
|
|
end
|
2017-04-04 15:27:04 +02:00
|
|
|
end
|