Creditcoop/perso : upgrade to browser2
This commit is contained in:
parent
05a2a8cc9c
commit
40a8bc0ce1
3 changed files with 68 additions and 78 deletions
|
|
@ -17,68 +17,53 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import urllib
|
||||
from weboob.browser import LoginBrowser, URL, need_login
|
||||
from weboob.exceptions import BrowserIncorrectPassword
|
||||
|
||||
from weboob.deprecated.browser import Browser, BrowserIncorrectPassword
|
||||
|
||||
from .pages import LoginPage, LoggedPage, AccountsPage, TransactionsPage, TransactionsJSONPage, ComingTransactionsPage
|
||||
from .pages import LoginPage, CreditLoggedPage, AccountsPage, TransactionsPage, TransactionsJSONPage, ComingTransactionsPage
|
||||
|
||||
|
||||
__all__ = ['CreditCooperatif']
|
||||
|
||||
|
||||
class CreditCooperatif(Browser):
|
||||
PROTOCOL = 'https'
|
||||
ENCODING = 'iso-8859-15'
|
||||
DOMAIN = "www.credit-cooperatif.coop"
|
||||
PAGES = {'https://www.credit-cooperatif.coop/portail/particuliers/login.do': LoginPage,
|
||||
'https://www.credit-cooperatif.coop/portail/particuliers/authentification.do': LoggedPage,
|
||||
'https://www.credit-cooperatif.coop/portail/particuliers/mescomptes/synthese.do': AccountsPage,
|
||||
'https://www.credit-cooperatif.coop/portail/particuliers/mescomptes/relevedesoperations.do': TransactionsPage,
|
||||
'https://www.credit-cooperatif.coop/portail/particuliers/mescomptes/relevedesoperationsjson.do': (TransactionsJSONPage, 'json'),
|
||||
'https://www.credit-cooperatif.coop/portail/particuliers/mescomptes/synthese/operationsencourslien.do': ComingTransactionsPage,
|
||||
}
|
||||
class CreditCooperatif(LoginBrowser):
|
||||
BASEURL = "https://www.credit-cooperatif.coop"
|
||||
|
||||
def home(self):
|
||||
self.location("/portail/particuliers/mescomptes/synthese.do")
|
||||
loginpage = URL('/portail//particuliers/login.do', LoginPage)
|
||||
loggedpage = URL('/portail/particuliers/authentification.do', CreditLoggedPage)
|
||||
accountspage = URL('/portail/particuliers/mescomptes/synthese.do', AccountsPage)
|
||||
transactionpage = URL('/portail/particuliers/mescomptes/relevedesoperations.do', TransactionsPage)
|
||||
transactjsonpage = URL('/portail/particuliers/mescomptes/relevedesoperationsjson.do', TransactionsJSONPage)
|
||||
comingpage = URL('/portail/particuliers/mescomptes/synthese/operationsencourslien.do', ComingTransactionsPage)
|
||||
|
||||
def is_logged(self):
|
||||
return not self.is_on_page(LoginPage)
|
||||
|
||||
def login(self):
|
||||
def do_login(self):
|
||||
"""
|
||||
Attempt to log in.
|
||||
Note: this method does nothing if we are already logged in.
|
||||
"""
|
||||
|
||||
assert isinstance(self.username, basestring)
|
||||
assert isinstance(self.password, basestring)
|
||||
|
||||
if self.is_logged():
|
||||
return
|
||||
|
||||
if not self.is_on_page(LoginPage):
|
||||
self.home()
|
||||
|
||||
self.loginpage.stay_or_go()
|
||||
self.page.login(self.username, self.password)
|
||||
|
||||
if self.is_on_page(LoggedPage):
|
||||
if self.loggedpage.is_here():
|
||||
error = self.page.get_error()
|
||||
if error is not None:
|
||||
raise BrowserIncorrectPassword(error)
|
||||
if error is None:
|
||||
return
|
||||
|
||||
if not self.is_logged():
|
||||
raise BrowserIncorrectPassword()
|
||||
raise BrowserIncorrectPassword(error)
|
||||
|
||||
@need_login
|
||||
def get_accounts_list(self):
|
||||
if not self.is_on_page(AccountsPage):
|
||||
self.location('/portail/particuliers/mescomptes/synthese.do')
|
||||
self.accountspage.stay_or_go()
|
||||
|
||||
return self.page.get_list()
|
||||
|
||||
@need_login
|
||||
def get_history(self, account):
|
||||
data = {'accountExternalNumber': account.id}
|
||||
self.location('/portail/particuliers/mescomptes/relevedesoperations.do', urllib.urlencode(data))
|
||||
self.transactionpage.go(data=data)
|
||||
|
||||
data = {'iDisplayLength': 400,
|
||||
'iDisplayStart': 0,
|
||||
|
|
@ -87,15 +72,16 @@ class CreditCooperatif(Browser):
|
|||
'sColumns': '',
|
||||
'sEcho': 1,
|
||||
'sSortDir_0': 'asc',
|
||||
}
|
||||
self.location('/portail/particuliers/mescomptes/relevedesoperationsjson.do', urllib.urlencode(data))
|
||||
}
|
||||
self.transactjsonpage.go(data=data)
|
||||
|
||||
return self.page.get_transactions()
|
||||
|
||||
@need_login
|
||||
def get_coming(self, account):
|
||||
data = {'accountExternalNumber': account.id}
|
||||
self.location('/portail/particuliers/mescomptes/synthese/operationsencourslien.do', urllib.urlencode(data))
|
||||
self.comingpage.go(data=data)
|
||||
|
||||
assert self.is_on_page(ComingTransactionsPage)
|
||||
assert self.comingpage.is_here()
|
||||
|
||||
return self.page.get_transactions()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue