Commit afbf9adf authored by Pierre Nardozi's avatar Pierre Nardozi Committed by Vincent A

[orange] add new profile page for pro

parent 02cf0045
......@@ -29,7 +29,7 @@ from .pages.bills import (
SubscriptionsPage, SubscriptionsApiPage, BillsApiProPage, BillsApiParPage,
ContractsPage, ContractsApiPage
)
from .pages.profile import ProfilePage
from .pages.profile import ProfileParPage, ProfileProPage
from weboob.browser.exceptions import ClientError, ServerError
from weboob.tools.compat import basestring
from weboob.tools.decorators import retry
......@@ -41,9 +41,11 @@ __all__ = ['OrangeBillBrowser']
class OrangeBillBrowser(LoginBrowser, StatesMixin):
TIMEOUT = 60
STATE_DURATION = 20
BASEURL = 'https://espaceclientv3.orange.fr'
home_page = URL(r'https://businesslounge.orange.fr/$', HomePage)
home_page = URL(r'https://businesslounge.orange.fr/?$', HomePage)
portal_page = URL(r'https://www.orange.fr/portail', PortalPage)
loginpage = URL(
r'https://login.orange.fr/\?service=sosh&return_url=https://www.sosh.fr/',
......@@ -83,7 +85,8 @@ class OrangeBillBrowser(LoginBrowser, StatesMixin):
doc_api_par = URL(r'https://sso-f.orange.fr/omoi_erb/facture/v1.0/pdf')
doc_api_pro = URL(r'https://espaceclientpro.orange.fr/api/contract/(?P<subid>\d+)/bill/(?P<dir>.*)/(?P<fact_type>.*)/\?(?P<billparams>)')
profile = URL(r'/\?page=profil-infosPerso', ProfilePage)
profile_par = URL(r'/\?page=profil-infosPerso', ProfileParPage)
profile_pro = URL(r'https://businesslounge.orange.fr/profil', ProfileProPage)
def locate_browser(self, state):
try:
......@@ -136,12 +139,12 @@ class OrangeBillBrowser(LoginBrowser, StatesMixin):
@need_login
def get_subscription_list(self):
try:
self.profile.go()
if not (self.profile.is_here() or self.manage_cgi.is_here()):
self.session.cookies.clear()
self.do_login()
self.profile.go()
# look at the type of account, pro or par and associates the right profile page
self.portal_page.go()
if self.home_page.is_here():
self.profile_pro.go()
else:
self.profile_par.go()
# we land on manage_cgi page when there is cgu to validate
if self.manage_cgi.is_here():
......@@ -236,4 +239,7 @@ class OrangeBillBrowser(LoginBrowser, StatesMixin):
@need_login
def get_profile(self):
return self.profile.go().get_profile()
self.profile_par.go()
if not self.profile_par.is_here():
self.profile_pro.go()
return self.page.get_profile()
......@@ -24,7 +24,7 @@ from weboob.capabilities.profile import Profile
from weboob.browser.filters.standard import CleanText, Format
class ProfilePage(LoggedPage, HTMLPage):
class ProfileParPage(LoggedPage, HTMLPage):
def get_profile(self):
pr = Profile()
pr.email = CleanText('//span[contains(@class, "panelAccount-label") and strong[contains(text(), "Adresse email")]]/following::span[1]/strong')(self.doc)
......@@ -59,3 +59,19 @@ class ProfilePage(LoggedPage, HTMLPage):
pr.name = CleanText('//p[contains(@class, "panelAccount-label")]/span[strong[text()="Nom :"]]/following::span[1]')(self.doc)
return pr
class ProfileProPage(LoggedPage, HTMLPage):
def get_profile(self):
pr = Profile()
pr.email = CleanText('//input[@id="profile_email"]/@value')(self.doc)
pr.name = Format(
'%s %s',
CleanText('//input[@id="profile_lastName"]/@value'),
CleanText('//input[@id="profile_firstName"]/@value'),
)(self.doc)
pr.phone = CleanText('//div[contains(@class, "main-header-profile")][1]//div[@class="h2"]')(self.doc)
return pr
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment