From b9695cc44e84f0e77573de0322769ada5c51592f Mon Sep 17 00:00:00 2001 From: Philip Douglass Date: Wed, 24 Apr 2019 13:23:24 -0400 Subject: [PATCH 1/2] Accept parameters to accounts() to pass on to account_list_query() --- ofxclient/institution.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ofxclient/institution.py b/ofxclient/institution.py index 3a06588..35b816d 100644 --- a/ofxclient/institution.py +++ b/ofxclient/institution.py @@ -131,14 +131,14 @@ def authenticate(self, username=None, password=None): raise ValueError(status) - def accounts(self): + def accounts(self, *args, **kwargs): """Ask the bank for the known :py:class:`ofxclient.Account` list. :rtype: list of :py:class:`ofxclient.Account` objects """ from ofxclient.account import Account client = self.client() - query = client.account_list_query() + query = client.account_list_query(*args, **kwargs) resp = client.post(query) resp_handle = StringIO(resp) From 31315f7f82a75c36481df8bb7a8e1c8eaf5df346 Mon Sep 17 00:00:00 2001 From: Philip Douglass Date: Thu, 25 Apr 2019 09:01:23 -0400 Subject: [PATCH 2/2] Automatically try short date in case accounts() returns nothing Resolves issue with TD Bank --- ofxclient/institution.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ofxclient/institution.py b/ofxclient/institution.py index 35b816d..299d9b8 100644 --- a/ofxclient/institution.py +++ b/ofxclient/institution.py @@ -131,14 +131,14 @@ def authenticate(self, username=None, password=None): raise ValueError(status) - def accounts(self, *args, **kwargs): + def accounts(self, date='19700101000000'): """Ask the bank for the known :py:class:`ofxclient.Account` list. :rtype: list of :py:class:`ofxclient.Account` objects """ from ofxclient.account import Account client = self.client() - query = client.account_list_query(*args, **kwargs) + query = client.account_list_query(date) resp = client.post(query) resp_handle = StringIO(resp) @@ -147,6 +147,10 @@ def accounts(self, *args, **kwargs): else: parsed = OfxParser.parse(BytesIO(resp_handle.read().encode())) + if not parsed.accounts and len(date) > 8: + # TD Bank doesn't support full date/time string here + return self.accounts(date=date[:8]) + return [Account.from_ofxparse(a, institution=self) for a in parsed.accounts]