module.py 2.13 KB
Newer Older
1 2 3 4
# -*- coding: utf-8 -*-

# Copyright(C) 2014 Budget Insight
#
5
# This file is part of a weboob module.
6
#
7
# This weboob module is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU Lesser General Public License as published by
9 10 11
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
12
# This weboob module is distributed in the hope that it will be useful,
13 14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU Lesser General Public License for more details.
16
#
17
# You should have received a copy of the GNU Lesser General Public License
18
# along with this weboob module. If not, see <http://www.gnu.org/licenses/>.
19 20


21
from weboob.capabilities.bank import CapBank, AccountNotFound
22
from weboob.capabilities.base import find_object
23
from weboob.tools.backend import Module, BackendConfig
24 25 26 27 28
from weboob.tools.value import ValueBackendPassword

from .browser import OneyBrowser


Florent Fourcot's avatar
Florent Fourcot committed
29
__all__ = ['OneyModule']
30 31


32
class OneyModule(Module, CapBank):
33
    NAME = 'oney'
ntome's avatar
ntome committed
34
    MAINTAINER = u'Vincent Paredes'
35
    EMAIL = 'vparedes@budget-insight.com'
Romain Bignon's avatar
Romain Bignon committed
36
    VERSION = '1.6'
37
    LICENSE = 'LGPLv3+'
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
    DESCRIPTION = 'Oney'
    CONFIG = BackendConfig(ValueBackendPassword('login',      label='Identifiant', masked=False),
                           ValueBackendPassword('password',   label='Mot de passe'))
    BROWSER = OneyBrowser

    def create_default_browser(self):
        return self.create_browser(self.config['login'].get(),
                                   self.config['password'].get())

    def iter_accounts(self):
        for account in self.browser.get_accounts_list():
            yield account

    def get_account(self, _id):
        return find_object(self.browser.get_accounts_list(), id=_id, error=AccountNotFound)

    def iter_history(self, account):
55 56 57 58 59
        # To prevent issues in calcul of actual balance and coming one, all
        # operations are marked as debited.
        for tr in self.browser.iter_coming(account):
            yield tr

60 61
        for tr in self.browser.iter_history(account):
            yield tr