2020-08-05 18:40:47 +02:00
|
|
|
class APIEntreprise::ExercicesAdapter < APIEntreprise::Adapter
|
2018-02-21 16:29:22 +01:00
|
|
|
private
|
|
|
|
|
2018-03-19 15:05:56 +01:00
|
|
|
def get_resource
|
2022-07-20 14:52:17 +02:00
|
|
|
api(@procedure_id).exercices(@siret)
|
2018-03-15 14:30:10 +01:00
|
|
|
end
|
|
|
|
|
2018-03-19 15:45:55 +01:00
|
|
|
def process_params
|
|
|
|
exercices_array = data_source[:exercices].map do |exercice|
|
|
|
|
exercice.slice(*attr_to_fetch)
|
|
|
|
end
|
|
|
|
|
2018-10-04 18:47:39 +02:00
|
|
|
if exercices_array.all? { |params| valid_params?(params) }
|
2018-10-04 16:22:19 +02:00
|
|
|
{ exercices_attributes: exercices_array }
|
|
|
|
else
|
|
|
|
{}
|
|
|
|
end
|
2018-03-19 15:45:55 +01:00
|
|
|
end
|
|
|
|
|
2018-02-21 16:29:22 +01:00
|
|
|
def attr_to_fetch
|
2018-03-19 15:22:51 +01:00
|
|
|
[
|
|
|
|
: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
|