From 1746000737e7d944445137a4ff7cf384ab57e0a5 Mon Sep 17 00:00:00 2001 From: Robin Monnier Date: Mon, 16 Dec 2024 14:44:18 +0100 Subject: [PATCH] fix: remove stub insee, use wildcard (#1461) --- clients/routes.ts | 6 ++++-- clients/sirene-insee/siren.ts | 2 +- clients/sirene-insee/siret.ts | 4 ++-- cypress/mocks/routes.ts | 4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/clients/routes.ts b/clients/routes.ts index a32a1ea0b..98669a5e8 100644 --- a/clients/routes.ts +++ b/clients/routes.ts @@ -197,8 +197,10 @@ const routes = { sireneInsee: { auth: 'https://auth.insee.net/auth/realms/apim-gravitee/protocol/openid-connect/token', avis: 'https://api-avis-situation-sirene.insee.fr/identification/pdf/', - siren: 'https://api.insee.fr/api-sirene/prive/3.11/siren/', - siret: 'https://api.insee.fr/api-sirene/prive/3.11/siret/', + getBySiren: (siren: string) => + `https://api.insee.fr/api-sirene/prive/3.11/siren/${siren}`, + getBySiret: (siret: string) => + `https://api.insee.fr/api-sirene/prive/3.11/siret/${siret}`, }, rechercheEntreprise: { rechercheUniteLegale: 'https://recherche-entreprises.api.gouv.fr/search', diff --git a/clients/sirene-insee/siren.ts b/clients/sirene-insee/siren.ts index bc96c261e..f0b484006 100644 --- a/clients/sirene-insee/siren.ts +++ b/clients/sirene-insee/siren.ts @@ -133,7 +133,7 @@ export const clientUniteLegaleInsee = async ( const clientTmpUniteLegale = async (siren: Siren, useFallback: boolean) => { const dataUniteLegale = await inseeClientGet( - routes.sireneInsee.siren + siren, + routes.sireneInsee.getBySiren(siren), {}, useFallback ); diff --git a/clients/sirene-insee/siret.ts b/clients/sirene-insee/siret.ts index 8e8469406..3082dba6d 100644 --- a/clients/sirene-insee/siret.ts +++ b/clients/sirene-insee/siret.ts @@ -102,7 +102,7 @@ export const clientAllEtablissementsInsee = async ( const { header, etablissements } = await inseeClientGet( - routes.sireneInsee.siret, + routes.sireneInsee.getBySiret(''), { params: { q: `siren:${siren}`, @@ -130,7 +130,7 @@ export const clientEtablissementInsee = async ( ) => { const { etablissement, etablissements } = await inseeClientGet( - routes.sireneInsee.siret + siret, + routes.sireneInsee.getBySiret(siret), {}, useFallback ); diff --git a/cypress/mocks/routes.ts b/cypress/mocks/routes.ts index 9114ca41a..3d4e6aab7 100644 --- a/cypress/mocks/routes.ts +++ b/cypress/mocks/routes.ts @@ -44,6 +44,6 @@ export const routesHandlers = [ http.get(routes.educationNationale.search, educationNationaleHandler), http.get(routes.ban, baseAdresseNationaleHandler), http.post(routes.sireneInsee.auth, apiSireneInseeAuthHandler), - http.get(routes.sireneInsee.siret, apiSireneInseeSiretHandler), - http.get(routes.sireneInsee.siren, apiSireneInseeSirenHandler), + http.get(routes.sireneInsee.getBySiret('*'), apiSireneInseeSiretHandler), + http.get(routes.sireneInsee.getBySiren('*'), apiSireneInseeSirenHandler), ];