demarches-normaliennes/app/lib/siade/exercices_adapter.rb
2018-03-19 11:39:46 +01:00

26 lines
480 B
Ruby

class SIADE::ExercicesAdapter
def initialize(siret, procedure_id)
@siret = siret
@procedure_id = procedure_id
end
def to_params
data_source[:exercices].map do |exercice|
exercice.slice(*attr_to_fetch)
end
rescue
[]
end
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
end