-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: lbac 2256: jobOpportunity (#1337)
* feat: add jobOpportunity type * feat: multi-usage route - wip * feat: update logic - wip * feat: recruteurs_lba - wip * feat: job opportunity recruteur lba * fix: review * feat: job opportunity - wip * feat: job opportunity france travail * feat: missing FT duration * fix: duration typing * feat: update openapi * fix: typing * feat: split rome/rncp routes * fix: typo
- Loading branch information
Showing
17 changed files
with
639 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import axios from "axios" | ||
|
||
import { sentryCaptureException } from "../common/utils/sentryUtils" | ||
import config from "../config" | ||
|
||
import { CertificationAPIApprentissage } from "./queryValidator.service.types" | ||
|
||
const getFirstCertificationFromAPIApprentissage = async (rncp: string): Promise<CertificationAPIApprentissage | null> => { | ||
try { | ||
const { data } = await axios.get<CertificationAPIApprentissage[]>(`${config.apiApprentissage.baseUrl}/certification/v1?identifiant.rncp=${rncp}`, { | ||
headers: { Authorization: `Bearer ${config.apiApprentissage.apiKey}` }, | ||
}) | ||
|
||
if (!data.length) return null | ||
|
||
return data[0] | ||
} catch (error: any) { | ||
sentryCaptureException(error, { responseData: error.response?.data }) | ||
return null | ||
} | ||
} | ||
|
||
const getRomesFromCertification = (certification: CertificationAPIApprentissage) => { | ||
return certification.domaines.rome.rncp.map((x) => x.code) | ||
} | ||
export const getRomesFromRncp = async (rncp: string): Promise<string[] | null> => { | ||
let certification = await getFirstCertificationFromAPIApprentissage(rncp) | ||
if (!certification) { | ||
return null | ||
} | ||
if (certification.periode_validite.rncp.actif) { | ||
return getRomesFromCertification(certification) | ||
} else { | ||
const latestRNCP = certification.continuite.rncp.findLast((rncp) => rncp.actif === true) | ||
if (!latestRNCP) { | ||
return getRomesFromCertification(certification) | ||
} | ||
certification = await getFirstCertificationFromAPIApprentissage(latestRNCP.code) | ||
if (!certification) { | ||
return null | ||
} | ||
return getRomesFromCertification(certification) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.