diff --git a/modules/cmso/par/browser.py b/modules/cmso/par/browser.py index bf0ea2f4619bef8a0a48c5bb303ac759eb160082..9e6eba230f6419fee5306f4a0876306c49353fbc 100644 --- a/modules/cmso/par/browser.py +++ b/modules/cmso/par/browser.py @@ -37,7 +37,8 @@ from .pages import ( LogoutPage, AccountsPage, HistoryPage, LifeinsurancePage, MarketPage, - AdvisorPage, LoginPage, ProfilePage, RedirectInsurancePage, + AdvisorPage, LoginPage, ProfilePage, RedirectInsurancePage, SpacesPage, + ChangeSpacePage, ) from .transfer_pages import TransferInfoPage, RecipientsListPage, TransferPage, AllowedRecipientsPage @@ -96,6 +97,10 @@ class CmsoParBrowser(TwoFactorBrowser): r'https://.*/auth/errorauthn', LogoutPage ) + + spaces = URL(r'/domiapi/oauth/json/accesAbonnement', SpacesPage) + change_space = URL(r'/securityapi/changeSpace', ChangeSpacePage) + accounts = URL(r'/domiapi/oauth/json/accounts/synthese(?P.*)', AccountsPage) history = URL(r'/domiapi/oauth/json/accounts/(?P.*)', HistoryPage) loans = URL(r'/creditapi/rest/oauth/v1/synthese', AccountsPage) @@ -249,6 +254,15 @@ def iter_accounts(self): # to know if account can do transfer accounts_eligibilite_debit = self.page.get_eligibilite_debit() + self.spaces.go(json={'includePart': True}) + self.change_space.go(json={ + 'clientIdSource': self.arkea_client_id, + 'espaceDestination': 'PART', + 'fromMobile': False, + 'numContractDestination': self.page.get_part_space(), + }) + self.session.headers['Authorization'] = 'Bearer %s' % self.page.get_access_token() + # First get all checking accounts... self.accounts.go(json={'typeListeCompte': 'COMPTE_SOLDE_COMPTES_CHEQUES'}, type='comptes') self.page.check_response() diff --git a/modules/cmso/par/pages.py b/modules/cmso/par/pages.py index e15084b1a87387db908325f1697da8f3d995263c..33048638ff763614a558e4803fb53dc77d278fd4 100644 --- a/modules/cmso/par/pages.py +++ b/modules/cmso/par/pages.py @@ -58,6 +58,18 @@ class LogoutPage(RawPage): pass +class SpacesPage(LoggedPage, JsonPage): + def get_part_space(self): + for abo in Dict('listAbonnement')(self.doc): + if Dict('espaceProxy')(abo) == 'PART': + return Dict('numContratBAD')(abo) + + +class ChangeSpacePage(LoggedPage, JsonPage): + def get_access_token(self): + return Dict('accessToken')(self.doc) + + class AccountsPage(LoggedPage, JsonPage): TYPES = OrderedDict([ ('courant', Account.TYPE_CHECKING),