switch to new website and several fixes

This commit is contained in:
Romain Bignon 2015-06-29 10:53:21 +02:00
commit 55de13b53b
3 changed files with 22 additions and 33 deletions

View file

@ -50,7 +50,7 @@ class BNPorcModule(Module, CapBank, CapMessages):
Value('website', label='Type de compte', default='pp',
choices={'pp': 'Particuliers/Professionnels',
'ent': 'Entreprises',
'pp2': 'Particuliers/Professionnels (nouveau site)'}))
'ppold': 'Particuliers/Professionnels (ancien site)'}))
STORAGE = {'seen': []}
# Store the messages *list* for this duration
@ -62,25 +62,10 @@ class BNPorcModule(Module, CapBank, CapMessages):
self._threads_age = datetime.utcnow()
def create_default_browser(self):
b = {'pp': BNPorc, 'ent': BNPEnterprise, 'pp2': BNPParibasBrowser}
b = {'ppold': BNPorc, 'ent': BNPEnterprise, 'pp': BNPParibasBrowser}
self.BROWSER = b[self.config['website'].get()]
#if self.config['rotating_password'].get().isdigit() and len(self.config['rotating_password'].get()) == 6:
# rotating_password = self.config['rotating_password'].get()
#else:
rotating_password = None
if self.config['website'].get() != 'pp':
return self.create_browser(self.config['login'].get(),
self.config['password'].get())
else:
return self.create_browser(self.config['login'].get(),
self.config['password'].get(),
password_changed_cb=self._password_changed_cb,
rotating_password=rotating_password)
def _password_changed_cb(self, old, new):
self.config['password'].set(new)
self.config['rotating_password'].set(old)
self.config.save()
return self.create_browser(self.config['login'].get(),
self.config['password'].get())
def iter_accounts(self):
for account in self.browser.get_accounts_list():

View file

@ -25,7 +25,7 @@ from weboob.capabilities.base import find_object
from weboob.capabilities.bank import AccountNotFound
from weboob.tools.json import json
from .pages import LoginPage, AccountsPage, AccountsIBANPage, HistoryPage
from .pages import LoginPage, AccountsPage, AccountsIBANPage, HistoryPage, TransferInitPage
__all__ = ['BNPParibasBrowser']
@ -59,17 +59,18 @@ class JsonBrowserMixin(object):
class BNPParibasBrowser(CompatMixin, JsonBrowserMixin, LoginBrowser):
BASEURL_TEMPLATE = r'https://%s.bnpparibas.net/'
BASEURL_TEMPLATE = r'https://%s.bnpparibas/'
BASEURL = BASEURL_TEMPLATE % 'mabanque'
TIMEOUT = 30.0
login = URL(r'identification-wspl-pres/identification\?acceptRedirection=true&timestamp=(?P<timestamp>)',
login = URL(r'identification-wspl-pres/identification\?acceptRedirection=true&timestamp=(?P<timestamp>\d+)',
'SEEA-pa01/devServer/seeaserver',
'https://mabanqueprivee.bnpparibas.net/fr/espace-prive/comptes-et-contrats\?u=%2FSEEA-pa01%2FdevServer%2Fseeaserver',
LoginPage)
accounts = URL('udc-wspl/rest/getlstcpt', AccountsPage)
ibans = URL('rib-wspl/rpc/comptes', AccountsIBANPage)
history = URL('rop-wspl/rest/releveOp', HistoryPage)
transfer_init = URL('virement-wspl/rest/initialisationVirement', TransferInitPage)
def switch(self, subdomain):
self.BASEURL = self.BASEURL_TEMPLATE % subdomain
@ -83,10 +84,11 @@ class BNPParibasBrowser(CompatMixin, JsonBrowserMixin, LoginBrowser):
@need_login
def get_accounts_list(self):
ibans = self.ibans.go()
self.accounts.go()
assert self.accounts.is_here()
return self.page.iter_accounts(ibans.get_ibans_dict())
ibans = self.ibans.go().get_ibans_dict()
ibans.update(self.transfer_init.go(data=JSON({'restitutionVF': 1, 'type': 'TOUS'})).get_ibans_dict())
self.accounts.go().iter_accounts(ibans)
return self.page.iter_accounts(ibans)
@need_login
def get_account(self, _id):
@ -95,7 +97,7 @@ class BNPParibasBrowser(CompatMixin, JsonBrowserMixin, LoginBrowser):
@need_login
def iter_history(self, account, coming=False):
self.page = self.history.go(data=JSON({
"ibanCrypte": account.id,
"ibanCrypte": account._key,
"pastOrPending": 1,
"triAV": 0,
"startDate": None,

View file

@ -32,9 +32,6 @@ from weboob.tools.json import json
from weboob.tools.date import parse_french_date as Date
__all__ = ['LoginPage']
def cast(x, typ, default=None):
try:
return typ(x or default)
@ -139,19 +136,24 @@ class AccountsPage(BNPPage):
for f in self.path('data.infoUdc.familleCompte.*'):
for a in f.get('compte'):
yield Account.from_dict({
'id': a.get('key'),
'_key': a.get('key'),
'label': a.get('libellePersoProduit') or a.get('libelleProduit'),
'currency': a.get('devise'),
'type': self.FAMILY_TO_TYPE.get(f.get('idFamilleCompte')) or Account.TYPE_UNKNOWN,
'balance': a.get('soldeDispo'),
'coming': a.get('soldeAVenir'),
'iban': ibans.get(a.get('key')) or a.get('value')
'iban': ibans.get(a.get('key'))
})
class AccountsIBANPage(BNPPage):
def get_ibans_dict(self):
return dict((a.get('ibanCrypte'), a.get('iban')) for a in self.path('listeRib.*.infoCompte'))
return {a['ibanCrypte']: a['iban'] for a in self.path('data.listeRib.*.infoCompte')}
class TransferInitPage(BNPPage):
def get_ibans_dict(self):
return {a['ibanCrypte']: a['iban'] for a in self.path('data.infoVirement.listeComptesCrediteur.*')}
class Transaction(FrenchTransaction):