demarches-normaliennes/app/lib/siade/exercices_adapter.rb

24 lines
493 B
Ruby
Raw Normal View History

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|
{
ca: exercice[:ca],
dateFinExercice: exercice[:date_fin_exercice],
date_fin_exercice_timestamp: exercice[:date_fin_exercice_timestamp]
}
end
rescue
nil
end
2017-04-04 15:27:04 +02:00
end