2018-03-28 15:24:43 +02:00
|
|
|
class ApiEntreprise::EntrepriseAdapter < 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
|
|
|
siren = @siret[0..8]
|
2018-03-29 12:15:33 +02:00
|
|
|
ApiEntreprise::API.entreprise(siren, @procedure_id)
|
2018-03-15 14:30:10 +01:00
|
|
|
end
|
|
|
|
|
2018-03-19 15:45:55 +01:00
|
|
|
def process_params
|
|
|
|
params = data_source[:entreprise].slice(*attr_to_fetch)
|
2018-10-04 16:22:19 +02:00
|
|
|
|
|
|
|
if valid_params?(params)
|
2018-10-25 15:29:25 +02:00
|
|
|
params[:date_creation] = Time.zone.at(params[:date_creation]).to_datetime
|
2018-10-04 16:22:19 +02:00
|
|
|
params.transform_keys { |k| :"entreprise_#{k}" }
|
|
|
|
else
|
|
|
|
{}
|
|
|
|
end
|
2018-03-19 15:45:55 +01:00
|
|
|
end
|
|
|
|
|
2015-08-10 11:05:06 +02:00
|
|
|
def attr_to_fetch
|
2018-01-15 14:42:48 +01:00
|
|
|
[
|
|
|
|
:siren,
|
|
|
|
:capital_social,
|
|
|
|
:numero_tva_intracommunautaire,
|
|
|
|
:forme_juridique,
|
|
|
|
:forme_juridique_code,
|
|
|
|
:nom_commercial,
|
|
|
|
:raison_sociale,
|
|
|
|
:siret_siege_social,
|
|
|
|
:code_effectif_entreprise,
|
|
|
|
:date_creation,
|
|
|
|
:nom,
|
|
|
|
:prenom
|
|
|
|
]
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|
|
|
|
end
|