2015-08-10 11:05:06 +02:00
|
|
|
class SIADE::EntrepriseAdapter
|
|
|
|
|
|
|
|
def initialize(siren)
|
|
|
|
@siren = siren
|
|
|
|
end
|
|
|
|
|
|
|
|
def data_source
|
2015-08-17 15:53:35 +02:00
|
|
|
@data_source ||= JSON.parse(SIADE::API.entreprise(@siren), symbolize_names: true)
|
2015-08-10 11:05:06 +02:00
|
|
|
rescue
|
|
|
|
@data_source = nil
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_params
|
|
|
|
params = {}
|
|
|
|
|
|
|
|
data_source[:entreprise].each do |k,v|
|
|
|
|
if attr_to_fetch.include?(k)
|
|
|
|
params[k] = v
|
|
|
|
end
|
|
|
|
end
|
|
|
|
params
|
|
|
|
rescue
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
def attr_to_fetch
|
|
|
|
[: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]
|
|
|
|
end
|
|
|
|
end
|