Commit 2aed8a52 authored by Célande Adrien's avatar Célande Adrien Committed by Romain Bignon

[freemobile] handle profile

parent 31ea8bcf
......@@ -21,7 +21,7 @@ from weboob.browser import LoginBrowser, URL, need_login
from weboob.capabilities.messages import CantSendMessage
from weboob.exceptions import BrowserIncorrectPassword
from weboob.tools.compat import basestring
from .pages import HomePage, LoginPage, HistoryPage, DetailsPage, OptionsPage
from .pages import HomePage, LoginPage, HistoryPage, DetailsPage, OptionsPage, ProfilePage
__all__ = ['Freemobile']
......@@ -32,6 +32,7 @@ class Freemobile(LoginBrowser):
homepage = URL('index.php\?page=home', HomePage)
detailspage = URL('index.php\?page=suiviconso', DetailsPage)
optionspage = URL('index.php\?page=options&o=(?P<username>)', OptionsPage)
profile = URL('index.php\?page=coordonnees', ProfilePage)
loginpage = URL('index.php', LoginPage)
historypage = URL('ajax.php\?page=consotel_current_month', HistoryPage)
sendAPI = URL('https://smsapi.free-mobile.fr/sendmsg\?user=(?P<username>)&pass=(?P<apikey>)&msg=(?P<msg>)')
......@@ -95,3 +96,8 @@ class Freemobile(LoginBrowser):
username=username, apikey=api_key,
msg=message.content
)
@need_login
def get_profile(self):
self.profile.go()
return self.page.get_profile()
......@@ -18,6 +18,7 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.capabilities.bill import CapDocument, Subscription, Bill, SubscriptionNotFound, DocumentNotFound
from weboob.capabilities.profile import CapProfile
from weboob.capabilities.messages import CantSendMessage, CapMessages, CapMessagesPost
from weboob.capabilities.base import find_object
from weboob.tools.backend import Module, BackendConfig
......@@ -29,7 +30,7 @@ from .browser import Freemobile
__all__ = ['FreeMobileModule']
class FreeMobileModule(Module, CapDocument, CapMessages, CapMessagesPost):
class FreeMobileModule(Module, CapDocument, CapMessages, CapMessagesPost, CapProfile):
NAME = 'freemobile'
MAINTAINER = u'Florent Fourcot'
EMAIL = 'weboob@flo.fourcot.fr'
......@@ -85,3 +86,6 @@ class FreeMobileModule(Module, CapDocument, CapMessages, CapMessagesPost):
if not message.content.strip():
raise CantSendMessage(u'Message content is empty.')
return self.browser.post_message(message)
def get_profile(self):
return self.browser.get_profile()
......@@ -22,5 +22,6 @@ from .homepage import HomePage
from .history import HistoryPage, DetailsPage
from .login import LoginPage
from .options import OptionsPage
from .profile import ProfilePage
__all__ = ['LoginPage', 'HomePage', 'HistoryPage', 'DetailsPage', 'OptionsPage']
__all__ = ['LoginPage', 'HomePage', 'HistoryPage', 'DetailsPage', 'OptionsPage', 'ProfilePage']
# -*- coding: utf-8 -*-
# Copyright(C) 2012-2014 Florent Fourcot
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
from weboob.browser.pages import HTMLPage, LoggedPage
from weboob.capabilities.profile import Profile
from weboob.browser.filters.standard import CleanText, Regexp
class ProfilePage(LoggedPage, HTMLPage):
def get_profile(self):
p = Profile()
p.name = CleanText('//div[address]/div')(self.doc)
p.address = CleanText('//div/address')(self.doc)
p.email = CleanText('//div[contains(text(), "Mon email")]/span')(self.doc)
for phone in self.doc.xpath('//div[@id="containerRIO"]//option[not(@value="")]'):
if p.name == Regexp(CleanText('.'), r'(.*) - \d{10}')(phone):
p.phone = Regexp(CleanText('.'), r'(\d{10})')(phone)
break
return p
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