api_entreprise: use v3 in match_mandataire_social endpoint (#75641)
gitea/passerelle/pipeline/head This commit looks good
Details
gitea/passerelle/pipeline/head This commit looks good
Details
This commit is contained in:
parent
5a44fdcdeb
commit
d656b273c9
|
@ -454,18 +454,17 @@ class APIEntreprise(BaseResource):
|
|||
def match_mandataire_social(
|
||||
self, request, siren, first_name, last_name, birthdate, method='simple', **kwargs
|
||||
):
|
||||
entreprise = self.get(
|
||||
'v2/entreprises/%s/' % siren,
|
||||
raw=True,
|
||||
**kwargs,
|
||||
)
|
||||
mandataires = self.get(
|
||||
'v3/infogreffe/rcs/unites_legales/%s/mandataires_sociaux' % siren, raw=True, **kwargs
|
||||
).get('data', [])
|
||||
|
||||
methods = {
|
||||
'simple': simple_match,
|
||||
'levenshtein': levenshtein_match,
|
||||
}
|
||||
if method not in methods:
|
||||
return {'err': 1, 'err_desc': 'method %s not implemented' % method}
|
||||
for mandataire in entreprise.get('entreprise', {}).get('mandataires_sociaux', []):
|
||||
for mandataire in mandataires:
|
||||
if methods[method](mandataire, first_name, last_name, birthdate):
|
||||
return {'err': 0, 'data': mandataire}
|
||||
return {'err': 0, 'data': {}}
|
||||
|
|
|
@ -64,90 +64,6 @@ ETABLISSEMENTS_RESPONSE = {
|
|||
"gateway_error": False,
|
||||
}
|
||||
|
||||
ENTREPRISES_RESPONSE = {
|
||||
"entreprise": {
|
||||
"siren": "418166096",
|
||||
"capital_social": 459356,
|
||||
"numero_tva_intracommunautaire": "FR16418166096",
|
||||
"forme_juridique": "SA à directoire (s.a.i.)",
|
||||
"forme_juridique_code": "5699",
|
||||
"nom_commercial": "OCTO-TECHNOLOGY",
|
||||
"procedure_collective": False,
|
||||
"naf_entreprise": "6202A",
|
||||
"libelle_naf_entreprise": "Conseil en systèmes et logiciels informatiques",
|
||||
"raison_sociale": "OCTO-TECHNOLOGY",
|
||||
"siret_siege_social": "41816609600051",
|
||||
"code_effectif_entreprise": "31",
|
||||
"date_creation": 891381600,
|
||||
"categorie_entreprise": "PME",
|
||||
"diffusable_commercialement": True,
|
||||
"tranche_effectif_salarie_entreprise": {
|
||||
"de": 200,
|
||||
"a": 249,
|
||||
"code": "31",
|
||||
"date_reference": "2014",
|
||||
"intitule": "200 à 249 salariés",
|
||||
},
|
||||
"mandataires_sociaux": [
|
||||
{
|
||||
"nom": "HISQUIN",
|
||||
"prenom": "FRANCOIS",
|
||||
"fonction": "PRESIDENT DU DIRECTOIRE",
|
||||
"dirigeant": True,
|
||||
"date_naissance": "1965-01-27",
|
||||
"raison_sociale": "",
|
||||
"identifiant": "",
|
||||
"type": "PP",
|
||||
},
|
||||
{
|
||||
"nom": "",
|
||||
"prenom": "",
|
||||
"fonction": "COMMISSAIRE AUX COMPTES SUPPLEANT",
|
||||
"dirigeant": True,
|
||||
"date_naissance": "",
|
||||
"date_naissance_timestamp": 0,
|
||||
"raison_sociale": "BCRH & ASSOCIES - SOCIETE A RESPONSABILITE LIMITEE A ASSOCIE UNIQUE",
|
||||
"identifiant": "490092574",
|
||||
"type": "PM",
|
||||
},
|
||||
],
|
||||
"etat_administratif": {
|
||||
"value": "C", # A (actif) ou C (cessé)
|
||||
"date_cessation": 1315173600, # null quand actif (A), un timestamp (un entier) quand cessé (C )
|
||||
},
|
||||
},
|
||||
"etablissement_siege": {
|
||||
"siege_social": True,
|
||||
"siret": "41816609600051",
|
||||
"naf": "6202A",
|
||||
"libelle_naf": "Conseil en systèmes et logiciels informatiques",
|
||||
"date_mise_a_jour": 1449183600,
|
||||
"tranche_effectif_salarie_etablissement": {
|
||||
"de": 200,
|
||||
"a": 249,
|
||||
"code": "31",
|
||||
"date_reference": "2014",
|
||||
"intitule": "200 à 249 salariés",
|
||||
},
|
||||
"date_creation_etablissement": 1108594800,
|
||||
"region_implantation": {"code": "11", "value": "Île-de-France"},
|
||||
"commune_implantation": {"code": "75108", "value": "PARIS 8"},
|
||||
"adresse": {
|
||||
"l1": "OCTO TECHNOLOGY",
|
||||
"l4": "50 AVENUE DES CHAMPS ELYSEES",
|
||||
"l6": "75008 PARIS",
|
||||
"l7": "FRANCE",
|
||||
"numero_voie": "50",
|
||||
"type_voie": "AV",
|
||||
"nom_voie": "DES CHAMPS ELYSEES",
|
||||
"code_postal": "75008",
|
||||
"localite": "PARIS 8",
|
||||
"code_insee_localite": "75108",
|
||||
},
|
||||
"etat_administratif": {"value": "F", "date_fermeture": 1315173600},
|
||||
},
|
||||
"gateway_error": False,
|
||||
}
|
||||
|
||||
UNITES_LEGALES_RESPONSE = {
|
||||
"data": {
|
||||
|
@ -404,7 +320,10 @@ def test_simple_match_mandataire_social(app, resource):
|
|||
params.update(REQUEST_PARAMS)
|
||||
|
||||
with responses.RequestsMock() as rsps:
|
||||
rsps.get('https://entreprise.api.gouv.fr/v2/entreprises/443170139/', json=ENTREPRISES_RESPONSE)
|
||||
rsps.get(
|
||||
'https://entreprise.api.gouv.fr/v3/infogreffe/rcs/unites_legales/443170139/mandataires_sociaux',
|
||||
json=RCS_UNITES_LEGALES_MANDATAIRES_SOCIAUX_RESPONSE,
|
||||
)
|
||||
url = '/api-entreprise/test/match_mandataire_social/443170139/'
|
||||
response = app.get(url, params=params)
|
||||
|
||||
|
@ -448,7 +367,10 @@ def test_levenshtein_match_mandataire_social(app, resource):
|
|||
params.update(REQUEST_PARAMS)
|
||||
|
||||
with responses.RequestsMock() as rsps:
|
||||
rsps.get('https://entreprise.api.gouv.fr/v2/entreprises/443170139/', json=ENTREPRISES_RESPONSE)
|
||||
rsps.get(
|
||||
'https://entreprise.api.gouv.fr/v3/infogreffe/rcs/unites_legales/443170139/mandataires_sociaux',
|
||||
json=RCS_UNITES_LEGALES_MANDATAIRES_SOCIAUX_RESPONSE,
|
||||
)
|
||||
|
||||
url = '/api-entreprise/test/match_mandataire_social/443170139/'
|
||||
response = app.get(url, params=params)
|
||||
|
|
Loading…
Reference in New Issue