Commit 51a41aec authored by cadrien's avatar cadrien Committed by Romain Bignon

[bouygues] handle profile

parent b676fb1d
......@@ -25,7 +25,7 @@ from weboob.browser.exceptions import ClientError
from import urlparse, parse_qs
from .pages import (
DocumentsPage, HomePage, LoginPage, SubscriberPage, SubscriptionPage, SubscriptionDetailPage,
SendSMSPage, SendSMSErrorPage, UselessPage, DocumentFilePage
SendSMSPage, SendSMSErrorPage, UselessPage, DocumentFilePage, ProfilePage,
from weboob.capabilities.messages import CantSendMessage
......@@ -51,6 +51,7 @@ class BouyguesBrowser(LoginBrowser):
confirm = URL('', UselessPage)
sms_error_page = URL('',
profile = URL('/personnes/(?P<idUser>\d+)/coordonnees', ProfilePage)
def __init__(self, username, password, lastname, *args, **kwargs):
super(BouyguesBrowser, self).__init__(username, password, *args, **kwargs)
......@@ -131,3 +132,12 @@ class BouyguesBrowser(LoginBrowser):
def download_document(self, document):
self.location(document.url, headers=self.headers)
def get_profile(self):
self.subscriber.go(idUser=self.id_user, headers=self.headers)
subscriber =
self.profile.go(idUser=self.id_user, headers=self.headers)
......@@ -22,6 +22,7 @@ from __future__ import unicode_literals
from weboob.capabilities.bill import CapDocument, Subscription, Document, SubscriptionNotFound, DocumentNotFound
from weboob.capabilities.messages import CantSendMessage, CapMessages, CapMessagesPost
from weboob.capabilities.base import find_object
from weboob.capabilities.profile import CapProfile
from import Module, BackendConfig
from import ValueBackendPassword, Value
......@@ -31,7 +32,7 @@ from .browser import BouyguesBrowser
__all__ = ['BouyguesModule']
class BouyguesModule(Module, CapMessages, CapMessagesPost, CapDocument):
class BouyguesModule(Module, CapMessages, CapMessagesPost, CapDocument, CapProfile):
NAME = 'bouygues'
MAINTAINER = u'Bezleputh'
EMAIL = ''
......@@ -71,3 +72,6 @@ class BouyguesModule(Module, CapMessages, CapMessagesPost, CapDocument):
if not isinstance(document, Document):
document = self.get_document(document)
return self.browser.download_document(document)
def get_profile(self):
return self.browser.get_profile()
......@@ -23,6 +23,7 @@ from weboob.capabilities.messages import CantSendMessage
from weboob.capabilities.base import NotLoaded
from weboob.capabilities.bill import Bill, Subscription
from weboob.capabilities.profile import Profile
from weboob.browser.pages import HTMLPage, JsonPage, LoggedPage, PDFPage
from weboob.browser.filters.json import Dict
from weboob.browser.filters.standard import CleanDecimal, CleanText, Env, Format, Regexp
......@@ -159,6 +160,35 @@ class DocumentsPage(LoggedPage, JsonPage):
return self.doc['_actions']['telecharger']['action']
class ProfilePage(LoggedPage, JsonPage):
def get_profile(self, subscriber):
data = self.doc
last_address = data['adressesPostales'][0]
for address in data['adressesPostales']:
if address['dateMiseAJour'] > last_address['dateMiseAJour']:
last_address = address
p = Profile() = subscriber
p.address = '%s %s %s %s' % (last_address['numero'], last_address['rue'],
last_address['codePostal'], last_address['ville']) = last_address['pays']
for email in data['emails']:
if email['emailPrincipal']: = email['email']
if 'telephones' in data:
for phone in data['telephones']:
if phone['telephonePrincipal']: = phone['numero']
return p
class UselessPage(HTMLPage):
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