Projet

Général

Profil

0001-api_entreprise-fix-parameteres-names-labels-and-exam.patch

Serghei Mihai (congés, retour 15/05), 17 avril 2019 13:58

Télécharger (11,3 ko)

Voir les différences:

Subject: [PATCH] api_entreprise: fix parameteres names, labels and examples
 (#32411)

 passerelle/apps/api_entreprise/models.py | 116 +++++++++++------------
 1 file changed, 58 insertions(+), 58 deletions(-)
passerelle/apps/api_entreprise/models.py
119 119

  
120 120

  
121 121
    @endpoint(perm='can_access',
122
              pattern='(?P<institution_id>\w+)/$',
123
              example_pattern='{institution_id}/',
122
              pattern='(?P<association_id>\w+)/$',
123
              example_pattern='{association_id}/',
124 124
              description=_('Get association\'s documents'),
125 125
              parameters={
126
                  'institution_id': {
127
                      'description': _('association id'),
126
                  'association_id': {
127
                      'description': _('association\'s SIREN or WALDEC number'),
128 128
                      'example_value': '44317013900036',
129 129
                  },
130 130
                  'object': {
131 131
                      'Description': _('request object'),
132
                      'example_value': 'MSP'
132
                      'example_value': '42'
133 133
                  },
134 134
                  'context': {
135
                      'description': _('request context'),
135
                      'description': _('request context (MPS, APS, ... )'),
136 136
                      'example_value': '42'
137 137
                  },
138 138
                  'recipient': {
......
141 141
                  }
142 142
              }
143 143
    )
144
    def documents_associations(self, request, institution_id, **kwargs):
144
    def documents_associations(self, request, association_id, **kwargs):
145 145
        data = []
146
        resp = self.get('documents_associations/%s/' % institution_id, **kwargs)
146
        resp = self.get('documents_associations/%s/' % association_id, **kwargs)
147 147
        for item in resp['data'].get('documents', []):
148 148
            # ignore documents with no type
149 149
            if not item.get('type'):
......
156 156
            document_url = request.build_absolute_uri(reverse('generic-endpoint', kwargs={'connector': self.get_connector_slug(),
157 157
                                        'slug': self.slug,
158 158
                                        'endpoint': 'document',
159
                                        'rest': '%s/%s/' % (institution_id, signature)}))
159
                                        'rest': '%s/%s/' % (association_id, signature)}))
160 160
            item['id'] = item['timestamp']
161 161
            item['text'] = item['type']
162 162
            item['url'] = document_url
......
166 166
        return {'err': 0, 'data': data}
167 167

  
168 168

  
169
    @endpoint(pattern='(?P<institution_id>\w+)/(?P<document_id>[\:\w-]+)/$',
170
              example_pattern='{institution_id}/{document_id}/',
171
              description=_('Get institution\'s document'),
169
    @endpoint(pattern='(?P<association_id>\w+)/(?P<document_id>[\:\w-]+)/$',
170
              example_pattern='{association_id}/{document_id}/',
171
              description=_('Get association\'s document'),
172 172
              parameters={
173
                  'institution_id': {
174
                      'description': _('institution id'),
173
                  'association_id': {
174
                      'description': _('association\'s SIREN or WALDEC number'),
175 175
                      'example_value': '44317013900036',
176 176
                  },
177 177
                  'document_id': {
......
180 180
                  },
181 181
                  'object': {
182 182
                      'Description': _('request object'),
183
                      'example_value': 'MSP'
183
                      'example_value': '42'
184 184
                  },
185 185
                  'context': {
186
                      'description': _('request context'),
187
                      'example_value': '42'
186
                      'description': _('request context (MPS, APS, ... )'),
187
                      'example_value': 'MPS'
188 188
                  },
189 189
                  'recipient': {
190 190
                      'description': _('request recipient: usually customer number'),
......
192 192
                  }
193 193
              }
194 194
    )
195
    def document(self, request, institution_id, document_id, **kwargs):
195
    def document(self, request, association_id, document_id, **kwargs):
196 196
        try:
197 197
            params = signing.loads(document_id, max_age=DOCUMENT_SIGNATURE_MAX_AGE)
198 198
        except signing.BadSignature:
......
204 204

  
205 205

  
206 206
    @endpoint(perm='can_access',
207
              pattern='(?P<institution_id>\w+)/$',
208
              example_pattern='{institution_id}/',
209
              description=_('Get institution\'s data from Infogreffe'),
207
              pattern='(?P<siren>\w+)/$',
208
              example_pattern='{siren}/',
209
              description=_('Get firm\'s data from Infogreffe'),
210 210
              parameters={
211
                  'institution_id': {
212
                      'description': _('institution id'),
211
                  'siren': {
212
                      'description': _('firm\'s SIREN number'),
213 213
                      'example_value': '44317013900036',
214 214
                  },
215 215
                  'object': {
216 216
                      'Description': _('request object'),
217
                      'example_value': 'MSP'
217
                      'example_value': '42'
218 218
                  },
219 219
                  'context': {
220
                      'description': _('request context'),
221
                      'example_value': '42'
220
                      'description': _('request context (MPS, APS, ... )'),
221
                      'example_value': 'MPS'
222 222
                  },
223 223
                  'recipient': {
224 224
                      'description': _('request recipient: usually customer number'),
......
226 226
                  }
227 227
              }
228 228
    )
229
    def extraits_rcs(self, request, institution_id, **kwargs):
230
        return self.get('extraits_rcs_infogreffe/%s/' % institution_id, **kwargs)
229
    def extraits_rcs(self, request, siren, **kwargs):
230
        return self.get('extraits_rcs_infogreffe/%s/' % siren, **kwargs)
231 231

  
232 232

  
233 233
    @endpoint(perm='can_access',
234
              pattern='(?P<institution_id>\w+)/$',
235
              example_pattern='{institution_id}/',
236
              description=_('Get institution\'s related informations'),
234
              pattern='(?P<association_id>\w+)/$',
235
              example_pattern='{association_id}/',
236
              description=_('Get association\'s related informations'),
237 237
              parameters={
238
                  'institution_id': {
239
                      'description': _('institution id'),
238
                  'association_id': {
239
                      'description': _('association\'s SIRET or WALDEC number'),
240 240
                      'example_value': '44317013900036',
241 241
                  },
242 242
                  'object': {
243 243
                      'Description': _('request object'),
244
                      'example_value': 'MSP'
244
                      'example_value': '42'
245 245
                  },
246 246
                  'context': {
247
                      'description': _('request context'),
248
                      'example_value': '42'
247
                      'description': _('request context (MPS, APS, ... )'),
248
                      'example_value': 'MPS'
249 249
                  },
250 250
                  'recipient': {
251 251
                      'description': _('request recipient: usually customer number'),
......
253 253
                  }
254 254
              }
255 255
    )
256
    def associations(self, request, institution_id, **kwargs):
257
        return self.get('associations/%s/' % institution_id, **kwargs)
256
    def associations(self, request, association_id, **kwargs):
257
        return self.get('associations/%s/' % association_id, **kwargs)
258 258

  
259 259

  
260 260
    @endpoint(perm='can_access',
261
              pattern='(?P<institution_id>\w+)/$',
262
              example_pattern='{institution_id}/',
263
              description=_('Get institution\'s related informations'),
261
              pattern='(?P<siren>\w+)/$',
262
              example_pattern='{siren}/',
263
              description=_('Get firm\'s related informations'),
264 264
              parameters={
265
                  'institution_id': {
266
                      'description': _('association id'),
265
                  'siren': {
266
                      'description': _('firm\'s SIREN number'),
267 267
                      'example_value': '44317013900036',
268 268
                  },
269 269
                  'object': {
270 270
                      'description': _('request object'),
271
                      'example_value': 'MSP'
271
                      'example_value': '42'
272 272
                  },
273 273
                  'context': {
274
                      'description': _('request context'),
275
                      'example_value': '42'
274
                      'description': _('request context (MPS, APS, ... )'),
275
                      'example_value': 'MPS'
276 276
                  },
277 277
                  'recipient': {
278 278
                      'description': _('request recipient: usually customer number'),
......
280 280
                  }
281 281
              }
282 282
    )
283
    def entreprises(self, request, institution_id, **kwargs):
284
        return self.get('entreprises/%s/' % institution_id, **kwargs)
283
    def entreprises(self, request, siren, **kwargs):
284
        return self.get('entreprises/%s/' % siren, **kwargs)
285 285

  
286 286

  
287 287
    @endpoint(perm='can_access',
288 288
              methods=['get'],
289
              pattern='(?P<institution_id>\w+)/$',
290
              example_pattern='{institution_id}/', #&
291
              description_get=_('Get institution\'s related informations'),
289
              pattern='(?P<siret>\w+)/$',
290
              example_pattern='{siret}/',
291
              description_get=_('Get firms\'s related informations'),
292 292
              parameters={
293
                  'institution_id': {
294
                      'description': _('institution id'),
293
                  'siret': {
294
                      'description': _('firms\'s SIRET number'),
295 295
                      'example_value': '44317013900036',
296 296
                  },
297 297
                  'object': {
298 298
                      'description': _('request object'),
299
                      'example_value': 'MSP'
299
                      'example_value': '42'
300 300
                  },
301 301
                  'context': {
302
                      'description': _('request context'),
303
                      'example_value': '42'
302
                      'description': _('request context (MPS, APS, ... )'),
303
                      'example_value': 'MPS'
304 304
                  },
305 305
                  'recipient': {
306 306
                      'description': _('request recipient: usually customer number'),
......
308 308
                  }
309 309
              }
310 310
    )
311
    def etablissements(self, request, institution_id, **kwargs):
312
        return self.get('etablissements/%s/' % institution_id, **kwargs)
311
    def etablissements(self, request, siret, **kwargs):
312
        return self.get('etablissements/%s/' % siret, **kwargs)
313
-