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 weboob.tools.compat 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('http://www.mobile.service.bbox.bouyguestelecom.fr/services/SMSIHD/resultSendSMS.phtml', UselessPage)
sms_error_page = URL('http://www.mobile.service.bbox.bouyguestelecom.fr/services/SMSIHD/SMS_erreur.phtml',
SendSMSErrorPage)
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)
return self.open(self.page.get_one_shot_download_url()).content
@need_login
def get_profile(self):
self.subscriber.go(idUser=self.id_user, headers=self.headers)
subscriber = self.page.get_subscriber()
self.profile.go(idUser=self.id_user, headers=self.headers)
return self.page.get_profile(subscriber=subscriber)
......@@ -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 weboob.tools.backend import Module, BackendConfig
from weboob.tools.value 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 = 'carton_ben@yahoo.fr'
......@@ -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()
p.name = subscriber
p.address = '%s %s %s %s' % (last_address['numero'], last_address['rue'],
last_address['codePostal'], last_address['ville'])
p.country = last_address['pays']
for email in data['emails']:
if email['emailPrincipal']:
p.email = email['email']
break
if 'telephones' in data:
for phone in data['telephones']:
if phone['telephonePrincipal']:
p.phone = phone['numero']
break
return p
class UselessPage(HTMLPage):
pass
......
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