Skip to content

Commit

Permalink
feat: improve IG response
Browse files Browse the repository at this point in the history
  • Loading branch information
XavierJp committed Sep 24, 2024
1 parent e636397 commit 293cc11
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/clients/ig/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import constants from '../../constants';
import { IIdentite } from '../../models/rne';
import { Siren } from '../../models/siren-and-siret';
import { formatNameFull } from '../../utils/helpers/formatters';
import httpClient from '../../utils/network';
Expand Down Expand Up @@ -115,9 +114,7 @@ interface PersonneMorale {
* Call EORI to validate a French EORI number
* @param siret
*/
const clientUniteLegaleIG = async (
siren: Siren
): Promise<{ siren: Siren; immatriculation: IIdentite }> => {
const clientUniteLegaleIG = async (siren: Siren) => {
const response = await httpClient({
url: routes.ig + siren,
timeout: constants.timeout.XXXL,
Expand All @@ -139,7 +136,7 @@ const mapToDomainObject = (r: IGResponse, siren: Siren) => {
: r?.nom +
(r?.personne_morale?.sigle ? ` (${r?.personne_morale?.sigle})` : '');

const dateClotureExercice =
const dateCloture =
r?.personne_morale?.date_cloture_exceptionnelle ??
(r?.personne_morale?.jour_date_cloture &&
r?.personne_morale?.mois_date_cloture)
Expand All @@ -161,20 +158,19 @@ const mapToDomainObject = (r: IGResponse, siren: Siren) => {
idAssociation: r?.personne_morale?.numero_rna || null,
},
immatriculation: {
dateDebutActivite: '',
dateFin: '',
duree: 0,
natureEntreprise: [],
dateCloture,
dateImmatriculation: r.date_immatriculation || '',
dateRadiation: r.date_radiation || '',
dateDebutActiv: '',
dateCessationActivite: '',
isPersonneMorale: !isEI,
denomination: r?.personne_morale?.denomination,
natureEntreprise: '',
dateClotureExercice,
dureePersonneMorale: 0,
capital: r?.personne_morale?.capital
? `${r?.personne_morale?.capital?.montant} ${r?.personne_morale?.capital?.devise?.code} ${r?.personne_morale?.capital?.type}`
: '',
libelleNatureJuridique: natureJuridique,
} as IIdentite,
},
};
};

Expand Down

0 comments on commit 293cc11

Please sign in to comment.