diff --git a/weboob/capabilities/bank.py b/weboob/capabilities/bank.py index 1742d374..2458871b 100644 --- a/weboob/capabilities/bank.py +++ b/weboob/capabilities/bank.py @@ -20,10 +20,11 @@ from datetime import datetime, date -from .base import IBaseCap, CapBaseObject +from .base import CapBaseObject +from .collection import ICapCollection, CollectionNotFound -__all__ = ['Account', 'AccountNotFound', 'TransferError', 'ICapBank', +__all__ = ['Account', 'AccountNotFound', 'TransferError', 'ICapBank', 'Operation'] @@ -36,10 +37,14 @@ class AccountNotFound(Exception): class TransferError(Exception): pass -class Account(CapBaseObject): +class Recipient(CapBaseObject): def __init__(self): CapBaseObject.__init__(self, 0) self.add_field('label', basestring) + +class Account(Recipient): + def __init__(self): + Recipient.__init__(self) self.add_field('balance', float) self.add_field('coming', float) self.link_id = None @@ -56,7 +61,7 @@ class Operation(CapBaseObject): self.add_field('amount', float) def __repr__(self): - return "" % (self.date, + return "" % (self.date, self.label, self.amount) class Transfer(CapBaseObject): @@ -67,7 +72,13 @@ class Transfer(CapBaseObject): self.add_field('origin', (int, long, basestring)) self.add_field('recipient', (int, long, basestring)) -class ICapBank(IBaseCap): +class ICapBank(ICapCollection): + def iter_resources(self, splited_path): + if len(splited_path) > 0: + raise CollectionNotFound() + + return self.iter_accounts() + def iter_accounts(self): raise NotImplementedError() @@ -80,12 +91,21 @@ class ICapBank(IBaseCap): def iter_history(self, account): raise NotImplementedError() - def transfer(self, account, to, amount, reason=None): + def iter_transfer_recipients(self, account): + """ + Iter recipients availables for a transfer from a specific account. + + @param account [Account] account which initiate the transfer + @return [iter(Recipient)] + """ + raise NotImplementedError() + + def transfer(self, account, recipient, amount, reason=None): """ Make a transfer from an account to a recipient. @param account [Account] account to take money - @param to [Account] account to send money + @param recipient [Recipient] account to send money @param amount [float] amount @param reason [str] reason of transfer @return [Transfer] a Transfer object