2015-12-11 10:36:16 +01:00
|
|
|
class SIADE::RNAAdapter
|
2016-01-20 10:34:22 +01:00
|
|
|
def initialize(siret)
|
|
|
|
@siret = siret
|
2015-12-11 10:36:16 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def data_source
|
2015-12-11 12:36:44 +01:00
|
|
|
@data_source ||= JSON.parse(SIADE::API.rna(@siret), symbolize_names: true)
|
2015-12-11 10:36:16 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def to_params
|
2018-02-21 16:29:22 +01:00
|
|
|
params = data_source[:association].slice(*attr_to_fetch)
|
|
|
|
params[:rna] = data_source[:association][:id]
|
2015-12-11 10:36:16 +01:00
|
|
|
params
|
2015-12-11 12:36:44 +01:00
|
|
|
rescue
|
|
|
|
nil
|
2015-12-11 10:36:16 +01:00
|
|
|
end
|
|
|
|
|
2018-02-21 16:29:22 +01:00
|
|
|
private
|
|
|
|
|
2015-12-11 10:36:16 +01:00
|
|
|
def attr_to_fetch
|
2018-01-15 14:42:48 +01:00
|
|
|
[
|
|
|
|
:titre,
|
|
|
|
:objet,
|
|
|
|
:date_creation,
|
|
|
|
:date_declaration,
|
|
|
|
:date_publication
|
2015-12-11 10:36:16 +01:00
|
|
|
]
|
|
|
|
end
|
|
|
|
end
|