Commit 332d59d8 authored by Florian Duguet's avatar Florian Duguet Committed by hydrargyrum
Browse files

[orange] update bill page for par website

Closes: 34908@sibi
parent dad4eb6d
......@@ -25,7 +25,7 @@
from weboob.exceptions import BrowserIncorrectPassword, BrowserUnavailable, ActionNeeded
from .pages import LoginPage, BillsPage
from .pages.login import ManageCGI, HomePage
from .pages.bills import SubscriptionsPage, BillsApiPage, ContractsPage
from .pages.bills import SubscriptionsPage, BillsApiProPage, BillsApiParPage, ContractsPage
from .pages.profile import ProfilePage
from weboob.browser.exceptions import ClientError, ServerError
from import basestring
......@@ -47,6 +47,7 @@ class OrangeBillBrowser(LoginBrowser):
subscriptions = URL(r'\?zonetype=bandeau&idPage=gt-home-page', SubscriptionsPage)
manage_cgi = URL('', ManageCGI)
# is billspage deprecated ?
billspage = URL('\?page=factures-archives',
......@@ -56,10 +57,13 @@ class OrangeBillBrowser(LoginBrowser):
bills_api = URL('<subid>\d+)/bills\?count=(?P<count>)',
bills_api_pro = URL('<subid>\d+)/bills\?count=(?P<count>)',
doc_api = URL('<subid>\d+)/bill/(?P<dir>.*)/(?P<fact_type>.*)/\?(?P<billparams>)')
bills_api_par = URL(r'<subid>\d+)', BillsApiParPage)
doc_api_par = URL(r'')
doc_api_pro = URL('<subid>\d+)/bill/(?P<dir>.*)/(?P<fact_type>.*)/\?(?P<billparams>)')
profile = URL('/\?page=profil-infosPerso', ProfilePage)
def do_login(self):
......@@ -132,12 +136,13 @@ def get_subscription_list(self):
def iter_documents(self, subscription):
documents = []
if subscription._is_pro:
for d in self.bills_api.go(, count=72).get_bills(
for d in self.bills_api_pro.go(, count=72).get_bills(
# check pagination for this subscription
assert len(documents) != 72
headers = {'x-orange-caller-id': 'ECQ'}
self.bills_api_par.go(, headers=headers)
for b in
return iter(documents)
......@@ -72,6 +72,10 @@ def download_document(self, document):
document = self.get_document(document)
if document.url is NotAvailable:
if document._is_v2:
# get 404 without this header
return, headers={'x-orange-caller-id': 'ECQ'}).content
def get_profile(self):
......@@ -28,7 +28,9 @@
from weboob.browser.pages import HTMLPage, LoggedPage, JsonPage
from weboob.capabilities.bill import Subscription
from weboob.browser.elements import DictElement, ListElement, ItemElement, method, TableElement
from weboob.browser.filters.standard import CleanDecimal, CleanText, Env, Field, Regexp, Date, Currency, BrowserURL, Format
from weboob.browser.filters.standard import (
CleanDecimal, CleanText, Env, Field, Regexp, Date, Currency, BrowserURL, Format, Eval
from weboob.browser.filters.html import Link, TableCell
from weboob.browser.filters.javascript import JSValue
from weboob.browser.filters.json import Dict
......@@ -38,7 +40,7 @@
from import urlencode
class BillsApiPage(LoggedPage, JsonPage):
class BillsApiProPage(LoggedPage, JsonPage):
class get_bills(DictElement):
item_xpath = 'bills'
......@@ -64,9 +66,33 @@ def get_params(self):
params = {'billid': Dict('id')(self), 'billDate': Dict('dueDate')(self)}
return urlencode(params)
obj_url = BrowserURL('doc_api', subid=Env('subid'), dir=Dict('documents/0/mainDir'), fact_type=Dict('documents/0/subDir'), billparams=get_params)
obj_url = BrowserURL('doc_api_pro', subid=Env('subid'), dir=Dict('documents/0/mainDir'), fact_type=Dict('documents/0/subDir'), billparams=get_params)
obj__is_v2 = False
class BillsApiParPage(LoggedPage, JsonPage):
class get_bills(DictElement):
item_xpath = 'billsHistory/billList'
class item(ItemElement):
klass = Bill
obj_date = Date(Dict('date'), default=NotAvailable)
obj_price = Eval(lambda x: x / 100, CleanDecimal(Dict('amount')))
obj_format = 'pdf'
def obj_label(self):
return 'Facture du %s' % Field('date')(self)
def obj_id(self):
return '%s_%s' % (Env('subid')(self), Field('date')(self).strftime('%d%m%Y'))
obj_url = Format('%s%s', BrowserURL('doc_api_par'), Dict('hrefPdf'))
obj__is_v2 = True
# is BillsPage deprecated ?
class BillsPage(LoggedPage, HTMLPage):
class get_bills(TableElement):
Supports Markdown
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