demarches-normaliennes/app/lib/siade/exercices_adapter.rb
2018-02-27 16:22:53 +01:00

25 lines
453 B
Ruby

class SIADE::ExercicesAdapter
def initialize(siret)
@siret = siret
end
def data_source
@data_source ||= JSON.parse(SIADE::API.exercices(@siret), symbolize_names: true)
rescue
@data_source = nil
end
def to_params
data_source[:exercices].map do |exercice|
exercice.slice(*attr_to_fetch)
end
rescue
[]
end
private
def attr_to_fetch
[:ca, :date_fin_exercice, :date_fin_exercice_timestamp]
end
end