demarches-normaliennes/lib/siade/rna_adapter.rb

29 lines
471 B
Ruby
Raw Normal View History

2015-12-11 10:36:16 +01:00
class SIADE::RNAAdapter
def initialize(siren)
@siret = siren
end
def data_source
@data_source ||= JSON.parse(SIADE::API.rna(@siren), symbolize_names: true)
end
def to_params
params = {}
data_source[:association].each do |k, v|
params[k] = v if attr_to_fetch.include?(k)
end
params
end
def attr_to_fetch
[:id,
:titre,
:objet,
:date_creation,
:date_declaration,
:date_publication
]
end
end