Commit 4fda0965 authored by Vincent A's avatar Vincent A

[bouygues] implement CapMessagesPost

parent 58bd6532
......@@ -30,6 +30,7 @@ from import urlparse, parse_qsl
from .pages import (
LoginPage, ForgottenPasswordPage, AppConfigPage, SubscriberPage, SubscriptionPage, SubscriptionDetail, DocumentPage,
DocumentDownloadPage, DocumentFilePage,
......@@ -57,6 +58,9 @@ class BouyguesBrowser(LoginBrowser):
documents_page = URL(r'/comptes-facturation/(?P<id_account>\d+)/factures(\?|$)', DocumentPage)
document_download_page = URL(r'/comptes-facturation/(?P<id_account>\d+)/factures/.*(\?|$)', DocumentDownloadPage)
send_sms = URL(r'', SendSMSPage)
confirm_sms = URL(r'')
def __init__(self, username, password, lastname, *args, **kwargs):
super(BouyguesBrowser, self).__init__(username, password, *args, **kwargs)
self.lastname = lastname
......@@ -130,3 +134,9 @@ class BouyguesBrowser(LoginBrowser):
def download_document(self, document):
if document.url:
return self.location(document.url, headers=self.headers).content
def post_message(self, receivers, content):
self.send_sms.go(), content) # no params: stateful?!
......@@ -19,10 +19,10 @@
from __future__ import unicode_literals
from import Module, BackendConfig
from weboob.capabilities.base import find_object
from weboob.capabilities.bill import CapDocument, Document, SubscriptionNotFound, Subscription, DocumentNotFound
from weboob.capabilities.messages import CapMessagesPost
from import Value, ValueBackendPassword
from .browser import BouyguesBrowser
......@@ -31,7 +31,7 @@ from .browser import BouyguesBrowser
__all__ = ['BouyguesModule']
class BouyguesModule(Module, CapDocument):
class BouyguesModule(Module, CapDocument, CapMessagesPost):
NAME = 'bouygues'
DESCRIPTION = 'Bouygues Télécom'
MAINTAINER = 'Florian Duguet'
......@@ -66,3 +66,10 @@ class BouyguesModule(Module, CapDocument):
if not isinstance(document, Document):
document = self.get_document(document)
return self.browser.download_document(document)
def post_message(self, message):
receivers = message.receivers
if not receivers:
assert message.thread
receivers = []
self.browser.post_message(receivers, message.content)
......@@ -144,3 +144,18 @@ class DocumentFilePage(LoggedPage, RawPage):
# since url of this file is almost the same than url of DocumentDownloadPage (which is a JsonPage)
# we have to define it to avoid mismatching
class SendSMSPage(LoggedPage, HTMLPage):
def post_message(self, receivers, content):
form = self.get_form(name='formSMS')
quota_text = CleanText('.//strong')(form.el)
quota = int('(\d+) SMS gratuit', quota_text)[1])'quota: %d messages left', quota)
if not quota:
raise Exception('quota exceeded')
form['fieldMsisdn'] = ';'.join(receivers)
form['fieldMessage'] = content
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