backend.py 2.36 KB
Newer Older
sputnick's avatar
sputnick committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
# -*- coding: utf-8 -*-

# Copyright(C) 2012 Gilles-Alexandre Quenot
#
# 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/>.


21
from weboob.capabilities.bank import CapBank, AccountNotFound
sputnick's avatar
sputnick committed
22 23 24 25 26 27 28 29 30
from weboob.tools.backend import BaseBackend, BackendConfig
from weboob.tools.value import ValueBackendPassword

from .browser import Fortuneo


__all__ = ['FortuneoBackend']


31
class FortuneoBackend(BaseBackend, CapBank):
sputnick's avatar
sputnick committed
32
    NAME = 'fortuneo'
33
    MAINTAINER = u'Gilles-Alexandre Quenot'
sputnick's avatar
sputnick committed
34
    EMAIL = 'gilles.quenot@gmail.com'
Florent Fourcot's avatar
Florent Fourcot committed
35
    VERSION = '1.0'
sputnick's avatar
sputnick committed
36
    LICENSE = 'AGPLv3+'
37
    DESCRIPTION = u'Fortuneo'
38 39 40
    CONFIG = BackendConfig(
                ValueBackendPassword(
                        'login',
41
                        label='Identifiant',
42 43 44 45 46
                        masked=False,
                        required=True
                ),
                ValueBackendPassword(
                        'password',
47
                        label='Mot de passe',
48 49 50
                        required=True
                )
    )
sputnick's avatar
sputnick committed
51 52 53
    BROWSER = Fortuneo

    def create_default_browser(self):
54 55 56 57
        return self.create_browser(
                self.config['login'].get(),
                self.config['password'].get()
        )
sputnick's avatar
sputnick committed
58 59

    def iter_accounts(self):
60 61
        """Iter accounts"""

sputnick's avatar
sputnick committed
62 63 64 65 66 67 68 69 70
        for account in self.browser.get_accounts_list():
            yield account

    def get_account(self, _id):
        with self.browser:
            account = self.browser.get_account(_id)
        if account:
            return account
        else:
71 72
            raise AccountNotFound()

sputnick's avatar
sputnick committed
73
    def iter_history(self, account):
74
        """Iter history of transactions on a specific account"""
sputnick's avatar
sputnick committed
75 76

        with self.browser:
77 78 79 80
            for history in self.browser.get_history(account):
                yield history

# vim:ts=4:sw=4