Add Mandataires Sociaux siade lib
This commit is contained in:
parent
cf6b3e955a
commit
3f048d0709
2 changed files with 78 additions and 0 deletions
35
lib/siade/mandataires_sociaux_adapter.rb
Normal file
35
lib/siade/mandataires_sociaux_adapter.rb
Normal file
|
@ -0,0 +1,35 @@
|
|||
class SIADE::MandatairesSociauxAdapter
|
||||
def initialize(siren)
|
||||
@siren = siren
|
||||
end
|
||||
|
||||
def data_source
|
||||
@data_source ||= JSON.parse(SIADE::API.entreprise(@siren), symbolize_names: true)
|
||||
rescue
|
||||
@data_source = nil
|
||||
end
|
||||
|
||||
def to_params
|
||||
params = {}
|
||||
|
||||
data_source[:entreprise][:mandataires_sociaux].each_with_index do |mandataire, i|
|
||||
params[i] = {}
|
||||
|
||||
mandataire.each do |k, v|
|
||||
params[i][k] = v if attr_to_fetch.include?(k)
|
||||
end
|
||||
end
|
||||
|
||||
params
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
|
||||
def attr_to_fetch
|
||||
[:nom,
|
||||
:prenom,
|
||||
:fonction,
|
||||
:date_naissance,
|
||||
:date_naissance_timestamp]
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue