From 363e575e2a9bea6bb6d4e76ce5476abdbf99d55b Mon Sep 17 00:00:00 2001
From: Serghei Mihai <smihai@entrouvert.com>
Date: Wed, 17 Apr 2019 11:40:33 +0200
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(-)

diff --git a/passerelle/apps/api_entreprise/models.py b/passerelle/apps/api_entreprise/models.py
index da6aa4c0..0aa1246d 100644
--- a/passerelle/apps/api_entreprise/models.py
+++ b/passerelle/apps/api_entreprise/models.py
@@ -119,20 +119,20 @@ class APIEntreprise(BaseResource):
 
 
     @endpoint(perm='can_access',
-              pattern='(?P<institution_id>\w+)/$',
-              example_pattern='{institution_id}/',
+              pattern='(?P<association_id>\w+)/$',
+              example_pattern='{association_id}/',
               description=_('Get association\'s documents'),
               parameters={
-                  'institution_id': {
-                      'description': _('association id'),
+                  'association_id': {
+                      'description': _('association\'s SIREN or WALDEC number'),
                       'example_value': '44317013900036',
                   },
                   'object': {
                       'Description': _('request object'),
-                      'example_value': 'MSP'
+                      'example_value': '42'
                   },
                   'context': {
-                      'description': _('request context'),
+                      'description': _('request context (MPS, APS, ... )'),
                       'example_value': '42'
                   },
                   'recipient': {
@@ -141,9 +141,9 @@ class APIEntreprise(BaseResource):
                   }
               }
     )
-    def documents_associations(self, request, institution_id, **kwargs):
+    def documents_associations(self, request, association_id, **kwargs):
         data = []
-        resp = self.get('documents_associations/%s/' % institution_id, **kwargs)
+        resp = self.get('documents_associations/%s/' % association_id, **kwargs)
         for item in resp['data'].get('documents', []):
             # ignore documents with no type
             if not item.get('type'):
@@ -156,7 +156,7 @@ class APIEntreprise(BaseResource):
             document_url = request.build_absolute_uri(reverse('generic-endpoint', kwargs={'connector': self.get_connector_slug(),
                                         'slug': self.slug,
                                         'endpoint': 'document',
-                                        'rest': '%s/%s/' % (institution_id, signature)}))
+                                        'rest': '%s/%s/' % (association_id, signature)}))
             item['id'] = item['timestamp']
             item['text'] = item['type']
             item['url'] = document_url
@@ -166,12 +166,12 @@ class APIEntreprise(BaseResource):
         return {'err': 0, 'data': data}
 
 
-    @endpoint(pattern='(?P<institution_id>\w+)/(?P<document_id>[\:\w-]+)/$',
-              example_pattern='{institution_id}/{document_id}/',
-              description=_('Get institution\'s document'),
+    @endpoint(pattern='(?P<association_id>\w+)/(?P<document_id>[\:\w-]+)/$',
+              example_pattern='{association_id}/{document_id}/',
+              description=_('Get association\'s document'),
               parameters={
-                  'institution_id': {
-                      'description': _('institution id'),
+                  'association_id': {
+                      'description': _('association\'s SIREN or WALDEC number'),
                       'example_value': '44317013900036',
                   },
                   'document_id': {
@@ -180,11 +180,11 @@ class APIEntreprise(BaseResource):
                   },
                   'object': {
                       'Description': _('request object'),
-                      'example_value': 'MSP'
+                      'example_value': '42'
                   },
                   'context': {
-                      'description': _('request context'),
-                      'example_value': '42'
+                      'description': _('request context (MPS, APS, ... )'),
+                      'example_value': 'MPS'
                   },
                   'recipient': {
                       'description': _('request recipient: usually customer number'),
@@ -192,7 +192,7 @@ class APIEntreprise(BaseResource):
                   }
               }
     )
-    def document(self, request, institution_id, document_id, **kwargs):
+    def document(self, request, association_id, document_id, **kwargs):
         try:
             params = signing.loads(document_id, max_age=DOCUMENT_SIGNATURE_MAX_AGE)
         except signing.BadSignature:
@@ -204,21 +204,21 @@ class APIEntreprise(BaseResource):
 
 
     @endpoint(perm='can_access',
-              pattern='(?P<institution_id>\w+)/$',
-              example_pattern='{institution_id}/',
-              description=_('Get institution\'s data from Infogreffe'),
+              pattern='(?P<siren>\w+)/$',
+              example_pattern='{siren}/',
+              description=_('Get firm\'s data from Infogreffe'),
               parameters={
-                  'institution_id': {
-                      'description': _('institution id'),
+                  'siren': {
+                      'description': _('firm\'s SIREN number'),
                       'example_value': '44317013900036',
                   },
                   'object': {
                       'Description': _('request object'),
-                      'example_value': 'MSP'
+                      'example_value': '42'
                   },
                   'context': {
-                      'description': _('request context'),
-                      'example_value': '42'
+                      'description': _('request context (MPS, APS, ... )'),
+                      'example_value': 'MPS'
                   },
                   'recipient': {
                       'description': _('request recipient: usually customer number'),
@@ -226,26 +226,26 @@ class APIEntreprise(BaseResource):
                   }
               }
     )
-    def extraits_rcs(self, request, institution_id, **kwargs):
-        return self.get('extraits_rcs_infogreffe/%s/' % institution_id, **kwargs)
+    def extraits_rcs(self, request, siren, **kwargs):
+        return self.get('extraits_rcs_infogreffe/%s/' % siren, **kwargs)
 
 
     @endpoint(perm='can_access',
-              pattern='(?P<institution_id>\w+)/$',
-              example_pattern='{institution_id}/',
-              description=_('Get institution\'s related informations'),
+              pattern='(?P<association_id>\w+)/$',
+              example_pattern='{association_id}/',
+              description=_('Get association\'s related informations'),
               parameters={
-                  'institution_id': {
-                      'description': _('institution id'),
+                  'association_id': {
+                      'description': _('association\'s SIRET or WALDEC number'),
                       'example_value': '44317013900036',
                   },
                   'object': {
                       'Description': _('request object'),
-                      'example_value': 'MSP'
+                      'example_value': '42'
                   },
                   'context': {
-                      'description': _('request context'),
-                      'example_value': '42'
+                      'description': _('request context (MPS, APS, ... )'),
+                      'example_value': 'MPS'
                   },
                   'recipient': {
                       'description': _('request recipient: usually customer number'),
@@ -253,26 +253,26 @@ class APIEntreprise(BaseResource):
                   }
               }
     )
-    def associations(self, request, institution_id, **kwargs):
-        return self.get('associations/%s/' % institution_id, **kwargs)
+    def associations(self, request, association_id, **kwargs):
+        return self.get('associations/%s/' % association_id, **kwargs)
 
 
     @endpoint(perm='can_access',
-              pattern='(?P<institution_id>\w+)/$',
-              example_pattern='{institution_id}/',
-              description=_('Get institution\'s related informations'),
+              pattern='(?P<siren>\w+)/$',
+              example_pattern='{siren}/',
+              description=_('Get firm\'s related informations'),
               parameters={
-                  'institution_id': {
-                      'description': _('association id'),
+                  'siren': {
+                      'description': _('firm\'s SIREN number'),
                       'example_value': '44317013900036',
                   },
                   'object': {
                       'description': _('request object'),
-                      'example_value': 'MSP'
+                      'example_value': '42'
                   },
                   'context': {
-                      'description': _('request context'),
-                      'example_value': '42'
+                      'description': _('request context (MPS, APS, ... )'),
+                      'example_value': 'MPS'
                   },
                   'recipient': {
                       'description': _('request recipient: usually customer number'),
@@ -280,27 +280,27 @@ class APIEntreprise(BaseResource):
                   }
               }
     )
-    def entreprises(self, request, institution_id, **kwargs):
-        return self.get('entreprises/%s/' % institution_id, **kwargs)
+    def entreprises(self, request, siren, **kwargs):
+        return self.get('entreprises/%s/' % siren, **kwargs)
 
 
     @endpoint(perm='can_access',
               methods=['get'],
-              pattern='(?P<institution_id>\w+)/$',
-              example_pattern='{institution_id}/', #&
-              description_get=_('Get institution\'s related informations'),
+              pattern='(?P<siret>\w+)/$',
+              example_pattern='{siret}/',
+              description_get=_('Get firms\'s related informations'),
               parameters={
-                  'institution_id': {
-                      'description': _('institution id'),
+                  'siret': {
+                      'description': _('firms\'s SIRET number'),
                       'example_value': '44317013900036',
                   },
                   'object': {
                       'description': _('request object'),
-                      'example_value': 'MSP'
+                      'example_value': '42'
                   },
                   'context': {
-                      'description': _('request context'),
-                      'example_value': '42'
+                      'description': _('request context (MPS, APS, ... )'),
+                      'example_value': 'MPS'
                   },
                   'recipient': {
                       'description': _('request recipient: usually customer number'),
@@ -308,5 +308,5 @@ class APIEntreprise(BaseResource):
                   }
               }
     )
-    def etablissements(self, request, institution_id, **kwargs):
-        return self.get('etablissements/%s/' % institution_id, **kwargs)
+    def etablissements(self, request, siret, **kwargs):
+        return self.get('etablissements/%s/' % siret, **kwargs)
-- 
2.20.1

