Skip to content

Commit

Permalink
feat(dila.js): add examples (Legilibre#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Bouquillon authored and adipasquale committed Jun 11, 2019
1 parent 3dfe178 commit 28f5f62
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
46 changes: 46 additions & 0 deletions packages/dila.js/examples/kali/convention-collective-full.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const dila = require("../dila");
const { JSONlog } = require("../../src/utils");

/*
renvoie la structure de base d'une convention collective et de tous ses textes attachés en JSON
ex: KALICONT000005635807: Convention collective nationale des salariés du particulier employeur du 24 novembre 1999.
*/

const flatify = arr => arr.reduce((a, c) => [...a, ...c], []);

dila
// récupère le conteneur principal
.getConteneur({ id: "KALICONT000005635807", date: "2019-01-01" })
// récupère le texte du conteneur principal
.then(({ data }) => dila.getTexte({ id: data.texte_de_base, date: "2019-01-01" }))
.then(texte =>
// récupères tous les textes attachés
Promise.all(
["extensions", "attaches", "salaires"].map(typeTextes =>
dila
.getConventionTextes({
conteneurId: "KALICONT000005635807",
typeTextes,
date: "2019-01-01"
})
.then(data =>
// recupère la structure de chaque texte attaché
Promise.all(
data.textes.map(texte => dila.getTexte({ id: texte.id, date: "2019-01-01" }))
)
)
)
)
.then(flatify)
.then(attaches => ({
id: "KALICONT000005635807",
date: "2019-01-01",
base: texte,
attaches
}))
)

.then(JSONlog)
.catch(console.log)
.then(dila.close);
17 changes: 17 additions & 0 deletions packages/dila.js/examples/kali/convention-collective.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const dila = require("../dila");
const html = require("../../src/html");

/*
renvoie le texte de base d'une convention collective en HTML
ex: KALICONT000005635807: Convention collective nationale des salariés du particulier employeur du 24 novembre 1999.
*/

dila
.getConteneur({ id: "KALICONT000005635807", date: "2019-01-01" })
.then(({ data }) => dila.getTexte({ id: data.texte_de_base, date: "2019-01-01" }))
.then(html)
.then(console.log)
.catch(console.log)
.then(dila.close);

14 changes: 14 additions & 0 deletions packages/dila.js/examples/kali/liste-conventions-collectives.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const dila = require("../dila");
const { JSONlog } = require("../../src/utils");

/*
liste les conventions actives en JSON
actives = selon le fichier publié sur le site de la DGT à une url type https://travail-emploi.gouv.fr/IMG/xls/idccjuin19.xls
*/

dila
.getConteneursList({ nature: "IDCC", active: true })
.then(JSONlog)
.catch(console.log)
.then(dila.close);

0 comments on commit 28f5f62

Please sign in to comment.