Skip to content

Commit

Permalink
Merge branch 'release/0.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
riton committed Sep 13, 2021
2 parents 0908844 + 1cb183a commit 61470bf
Show file tree
Hide file tree
Showing 783 changed files with 304,597 additions and 17 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.pdf
ensap-payroll-cli
ensap
/dist
46 changes: 46 additions & 0 deletions .goreleaser.yml
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
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
33 changes: 16 additions & 17 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

CeCILL-B FREE SOFTWARE LICENSE AGREEMENT


Expand All @@ -17,9 +16,9 @@ the two main principles guiding its drafting:
both authors and holders of the economic rights over software.

The authors of the CeCILL-B (for Ce[a] C[nrs] I[nria] L[ogiciel] L[ibre])
license are:
license are:

Commissariat l'Energie Atomique - CEA, a public scientific, technical
Commissariat à l'Energie Atomique - CEA, a public scientific, technical
and industrial research establishment, having its principal place of
business at 25 rue Leblanc, immeuble Le Ponant D, 75015 Paris, France.

Expand Down Expand Up @@ -185,13 +184,13 @@ The Licensee is authorized to use the Software, without any limitation
as to its fields of application, with it being hereinafter specified
that this comprises:

1. permanent or temporary reproduction of all or part of the Software
1. permanent or temporary reproduction of all or part of the Software
by any or all means and in any or all form.

2. loading, displaying, running, or storing the Software on any or
2. loading, displaying, running, or storing the Software on any or
all medium.

3. entitlement to observe, study or test its operation so as to
3. entitlement to observe, study or test its operation so as to
determine the ideas and principles behind any or all constituent
elements of said Software. This shall apply when the Licensee
carries out any or all loading, displaying, running, transmission
Expand Down Expand Up @@ -229,9 +228,9 @@ The Licensee is authorized to distribute true copies of the Software in
Source Code or Object Code form, provided that said distribution
complies with all the provisions of the Agreement and is accompanied by:

1. a copy of the Agreement,
1. a copy of the Agreement,

2. a notice relating to the limitation of both the Licensor's
2. a notice relating to the limitation of both the Licensor's
warranty and liability as set forth in Articles 8 and 9,

and that, in the event that only the Object Code of the Software is
Expand Down Expand Up @@ -262,20 +261,20 @@ may be distributed under a separate license agreement.
Any Licensee who may distribute a Modified Software hereby expressly
agrees to:

1. indicate in the related documentation that it is based on the
1. indicate in the related documentation that it is based on the
Software licensed hereunder, and reproduce the intellectual
property notice for the Software,

2. ensure that written indications of the Software intended use,
2. ensure that written indications of the Software intended use,
intellectual property notice and license hereunder are included in
easily accessible format from the Modified Software interface,

3. mention, on a freely accessible website describing the Modified
3. mention, on a freely accessible website describing the Modified
Software, at least throughout the distribution term thereof, that
it is based on the Software licensed hereunder, and reproduce the
Software intellectual property notice,

4. where it is distributed to a third party that may distribute a
4. where it is distributed to a third party that may distribute a
Modified Software without having to make its source code
available, make its best efforts to ensure that said third party
agrees to comply with the obligations set forth in this Article .
Expand Down Expand Up @@ -328,15 +327,15 @@ govern its distribution.

The Licensee expressly undertakes:

1. not to remove, or modify, in any manner, the intellectual property
1. not to remove, or modify, in any manner, the intellectual property
notices attached to the Software;

2. to reproduce said notices, in an identical manner, in the copies
2. to reproduce said notices, in an identical manner, in the copies
of the Software modified or not.

The Licensee undertakes not to directly or indirectly infringe the
intellectual property rights of the Holder and/or Contributors on the
Software and to take, where applicable, vis--vis its staff, any and all
Software and to take, where applicable, vis-à-vis its staff, any and all
measures required to ensure respect of said intellectual property rights
of the Holder and/or Contributors.

Expand Down Expand Up @@ -403,8 +402,8 @@ rights set forth in Article 5).

9.3 The Licensee acknowledges that the Software is supplied "as is" by
the Licensor without any other express or tacit warranty, other than
that provided for in Article 9.2 and, in particular, without any warranty
as to its commercial value, its secured, safe, innovative or relevant
that provided for in Article 9.2 and, in particular, without any warranty
as to its commercial value, its secured, safe, innovative or relevant
nature.

Specifically, the Licensor does not warrant that the Software is free
Expand Down
49 changes: 49 additions & 0 deletions README.md
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)

74 changes: 74 additions & 0 deletions README.payrolls.md
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
```
16 changes: 16 additions & 0 deletions _examples/ensap.yaml
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 }}
58 changes: 58 additions & 0 deletions api/ensap.go
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)
}
Loading

0 comments on commit 61470bf

Please sign in to comment.