2018-03-28 15:24:43 +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
|
2018-03-29 12:16:46 +02:00
|
|
|
ApiEntreprise::API.exercices(@siret, @procedure_id)
|
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
|