Skip to content
Extraits de code Groupes Projets
Valider 54d834ae rédigé par Benjamin - Le Filament's avatar Benjamin - Le Filament
Parcourir les fichiers

Merge branch '14.0-get-headers-from-request' into '14.0'

[ADD] add headers from response in return

See merge request !2
parents bb310a81 79a4cdf4
Branches 14.0
Aucune étiquette associée trouvée
1 requête de fusion!2[ADD] add headers from response in return
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"author": "Le Filament", "author": "Le Filament",
"website": "https://le-filament.com", "website": "https://le-filament.com",
"development_status": "Beta", "development_status": "Beta",
"version": "14.0.0.0.0", "version": "14.0.0.0.1",
"license": "AGPL-3", "license": "AGPL-3",
"depends": ["base"], "depends": ["base"],
"data": [ "data": [
......
...@@ -40,7 +40,7 @@ class ApiConnector(models.AbstractModel): ...@@ -40,7 +40,7 @@ class ApiConnector(models.AbstractModel):
# ------------------------------------------------------ # ------------------------------------------------------
# API functions # API functions
# ------------------------------------------------------ # ------------------------------------------------------
def call_api(self, url, call_type, **kwargs): def call_api(self, url, call_type, with_headers=False,**kwargs):
""" """
:param url: action API Alfresco :param url: action API Alfresco
:param call_type: post/get/put/delete :param call_type: post/get/put/delete
...@@ -66,16 +66,19 @@ class ApiConnector(models.AbstractModel): ...@@ -66,16 +66,19 @@ class ApiConnector(models.AbstractModel):
except Exception as e: except Exception as e:
raise e raise e
if with_headers:
return response.json(), response.headers
return response.json() return response.json()
def api_get(self, url, **kwargs): def api_get(self, url, with_headers=False,**kwargs):
return self.call_api(url, "get", **kwargs) return self.call_api(url, "get", with_headers=with_headers, **kwargs)
def api_post(self, url, **kwargs): def api_post(self, url, with_headers=False,**kwargs):
return self.call_api(url, "post", **kwargs) return self.call_api(url, "post", with_headers=with_headers, **kwargs)
def api_put(self, url, **kwargs): def api_put(self, url, with_headers=False,**kwargs):
return self.call_api(url, "put", **kwargs) return self.call_api(url, "put", with_headers=with_headers, **kwargs)
def api_delete(self, url, **kwargs): def api_delete(self, url, with_headers=False, **kwargs):
return self.call_api(url, "delete", **kwargs) return self.call_api(url, "delete", with_headers=with_headers, **kwargs)
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter