2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-08-05 18:40:47 +02:00
|
|
|
class APIEntreprise::EffectifsAdapter < APIEntreprise::Adapter
|
2020-05-14 14:41:54 +02:00
|
|
|
def initialize(siret, procedure_id, annee, mois)
|
|
|
|
@siret = siret
|
2020-04-07 14:20:22 +02:00
|
|
|
@procedure_id = procedure_id
|
|
|
|
@annee = annee
|
|
|
|
@mois = mois
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def get_resource
|
2023-10-17 13:23:17 +02:00
|
|
|
api(@procedure_id).effectifs(@siret, @annee, @mois)
|
2020-04-07 14:20:22 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def process_params
|
2023-10-17 13:23:17 +02:00
|
|
|
data = data_source.fetch(:data, nil)
|
|
|
|
Sentry.with_scope do |scope|
|
|
|
|
scope.set_tags(siret: @siret)
|
|
|
|
scope.set_extras(source: data)
|
|
|
|
effectifs = data&.fetch(:effectifs_mensuels, nil)&.first
|
|
|
|
if effectifs.present?
|
|
|
|
{
|
|
|
|
entreprise_effectif_mensuel: effectifs[:value],
|
|
|
|
entreprise_effectif_mois: effectifs[:mois],
|
|
|
|
entreprise_effectif_annee: effectifs[:annee]
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{}
|
|
|
|
end
|
2020-04-07 14:20:22 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|