diff --git a/modules/cragr/api/__init__.py b/modules/cragr/api/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/modules/cragr/api/browser.py b/modules/cragr/browser.py similarity index 97% rename from modules/cragr/api/browser.py rename to modules/cragr/browser.py index b35286f86d27ec1d3bf8262f8e7d315818e21e7c..7b90fec8d78e987174e12ce8fabc47204eb2e37d 100644 --- a/modules/cragr/api/browser.py +++ b/modules/cragr/browser.py @@ -27,7 +27,6 @@ from weboob.capabilities.bank import Account, Loan, Per, PerProviderType, Transaction, AccountNotFound, RecipientNotFound from weboob.capabilities.base import empty, NotAvailable, strict_find_object from weboob.browser import LoginBrowser, URL, need_login -from weboob.browser.switch import SiteSwitch from weboob.browser.exceptions import ServerError, ClientError, BrowserHTTPNotFound, HTTPNotFound from weboob.exceptions import BrowserUnavailable, BrowserIncorrectPassword, ActionNeeded from weboob.tools.capabilities.bank.iban import is_iban_valid @@ -37,7 +36,7 @@ from .pages import ( LoginPage, LoggedOutPage, KeypadPage, SecurityPage, ContractsPage, FirstConnectionPage, AccountsPage, AccountDetailsPage, TokenPage, ChangePasswordPage, IbanPage, HistoryPage, CardsPage, CardHistoryPage, NetfincaRedirectionPage, PredicaRedirectionPage, - PredicaInvestmentsPage, ProfilePage, ProfileDetailsPage, ProProfileDetailsPage, LifeInsuranceInvestmentsPage, OldWebsitePage, + PredicaInvestmentsPage, ProfilePage, ProfileDetailsPage, ProProfileDetailsPage, LifeInsuranceInvestmentsPage, ) from .transfer_pages import ( RecipientsPage, TransferPage, TransferTokenPage, @@ -47,10 +46,10 @@ from .netfinca_browser import NetfincaBrowser -__all__ = ['CragrAPI'] +__all__ = ['CreditAgricoleBrowser'] -class CragrAPI(LoginBrowser): +class CreditAgricoleBrowser(LoginBrowser): login_page = URL(r'particulier/acceder-a-mes-comptes.html$', LoginPage) keypad = URL(r'particulier/acceder-a-mes-comptes.authenticationKeypad.json', KeypadPage) security_check = URL(r'particulier/acceder-a-mes-comptes.html/j_security_check', SecurityPage) @@ -119,10 +118,9 @@ class CragrAPI(LoginBrowser): '(?P.*)/operations/(?P.*)/virement/jcr:content.transfer-data.json\?useSession=true', TransferPage ) transfer_exec = URL('(?P.*)/operations/(?P.*)/virement/jcr:content.process-transfer.json', TransferPage) - old_website = URL(r'https://.*particuliers.html$', OldWebsitePage) def __init__(self, website, *args, **kwargs): - super(CragrAPI, self).__init__(*args, **kwargs) + super(CreditAgricoleBrowser, self).__init__(*args, **kwargs) self.website = website self.accounts_url = None @@ -138,7 +136,7 @@ def space(self): return self.session.cookies.get('marche', None) def deinit(self): - super(CragrAPI, self).deinit() + super(CreditAgricoleBrowser, self).deinit() self.netfinca.deinit() @retry(BrowserUnavailable) @@ -179,17 +177,13 @@ def do_login(self): if not self.username or not self.password: raise BrowserIncorrectPassword() - # First we try to connect to the new website: if the connection - # is on the old website, we will automatically redirected. - website = self.website.replace('.fr', '') - region_domain = re.sub(r'^www\.', 'www.credit-agricole.fr/', website) + # For historical reasons (old cragr website), the websites look like 'www.ca-region.fr', + # from which we extract 'ca-region' to construct the BASEURL with a format such as: + # 'https://www.credit-agricole.fr/ca-region/' + region_domain = re.sub(r'^www\.', 'www.credit-agricole.fr/', self.website.replace('.fr', '')) self.BASEURL = 'https://%s/' % region_domain - self.login_page.go() - if self.old_website.is_here(): - self.BASEURL = 'https://%s/' % self.website - self.logger.warning('This is a regional connection, switching to old website with URL %s', self.BASEURL) - raise SiteSwitch('region') + self.login_page.go() self.do_security_check() # accounts_url may contain '/particulier', '/professionnel', '/entreprise', '/agriculteur' or '/association' diff --git a/modules/cragr/api/netfinca_browser.py b/modules/cragr/netfinca_browser.py similarity index 100% rename from modules/cragr/api/netfinca_browser.py rename to modules/cragr/netfinca_browser.py diff --git a/modules/cragr/api/pages.py b/modules/cragr/pages.py similarity index 99% rename from modules/cragr/api/pages.py rename to modules/cragr/pages.py index 175c2564fbd501cc346f8ee8c805e56fff39435f..1aafb96977d664cd6ccfeeabce7ac5db159d5152 100644 --- a/modules/cragr/api/pages.py +++ b/modules/cragr/pages.py @@ -177,6 +177,8 @@ class ContractsPage(LoggedPage, HTMLPage): 'DATG': Account.TYPE_DEPOSIT, 'CB': Account.TYPE_SAVINGS, # Carré bleu / PEL 'LIS': Account.TYPE_SAVINGS, + 'BOOSTE4': Account.TYPE_SAVINGS, # Livret d'Epargne Forteo + 'PEPS': Account.TYPE_SAVINGS, # Plan d'Epargne Populaire 'PRET PERSO': Account.TYPE_LOAN, 'P. ENTREPR': Account.TYPE_LOAN, 'P. HABITAT': Account.TYPE_LOAN, @@ -731,7 +733,3 @@ class fill_advisor(ItemElement): class ProProfileDetailsPage(ProfileDetailsPage): pass - - -class OldWebsitePage(HTMLPage): - pass diff --git a/modules/cragr/api/transfer_pages.py b/modules/cragr/transfer_pages.py similarity index 100% rename from modules/cragr/api/transfer_pages.py rename to modules/cragr/transfer_pages.py