2020-08-05 18:40:47 +02:00
|
|
|
class APIEntreprise::EtablissementAdapter < 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).etablissement(@siret)
|
2018-03-15 14:30:10 +01:00
|
|
|
end
|
|
|
|
|
2018-03-19 15:45:55 +01:00
|
|
|
def process_params
|
|
|
|
params = data_source[:etablissement].slice(*attr_to_fetch)
|
2018-10-04 16:22:19 +02:00
|
|
|
|
|
|
|
if valid_params?(params)
|
|
|
|
adresse_line = params[:adresse].slice(*address_lines_to_fetch).values.compact.join("\r\n")
|
|
|
|
params.merge!(params[:adresse].slice(*address_attr_to_fetch))
|
|
|
|
params[:adresse] = adresse_line
|
|
|
|
params
|
|
|
|
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
|
|
|
[
|
2018-02-21 16:29:22 +01:00
|
|
|
:adresse,
|
2018-01-15 14:42:48 +01:00
|
|
|
:siret,
|
|
|
|
:siege_social,
|
|
|
|
:naf,
|
2020-03-04 17:12:50 +01:00
|
|
|
:libelle_naf,
|
2020-08-20 10:21:34 +02:00
|
|
|
:enseigne,
|
2020-03-04 17:12:50 +01:00
|
|
|
:diffusable_commercialement
|
2015-08-20 16:46:46 +02:00
|
|
|
]
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|
|
|
|
|
2018-02-21 16:29:22 +01:00
|
|
|
def address_attr_to_fetch
|
2018-01-15 14:42:48 +01:00
|
|
|
[
|
|
|
|
:numero_voie,
|
|
|
|
:type_voie,
|
|
|
|
:nom_voie,
|
|
|
|
:complement_adresse,
|
|
|
|
:code_postal,
|
|
|
|
:localite,
|
|
|
|
:code_insee_localite
|
|
|
|
]
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|
2018-02-21 16:29:22 +01:00
|
|
|
|
|
|
|
def address_lines_to_fetch
|
|
|
|
[:l1, :l2, :l3, :l4, :l5, :l6, :l7]
|
|
|
|
end
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|