Commit e5acc196 authored by Guillaume Risbourg's avatar Guillaume Risbourg Committed by Vincent A

[orange] Retrieve subscriptions from api if no subscriptions found

If no subscriptions were found from the 2 others _iter_subscriptions_by_type,
we try to retrieve the subscriptions from the api.

Closes: 12396@zendesk 13917@zendesk 14120@zendesk 14382@zendesk 14451@zendesk 14535@zendesk
parent a685c04d
......@@ -25,7 +25,10 @@ from weboob.browser import LoginBrowser, URL, need_login
from weboob.exceptions import BrowserIncorrectPassword, BrowserUnavailable, ActionNeeded, BrowserPasswordExpired
from .pages import LoginPage, BillsPage
from .pages.login import ManageCGI, HomePage, PasswordPage
from .pages.bills import SubscriptionsPage, BillsApiProPage, BillsApiParPage, ContractsPage
from .pages.bills import (
SubscriptionsPage, SubscriptionsApiPage, BillsApiProPage, BillsApiParPage,
from .pages.profile import ProfilePage
from weboob.browser.exceptions import ClientError, ServerError
from import basestring
......@@ -49,6 +52,8 @@ class OrangeBillBrowser(LoginBrowser):
contracts = URL(r'\?page=1&nbcontractsbypage=15', ContractsPage)
subscriptions = URL(r'\?zonetype=bandeau&idPage=gt-home-page', SubscriptionsPage)
subscriptions_api = URL(r'', SubscriptionsApiPage)
manage_cgi = URL(r'', ManageCGI)
# is billspage deprecated ?
......@@ -74,10 +79,6 @@ class OrangeBillBrowser(LoginBrowser):
doc_api_pro = URL('<subid>\d+)/bill/(?P<dir>.*)/(?P<fact_type>.*)/\?(?P<billparams>)')
profile = URL('/\?page=profil-infosPerso', ProfilePage)
def __init__(self, *args, **kwargs):
super(OrangeBillBrowser, self).__init__(*args, **kwargs)
self.is_new_website = False
def do_login(self):
assert isinstance(self.username, basestring)
assert isinstance(self.password, basestring)
......@@ -97,11 +98,6 @@ class OrangeBillBrowser(LoginBrowser):
if error_message:
raise BrowserPasswordExpired(error_message)
print('location done / is_here : %s' % self.new_website.is_here())
if self.new_website.is_here():
self.is_new_website = True
def get_nb_remaining_free_sms(self):
raise NotImplementedError()
......@@ -153,10 +149,22 @@ class OrangeBillBrowser(LoginBrowser):
# if nb_sub is 0, we continue, because we can get them in next url
for sub in self._iter_subscriptions_by_type(, 'sosh'):
nb_sub += 1
yield sub
for sub in self._iter_subscriptions_by_type(, 'orange'):
nb_sub += 1
yield sub
if nb_sub == 0:
# No subscriptions found, trying with the API.
headers = {
'X-Orange-Caller-Id': 'ECQ',
for sub in
sub.subscriber =
yield sub
def iter_documents(self, subscription):
documents = []
......@@ -190,6 +190,22 @@ class SubscriptionsPage(LoggedPage, HTMLPage):
return bool( and obj._page != 'nec-tdb-ouvert'
class SubscriptionsApiPage(LoggedPage, JsonPage):
class iter_subscription(DictElement):
item_xpath = 'contracts'
class item(ItemElement):
klass = Subscription
def condition(self):
return Dict('contractStatus')(self) != 'CLOS'
obj_id = Dict('contractId')
obj_label = Dict('offerName')
obj__is_pro = False
class ContractsPage(LoggedPage, JsonPage):
class iter_subscriptions(DictElement):
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