fix(api-entreprise): do not crash when siret not found

This commit is contained in:
Paul Chavard 2023-04-05 18:38:13 +02:00
parent 6511836f2d
commit d1d5bc2e67
2 changed files with 19 additions and 10 deletions

View file

@ -6,7 +6,14 @@ class APIEntreprise::EntrepriseAdapter < APIEntreprise::Adapter
end
def process_params
params = data_source[:entreprise]&.slice(*attr_to_fetch)
params = data_source[:entreprise]
return {} if params.nil?
Sentry.with_scope do |scope|
scope.set_tags(siret: @siret)
scope.set_extras(source: params)
params = params.slice(*attr_to_fetch)
params[:etat_administratif] = map_etat_administratif(data_source)
if params.present? && valid_params?(params)
@ -19,6 +26,7 @@ class APIEntreprise::EntrepriseAdapter < APIEntreprise::Adapter
{}
end
end
end
def attr_to_fetch
[

View file

@ -15,12 +15,13 @@ class APIEntreprise::RNAAdapter < APIEntreprise::Adapter
def process_params
params = data_source[:association]
return {} if params.nil?
Sentry.with_scope do |scope|
scope.set_tags(siret: @siret)
scope.set_extras(source: params)
params = params&.slice(*attr_to_fetch) if @depreciated
params = params.slice(*attr_to_fetch) if @depreciated
params[:rna] = data_source.dig(:association, :id)
if params[:rna].present? && valid_params?(params)