From 1655bdd11ad23c8171425c640f3d35cf388b06f7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= <fpeters@entrouvert.com>
Date: Fri, 4 Dec 2020 12:19:22 +0100
Subject: [PATCH] lille urban card: log business errors as debug (#49129)

---
 passerelle/contrib/lille_urban_card/models.py | 28 +++++++++----------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/passerelle/contrib/lille_urban_card/models.py b/passerelle/contrib/lille_urban_card/models.py
index 90dc9319..f01a4120 100644
--- a/passerelle/contrib/lille_urban_card/models.py
+++ b/passerelle/contrib/lille_urban_card/models.py
@@ -139,10 +139,10 @@ class LilleUrbanCard(BaseResource):
                 auth=HttpBearerAuth(self.get_token()))
         response_json = response.json()
         if not isinstance(response_json, dict):
-            self.logger.error('error requesting card (unknown error)')
+            self.logger.error('error requesting card (unknown response format)')
             raise APIError('unknown error', data=response_json)
         if response_json.get('erreur'):
-            self.logger.error('error requesting card (%r)', response_json['erreur'])
+            self.logger.debug('error requesting card (%r)', response_json['erreur'])
             response_json['status_code'] = response.status_code
             raise APIError(response_json['erreur'], data=response_json)
         return {'data': response_json}  # {"n_demande_clu":10000005}
@@ -175,10 +175,10 @@ class LilleUrbanCard(BaseResource):
                 auth=HttpBearerAuth(self.get_token()))
         response_json = response.json()
         if not isinstance(response_json, dict):
-            self.logger.error('error adding subscriptions (unknown error)')
+            self.logger.error('error adding subscriptions (unknown response format)')
             raise APIError('unknown error', data=response_json)
         if response_json.get('erreur'):
-            self.logger.error('error adding subscriptions (%r)', response_json['erreur'])
+            self.logger.debug('error adding subscriptions (%r)', response_json['erreur'])
             response_json['status_code'] = response.status_code
             raise APIError(response_json['erreur'], data=response_json)
         return {'data': response_json}  # {"n_demande_clu":10000005}
@@ -192,10 +192,10 @@ class LilleUrbanCard(BaseResource):
                 auth=HttpBearerAuth(self.get_token()))
         response_json = response.json()
         if not isinstance(response_json, dict):
-            self.logger.error('error changing code (unknown error)')
+            self.logger.error('error changing code (unknown response format)')
             raise APIError('unknown error', data=response_json)
         if response_json.get('erreur'):
-            self.logger.error('error changing code (%r)', response_json['erreur'])
+            self.logger.debug('error changing code (%r)', response_json['erreur'])
             response_json['status_code'] = response.status_code
             raise APIError(response_json['erreur'], data=response_json)
         return {'data': response_json}
@@ -211,13 +211,13 @@ class LilleUrbanCard(BaseResource):
                 auth=HttpBearerAuth(self.get_token()))
         response_json = response.json()
         if not isinstance(response_json, dict):
-            self.logger.error('error checking code (unknown error)')
+            self.logger.error('error checking code (unknown response format)')
             raise APIError('unknown error', data=response_json)
         if response_json.get('message') == 'Le mot de passe est valide':
             return {'data': response_json}
         for error_attribute in ('erreur', 'message'):
             if response_json.get(error_attribute):
-                self.logger.error('error checking code (%r)', response_json[error_attribute])
+                self.logger.debug('error checking code (%r)', response_json[error_attribute])
                 response_json['status_code'] = response.status_code
                 raise APIError(response_json[error_attribute], data=response_json)
         raise APIError('invalid response', data=response_json)
@@ -231,11 +231,11 @@ class LilleUrbanCard(BaseResource):
                 auth=HttpBearerAuth(self.get_token()))
         response_json = response.json()
         if not isinstance(response_json, dict):
-            self.logger.error('error getting card info (unknown error)')
+            self.logger.error('error getting card info (unknown response format)')
             raise APIError('unknown error', data=response_json)
         for error_attribute in ('erreur', 'message'):
             if response_json.get(error_attribute):
-                self.logger.error('error getting card info (%r)', response_json[error_attribute])
+                self.logger.debug('error getting card info (%r)', response_json[error_attribute])
                 response_json['status_code'] = response.status_code
                 raise APIError(response_json[error_attribute], data=response_json)
         if not response_json.get('numero_serie'):
@@ -253,10 +253,10 @@ class LilleUrbanCard(BaseResource):
                 auth=HttpBearerAuth(self.get_token()))
         response_json = response.json()
         if not isinstance(response_json, dict):
-            self.logger.error('error revoking card (unknown error)')
+            self.logger.error('error revoking card (unknown response format)')
             raise APIError('unknown error', data=response_json)
         if response_json.get('erreur'):
-            self.logger.error('error revoking card (%r)', response_json['erreur'])
+            self.logger.debug('error revoking card (%r)', response_json['erreur'])
             response_json['status_code'] = response.status_code
             raise APIError(response_json['erreur'], data=response_json)
         return {'data': response_json}  # {"message": "La demande..."}
@@ -272,10 +272,10 @@ class LilleUrbanCard(BaseResource):
                 auth=HttpBearerAuth(self.get_token()))
         response_json = response.json()
         if not isinstance(response_json, dict):
-            self.logger.error('error revoking subscripton (unknown error)')
+            self.logger.error('error revoking subscripton (unknown response format)')
             raise APIError('unknown error', data=response_json)
         if response_json.get('erreur'):
-            self.logger.error('error revoking subscripton (%r)', response_json['erreur'])
+            self.logger.debug('error revoking subscripton (%r)', response_json['erreur'])
             response_json['status_code'] = response.status_code
             raise APIError(response_json['erreur'], data=response_json)
         return {'data': response_json}  # {"n_demande_clu":10000005}
-- 
2.29.2

