Projet

Général

Profil

0001-add-civil-status-connector-interface-16768.patch

Josué Kouka, 26 mars 2018 14:46

Télécharger (13,6 ko)

Voir les différences:

Subject: [PATCH] add civil status connector interface (#16768)

 passerelle/civilstatus/__init__.py |  65 ++++++++++++
 passerelle/civilstatus/readme.md   | 197 +++++++++++++++++++++++++++++++++++++
 2 files changed, 262 insertions(+)
 create mode 100644 passerelle/civilstatus/__init__.py
 create mode 100644 passerelle/civilstatus/readme.md
passerelle/civilstatus/__init__.py
1
# -*- coding: utf-8 -*-
2
# Passerelle - uniform access to data and services
3
# Copyright (C) 2018  Entr'ouvert
4
#
5
# This program is free software: you can redistribute it and/or modify it
6
# under the terms of the GNU Affero General Public License as published
7
# by the Free Software Foundation, either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
# GNU Affero General Public License for more details.
14
#
15
# You should have received a copy of the GNU Affero General Public License
16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
import json
18

  
19
from django.utils.translation import ugettext_lazy as _
20

  
21
from passerelle.utils.api import endpoint
22
from passerelle.utils.jsonresponse import APIError
23

  
24
MANDATORY_DATA = {
25
    'applicant_firstnames': None,
26
    'applicant_lastname': None,
27
    'application_id': None,
28
    'application_time': None,
29
    'certificate_type': ('birth', 'mariage', 'death', 'other'),
30
    'concerned_firstnames': None,
31
    'concerned_lastname': None,
32
    'document_type': ('full', 'multilingual', 'with-filiation', 'without-filiation'),
33
}
34

  
35

  
36
class EndpointNotAvailable(APIError):
37
    http_status = 400
38

  
39

  
40
class CivilStatusMixin(object):
41

  
42
    category = _('Civil Status')
43

  
44
    def create_demand(self, formdata, *args, **kwargs):
45
        raise EndpointNotAvailable('<create> endpoint is not available')
46

  
47
    def get_status(self, demand_id, **kwargs):
48
        raise EndpointNotAvailable('<status> endpoint is not available')
49

  
50
    @endpoint(perm='can_access', methods=['post'])
51
    def create(self, request, *args, **kwargs):
52
        try:
53
            payload = json.loads(request.body)
54
        except (ValueError,) as exc:
55
            raise APIError('Payload error: %s' % exc)
56
        for key, values in MANDATORY_DATA.iteritems():
57
            if (key not in payload):
58
                raise APIError('<%s> is required.' % key)
59
            if values and payload[key] not in values:
60
                raise APIError('<%s> value must be one of %s' % (key, values))
61
        return self.create_demand(request, payload, *args, **kwargs)
62

  
63
    @endpoint(perm='can_access', methods=['get'], pattern='(?P<demand_id>[\w-]+)/')
64
    def status(self, request, demand_id, **kwargs):
65
        return self.get_status(demand_id)
passerelle/civilstatus/readme.md
1
[]()
2

  
3
Connecteur État Civil[¶](#Connecteur-État-Civil){.wiki-anchor}
4
==============================================================
5

  
6
-   [Connecteur État Civil](#Connecteur-État-Civil)
7
    -   [Les variables](#Les-variables)
8
        -   -   [Variables relatives au
9
                demandeur](#Variables-relatives-au-demandeur)
10
            -   [Variables relatives à
11
                l'intéressé](#Variables-relatives-à-lintéressé)
12
            -   [Variables relatives au partenaire de
13
                l'intéréssé](#Variables-relatives-au-partenaire-de-lintéréssé)
14
            -   [Variables relatives aux parents de l'intéréssé ou de
15
                son/sa
16
                partenaire](#Variables-relatives-aux-parents-de-lintéréssé-ou-de-sonsa-partenaire)
17

  
18
    -   [Les URL](#Les-URL)
19
        -   [Création d'une demande](#Création-dune-demande)
20
        -   [Récupération du statut d'une
21
            demande](#Récupération-du-statut-dune-demande)
22
        -   [Sources de données](#Sources-de-données)
23

  
24
Cette page décrit l'interface commune qui doit être utilisée par tous
25
les connecteurs type État Civil dans Passerelle.
26

  
27
[]()
28

  
29
Les variables[¶](#Les-variables){.wiki-anchor}
30
----------------------------------------------
31

  
32
  Nom                            Type      Obligatoire   Valeurs possibles                                       Commentaires
33
  ------------------------------ --------- ------------- ------------------------------------------------------- ----------------------------------------------------------------------------------
34
  application\_id                string    **oui**                                                               (display\_id)
35
  application\_time              string    **oui**                                                               (receipt\_time)
36
  certificate\_type              string    **oui**       birth, marriage, death, other
37
  certificate\_type\_label       string    non                                                                   e.g Acte de Naissance
38
  document\_type                 string    **oui**       full, multilingual, with-filiation, without-filiation
39
  document\_type\_label          string    non                                                                   e.g Copie intégrale, plurilingue, extrait avec filiation, extrait sans filiation
40
  document\_copies               integer   non
41
  event\_city                    string    non
42
  event\_date\_start             date      non                                                                   format ISO
43
  event\_date\_end               date      non                                                                   format ISO
44
  application\_reason            string    non                                                                   motif de la demande
45
  application\_comment           string    non                                                                   commentaire sur la demande
46
  application\_city              string    non                                                                   nom de la ville à qui la demande est adressée
47
  application\_city\_inseecode   string    non                                                                   code INSEE de la ville à qui la demande est adressée
48
  application\_city\_zipcode     string    non                                                                   code postal de la ville à qui la demande est adressée
49
  applicant\_is\_concerned       boolean   non           true,false                                              définit si le demandeur est aussi le titulaire de l'acte
50
  application\_priority          string    non                                                                   définit la priorité de la demande
51

  
52
[]()
53

  
54
#### Variables relatives au demandeur[¶](#Variables-relatives-au-demandeur){.wiki-anchor}
55

  
56
  Nom                                  Type     Obligatoire   Valeurs possibles                                          Commentaires
57
  ------------------------------------ -------- ------------- ---------------------------------------------------------- ---------------------------------------------------------------------
58
  application\_title                   string   non           mr, ms, mx
59
  applicant\_lastname                  string   **oui**
60
  applicant\_firstnames                string   **oui**
61
  applicant\_usual\_name               string   non
62
  applicant\_email                     string   non
63
  applicant\_phone                     string   non
64
  applicant\_status                    string   **oui**       concerned, partner, parent, child, representative, other   personne concernée, conjoint(e), parent, enfant, représentant légal
65
  applicant\_status\_label             string   non
66
  applicant\_address\_street\_number   string   non                                                                      numéro de la voie
67
  applicant\_address\_street\_type     string   non                                                                      type de la voie
68
  applicant\_address\_street           string   non
69
  applicant\_address\_complement       string   non
70
  applicant\_address\_city             string   non
71
  applicant\_address\_zipcode          string   non
72
  applicant\_address\_country          string   non                                                                      `Code ISO` ou `nom du pays` en fonction du connecteur
73

  
74
[]()
75

  
76
#### Variables relatives à l'intéressé[¶](#Variables-relatives-à-lintéressé){.wiki-anchor}
77

  
78
  Nom                       Type     Obligatoire   Valeurs possibles   Commentaires
79
  ------------------------- -------- ------------- ------------------- -------------------------------------------------------
80
  concerned\_title          string   non           mr, ms, mx
81
  concerned\_title\_label   string   non                               e.g monsieur, madame, neutre
82
  concerned\_firstnames     string   **oui**
83
  concerned\_lastname       string   **oui**
84
  concerned\_usual\_name    string   non
85
  concerned\_birthdate      date     non                               format ISO
86
  concerned\_birthcountry   string   non                               `Code ISO` ou `nom du pays` en fonction du connecteur
87
  concerned\_birthcity      string   non
88
  concerned\_birthcounty    string   non                               Département
89
  concerned\_sex            string   non           m, f, o             Homme, femme ou autre
90
  concerned\_citizenship    string   non
91

  
92
[]()
93

  
94
#### Variables relatives au partenaire de l'intéréssé[¶](#Variables-relatives-au-partenaire-de-lintéréssé){.wiki-anchor}
95

  
96
  Nom                     Type     Obligatoire   Valeurs possibles   Commentaires
97
  ----------------------- -------- ------------- ------------------- ------------------------------
98
  partner\_title          string   non           mr, ms, mx
99
  partner\_title\_label   string   non                               e.g monsieur, madame, neutre
100
  partner\_firstnames     string   non
101
  partner\_lastname       string   non
102
  partner\_usual\_name    string   non
103
  partner\_birthdate      date     non                               format ISO
104
  partner\_birthcountry   string   non
105
  partner\_birthcity      string   non
106
  partner\_birthcounty    string   non                               Département
107
  partner\_sex            string   non           m, f, o             Homme, femme ou autre
108
  partner\_citizenship    string   non
109

  
110
[]()
111

  
112
#### Variables relatives aux parents de l'intéréssé ou de son/sa partenaire[¶](#Variables-relatives-aux-parents-de-lintéréssé-ou-de-sonsa-partenaire){.wiki-anchor}
113

  
114
  Nom                                                  Type     Obligatoire   Valeurs possibles   Commentaires
115
  ---------------------------------------------------- -------- ------------- ------------------- --------------------------
116
  {concerned,partner}\_{parent1,parent2}\_title        string   non           mr, ms, mx          monsieur, madame, neutre
117
  {concerned,partner}\_{parent1,parent2}\_firstnames   string   non
118
  {concerned,partner}\_{parent1,parent2}\_lastname     string   non
119
  {concerned,partner}\_{parent1,parent2}\_sex          string   non           m, f, o             Homme, femme ou autre
120

  
121
[]()
122

  
123
Les URL[¶](#Les-URL){.wiki-anchor}
124
----------------------------------
125

  
126
[]()
127

  
128
### Création d'une demande[¶](#Création-dune-demande){.wiki-anchor}
129

  
130
-   `/<connector>/<slug>/create/`
131

  
132
Avec le payload json:\
133

  
134
    {
135
      "display_id": 123,
136
      "receipt_time": "2017-07-01T00:00:00",
137
      "certificate_type": "Acte de Mariage",
138
      "certificate_type_raw": "MAR",
139
      "document_type": "Extrait avec filiation",
140
      "document_type_raw": "EF",
141
      "document_copies": 3,
142
      "concerned_firstnames": "Johnny Jumper",
143
      "concerned_lastname": "Doe",
144
      "concerned_birthdate": "1980-07-07",
145
      "concerned_birthcity": "Nantes",
146
      "concerned_birthcountry": "France",
147
      "applicant_firstnames": "Kevin",
148
      "applicant_lastname": "Troll",
149
      "applicant_address_street": "27 Blvd Henry Orion",
150
      "applicant_address_city": "Nantes",
151
      "applicant_address_zipcode": 44000,
152
      "concerned_parent2_firstnames": "Kim",
153
      "concerned_parent2_lastname": "Sung-Ho",
154
      "partner_firstnames": "Chelsea Ruth",
155
      "partner_lastname": "Whatever",
156
      "event_date": "2014-05-07"
157
    }
158

  
159
</p>
160
Le retour attendu est un json contenant la clé `demand_id` i.e. :\
161

  
162
    {
163
     "err": 0,
164
     "data": {
165
         "demand_id": "123-MAR-0"
166
     }
167
    }
168

  
169
</p>
170
[]()
171

  
172
### Récupération du statut d'une demande[¶](#Récupération-du-statut-dune-demande){.wiki-anchor}
173

  
174
Dans le cas où le connecteur peut le permettre, l'URL de récupération du
175
statut d'une demande sera comme suit :
176

  
177
-   `/<connector>/<slug>/status/<demand_id>/`
178

  
179
La réponse renvoyée doit au minimum avoir les clés `status` et `closed`
180
(Boolean).
181

  
182
    {
183
      "err": 0,
184
      "data":{
185
       "status": "rejected",
186
       "closed": true,
187
       "comment": "Invalid demand"
188
      }
189
    }
190

  
191
[]()
192

  
193
### Sources de données[¶](#Sources-de-données){.wiki-anchor}
194

  
195
-   `/<connector>/<slug>/datasources/<data_source_name>/` e.g
196
    `/mdel/test/datasources/applicant-status/`
197

  
0
-