From 045dcfc8afa0e642f0f3d14bfd2fdfaa7b9ec176 Mon Sep 17 00:00:00 2001 From: Fong NGO Date: Fri, 8 Jan 2021 18:34:20 +0100 Subject: [PATCH] [bp] pro website: fetch savings accounts Related to rework of LBP pro website: 97968cde1b646cb05f97ae33489440c5979b9256. Login was fixed in a previous commit so I can now access more connections (and especially connections with savings accounts) more easily. --- modules/bp/pages/pro.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/modules/bp/pages/pro.py b/modules/bp/pages/pro.py index 5ff32d70d1..170a8a03a2 100644 --- a/modules/bp/pages/pro.py +++ b/modules/bp/pages/pro.py @@ -49,7 +49,7 @@ def is_logged(self): ACCOUNT_TYPES = { # TODO: add new type names and remove old ones 'Comptes titres': Account.TYPE_MARKET, # old - 'Comptes épargne': Account.TYPE_SAVINGS, # old + 'COMPTE_EPARGNE': Account.TYPE_SAVINGS, 'COMPTE_COURANT': Account.TYPE_CHECKING, } @@ -67,7 +67,31 @@ def is_logged(self): class ProAccountsList(LoggedPage, JsonPage): @method class iter_accounts(DictElement): - item_xpath = 'comptesBancaires/comptes' + def find_elements(self): + """ + Structure of json: + { + "comptesBancaires": { + "comptes": [{...}], + "...": ..., + }, + "comptesEpargnesEtPlacements": { + "comptes": [{...}], + "...": ..., + }, + "financements": { + "...": ..., + } + "groupesPersos": ..., + "indicateurCarte": ..., + "numeroCampagne": ... + } + """ + for data in self.el.values(): + if not isinstance(data, dict): + continue + for account in data.get('comptes', []): + yield account class item(ItemElement): klass = Account -- GitLab