-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
783 changed files
with
304,597 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
ensap-payroll-cli | ||
ensap | ||
/dist |
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,46 @@ | ||
--- | ||
before: | ||
hooks: | ||
- go mod tidy | ||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- windows | ||
- darwin | ||
binary: 'ensap' | ||
archives: | ||
- replacements: | ||
darwin: Darwin | ||
linux: Linux | ||
windows: Windows | ||
386: i386 | ||
amd64: x86_64 | ||
checksum: | ||
name_template: 'checksums.txt' | ||
snapshot: | ||
name_template: "{{ incpatch .Version }}-next" | ||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- '^docs:' | ||
- '^test:' | ||
|
||
# Generate DEB and RPM using NFPM | ||
nfpms: | ||
- file_name_template: '{{ .ProjectName }}_{{ .Arch }}' | ||
homepage: https://github.com/riton/ensap-cli | ||
description: Ensap (https://ensap.gouv.fr) CLI - L'espace numérique sécurisé de l'agent public | ||
maintainer: Remi Ferrand <riton.github_at_gmail.com> | ||
license: CeCILL-B | ||
vendor: Remi Ferrand <riton.github_at_gmail.com> | ||
formats: | ||
- apk | ||
- deb | ||
- rpm | ||
bindir: '/usr/bin' | ||
contents: | ||
- src: ./_examples/ensap.yaml | ||
dst: /usr/share/{{ .ProjectName }}/ensap.sample.yaml |
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,6 @@ | ||
# CHANGELOG | ||
|
||
## 2021-09-13 - Remi Ferrand - v0.1.0 | ||
|
||
* _Release_ initiale du projet | ||
* La partie _retraite_ n'a pas encore été traitée |
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,49 @@ | ||
# ENSAP CLI | ||
|
||
**Attention**: Cet outil est encore en développement. L'outil `ensap` n'étant accessible que depuis très peu de temps, les commandes présentées ci-dessous peuvent évoluer. | ||
|
||
## Description | ||
|
||
Outil permettat d'intéragir avec l'API de l'**E**space **N**umérique **S**écurisé de l'**A**gent **P**ublique français (`ensap`). | ||
|
||
Cet outil permet pour le moment de: | ||
* lister les différentes fiches de paie présentes dans son espace `ensap`. | ||
* télécharger une fiche de paie identifiée par son _document ID_. | ||
|
||
## Installation | ||
|
||
### Paquets / binaires pré construits | ||
|
||
Vous pourrez trouver des paquets Windows, Linux et MacOS sur [la page de release](https://github.com/riton/ensap-cli/releases) de ce projet. | ||
|
||
### Construire à partir des sources | ||
|
||
Pour cela vous aurez besoin d'avoir le compilateur `go` installé (voir [site officiel](https://golang.org/dl/)). | ||
|
||
``` | ||
$ CGO_ENABLED=0 go build -ldflags "-s -w -extldflags '-static'" -o ensap . | ||
``` | ||
|
||
## Configuration | ||
|
||
La commande `ensap` utilise un fichier de configuration pour faciliter l'utilisation du _CLI_. | ||
|
||
Le fichier de configuration à utiliser peut-être spécifié via l'option `--config`. | ||
L'emplacement par défaut du fichier de configuration à créer est `~/.ensap.yaml`. | ||
|
||
### Exemple de configuration | ||
|
||
``` | ||
$ cat > ~/.ensap.yaml <<EOF | ||
--- | ||
api: | ||
endpoint: 'ensap.gouv.fr' | ||
username: 'METTRE_ICI_VOTRE_IDENTIFIANT' # mettre ici l'identifiant vous servant à vous connecter au site ensap.gouv.fr | ||
password: 'METTRE_ICI_VOTRE_MOT_DE_PASSE' # mettre ici le mot de passe vous servant à vous connecter au site ensap.gouv.fr | ||
EOF | ||
``` | ||
|
||
## Utilisation | ||
|
||
* [Opérations sur les fiches de paie](README.payrolls.md) | ||
|
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,74 @@ | ||
# Opérations sur les fiches de paie | ||
|
||
## Lister les fichers de paie présentes dans mon espace `ensap` | ||
|
||
``` | ||
$ ensap list-remuneration-paie | ||
Remuneration paie documents: | ||
* 2021_07_BP_juillet.pdf: | ||
- Document UUID: adc2cf49-6c5f-4765-1e74-7bacc1f2be68 | ||
- Document date: 01 Jul 21 00:00 CEST | ||
- Labels: | ||
- Juillet 2021 | ||
- 2021_07_BP_juillet.pdf (PDF, 490 Ko) | ||
- 42 BTC | ||
``` | ||
|
||
## Télécharger une fiche de paie en connaissant son identifiant (`UUID`) | ||
|
||
``` | ||
$ ensap download-remuneration-paie adc2cf49-6c5f-4765-1e74-7bacc1f2be68 | ||
``` | ||
|
||
La commande ci-dessus téléchargera le document identifié par l'`UUID` `adc2cf49-6c5f-4765-1e74-7bacc1f2be68` (obtenu via la commande `ensap list-remuneration-paie`) et | ||
enregistrera le document sous le nom `2021_07_BP_juillet.pdf`. | ||
|
||
Vous pouvez utiliser l'option `-o` ou `--out` pour spécifier un fichier de destination différent. | ||
|
||
## Utilisation avancée | ||
|
||
### Modifier le format d'affichage de la commande `list-remuneration-paie` | ||
|
||
La commande `list-remuneration-paie` affiche par défault ses données au format présenté dans la section [Lister les fichers de paie présentes dans mon espace `ensap`](#lister-les-fichers-de-paie-présentes-dans-mon-espace-ensap). | ||
|
||
Le _template_ par défaut utilisé pour formatter la sortie de cette commande est le suivant: | ||
|
||
```go | ||
Remuneration paie documents: | ||
{{- range $index, $document := . }} | ||
{{- with $document }} | ||
* {{ .NomDocument }}: | ||
- Document UUID: {{ .DocumentUUID }} | ||
- Document date: {{ .DateDocument }} | ||
- Labels: | ||
- {{ .Libelle1 }} | ||
- {{ .Libelle2 }} | ||
- {{ .Libelle3 }} | ||
{{- end }} | ||
{{- end }} | ||
``` | ||
|
||
L'utilisateur peut spécifier un _template_ alternatif à utiliser dans le fichier de configuration du CLI `ensap`. | ||
|
||
Exemple: | ||
|
||
```yaml | ||
rendering: | ||
templates: | ||
list-remuneration-paie-documents: | | ||
Only document UUIDs: | ||
{{- range $index, $document := . }} | ||
{{- with $document }} | ||
Document UUID = {{ .DocumentUUID }} | ||
{{- end }} | ||
{{- end }} | ||
``` | ||
est un template qui permet un affichage comme: | ||
``` | ||
$ ensap list-remuneration-paie | ||
Only document UUIDs: | ||
Document UUID = zfc9cc49-4c5f-1265-8d78-7bcaa2e2be68 | ||
Document UUID = 41a17871-ae47-4749-809f-2d1e2bcd1e26 | ||
``` |
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,16 @@ | ||
--- | ||
api: | ||
endpoint: 'ensap.gouv.fr' | ||
username: '<USERNAME>' # CHANGEME / TODO | ||
password: '<PASSWORD>' # CHANGEME / TODO | ||
|
||
# # Custom template for payroll documents listing | ||
# rendering: | ||
# templates: | ||
# list-remuneration-paie-documents: | | ||
# Only document UUIDs: | ||
# {{- range $index, $document := . }} | ||
# {{- with $document }} | ||
# Document UUID = {{ .DocumentUUID }} | ||
# {{- end }} | ||
# {{- end }} |
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,58 @@ | ||
package api | ||
|
||
/* | ||
Copyright © 2021 Remi Ferrand | ||
Contributor(s): Remi Ferrand <riton.github_at_gmail(dot)com>, 2021 | ||
This software is a computer program whose purpose is to interact with | ||
the ENSAP API (ensap.gouv.fr). | ||
This software is governed by the CeCILL-B license under French law and | ||
abiding by the rules of distribution of free software. You can use, | ||
modify and/ or redistribute the software under the terms of the CeCILL-B | ||
license as circulated by CEA, CNRS and INRIA at the following URL | ||
"http://www.cecill.info". | ||
As a counterpart to the access to the source code and rights to copy, | ||
modify and redistribute granted by the license, users are provided only | ||
with a limited warranty and the software's author, the holder of the | ||
economic rights, and the successive licensors have only limited | ||
liability. | ||
In this respect, the user's attention is drawn to the risks associated | ||
with loading, using, modifying and/or developing or reproducing the | ||
software by the user in light of its specific status of free software, | ||
that may mean that it is complicated to manipulate, and that also | ||
therefore means that it is reserved for developers and experienced | ||
professionals having in-depth computer knowledge. Users are therefore | ||
encouraged to load and test the software's suitability as regards their | ||
requirements in conditions enabling the security of their systems and/or | ||
data to be ensured and, more generally, to use and operate it in the | ||
same conditions as regards security. | ||
The fact that you are presently reading this means that you have had | ||
knowledge of the CeCILL-B license and that you accept its terms. | ||
*/ | ||
|
||
import "github.com/riton/ensap-cli/api/v1/objects" | ||
|
||
const ( | ||
RemunerationPaieEndpoint = "/prive/remunerationpaie" | ||
TelechargerRemunerationPaieEndpoint = "/prive/telechargerremunerationpaie" | ||
AuthentificationEndpoint = "/authentification" | ||
DeconnexionEndpoint = "/prive/deconnexion" | ||
) | ||
|
||
type EnsapAPIClient interface { | ||
Initialize() error | ||
Login() error | ||
Logout() error | ||
RemunerationPaieClient | ||
} | ||
|
||
type RemunerationPaieClient interface { | ||
ListRemunerationPaieDocumentsByYear(int /* year */) ([]objects.RemunerationPaieDocument, error) | ||
DownloadRemunerationPaie(string /* documentUuid */) (objects.DownloadRemunerationPaieDocument, error) | ||
} |
Oops, something went wrong.