Commit 11a21a04 authored by Guillaume Risbourg's avatar Guillaume Risbourg Committed by ntome

[banquepopulaire] Handle dematerialization status for subscriptions

If the status (available in the SubscriberPage with the key
`roleUtilisateurCoffreNumerique/code`) of dematerialization is CGDN
(Coffre Gratuit sans contrat de dématérialisation des documents)
that means we cannot gather subscriptions/documents online.

Closes: 46839@sibi
parent d01eda21
......@@ -581,8 +581,13 @@ class BanquePopulaire(LoginBrowser):
self.documents_headers = {'Authorization': 'Bearer %s' % response.json()['access_token']}
self.location('/api-bp/wapi/2.0/abonnes/current/mes-documents-electroniques', headers=self.documents_headers)
subscriber = self.page.get_subscriber()
if self.page.get_status_dematerialized() == 'CGDN':
# A status different than 1 means either the demateralization isn't enabled
# or not available for this connection
return []
subscriber = self.page.get_subscriber()
params = {'type': 'dematerialisationEffective'}
self.location('/api-bp/wapi/2.0/abonnes/current/contrats', params=params, headers=self.documents_headers)
return self.page.get_subscriptions(subscriber=subscriber)
......
......@@ -39,6 +39,8 @@ class SubscriberPage(LoggedPage, JsonPage):
def get_subscriber(self):
return self.doc['nomRaisonSociale']
def get_status_dematerialized(self):
return self.doc['roleUtilisateurCoffreNumerique']['code']
class SubscriptionsPage(LoggedPage, JsonPage):
@method
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment