From 31f15e68fe69a86b04d19336805051172ec8f512 Mon Sep 17 00:00:00 2001 From: Visgean Skeloru Date: Mon, 9 Feb 2015 19:28:57 +0100 Subject: [PATCH 1/7] Bumping version little.. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index acf47c0..65b7ddd 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ base_path = os.path.dirname(__file__) -version = '0.0.4' +version = '0.0.5' # release a version, publish to GitHub and PyPI From 8dbb782a33b4c2d2882719978e074af0db6014f1 Mon Sep 17 00:00:00 2001 From: Visgean Skeloru Date: Thu, 12 Feb 2015 12:18:05 +0100 Subject: [PATCH 2/7] minor pep8 polishing --- fiobank.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/fiobank.py b/fiobank.py index cb06221..c1c02f8 100644 --- a/fiobank.py +++ b/fiobank.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- import re -from datetime import datetime, date - import requests +from datetime import datetime, date + __all__ = ('FioBank',) @@ -26,6 +26,14 @@ def sanitize_value(value, convert=None): return value +class ThrottlingError(Exception): + """ + Throttling error raised when api is being used too fast. + """ + def __str__(self): + return 'Token should be used only once per 30s.' + + class FioBank(object): base_url = 'https://www.fio.cz/ib_api/rest/' @@ -104,7 +112,7 @@ def _parse_info(self, data): def _parse_transactions(self, data): schema = self.transaction_schema try: - entries = data['accountStatement']['transactionList']['transaction'] + entries = data['accountStatement']['transactionList']['transaction'] # noqa except TypeError: entries = [] From b82e61d4e4be15155ab43101da8b951e7dc36896 Mon Sep 17 00:00:00 2001 From: Visgean Skeloru Date: Thu, 12 Feb 2015 12:18:26 +0100 Subject: [PATCH 3/7] gitignore Pycharm files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index abac1ee..abae00a 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,4 @@ nosetests.xml .project .pydevproject .env +.idea/ \ No newline at end of file From d5781431ace80a0e1b3c5da6522998c2ac2a6835 Mon Sep 17 00:00:00 2001 From: Visgean Skeloru Date: Thu, 12 Feb 2015 12:51:36 +0100 Subject: [PATCH 4/7] throttling error --- fiobank.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fiobank.py b/fiobank.py index c1c02f8..867a765 100644 --- a/fiobank.py +++ b/fiobank.py @@ -87,6 +87,9 @@ def _request(self, action, **params): url = template.format(token=self.token, **params) response = requests.get(url) + if response.status_code == requests.codes['conflict']: + raise ThrottlingError() + response.raise_for_status() if response.content: From 632b2e40428405efe85b88175d8c05133f263833 Mon Sep 17 00:00:00 2001 From: Visgean Skeloru Date: Thu, 12 Feb 2015 16:59:29 +0100 Subject: [PATCH 5/7] Throttling error in readme --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e1103ac..1c3e0b8 100644 --- a/README.md +++ b/README.md @@ -50,8 +50,11 @@ Listing latest transactions: >>> client.last(from_date='2013-03-01') # sets cursor to given date and returns following transactions ``` -For further information [read code](https://github.com/honzajavorek/fiobank/blob/master/fiobank.py). +## Conflict error +[Fio api documentation](http://www.fio.cz/docs/cz/API_Bankovnictvi.pdf) (Section 8.2) states that a single token should be used only once per 30s. Otherwise a HTTP conflict will be returned and `Fiobank.ThrottlingError` will be raised. + +For further information [read code](https://github.com/honzajavorek/fiobank/blob/master/fiobank.py). ## License: ISC From a2ab1b59c350bed00b23d49b035f100ece9189d7 Mon Sep 17 00:00:00 2001 From: Visgean Skeloru Date: Thu, 12 Feb 2015 17:13:20 +0100 Subject: [PATCH 6/7] ugly imports :( --- fiobank.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fiobank.py b/fiobank.py index 867a765..c03c891 100644 --- a/fiobank.py +++ b/fiobank.py @@ -1,9 +1,10 @@ # -*- coding: utf-8 -*- import re +from datetime import datetime, date + import requests -from datetime import datetime, date __all__ = ('FioBank',) From b1635baa5bfe1f4627da320d73a1d6d2404d0a10 Mon Sep 17 00:00:00 2001 From: Visgean Skeloru Date: Thu, 12 Feb 2015 17:14:47 +0100 Subject: [PATCH 7/7] api capitalized --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1c3e0b8..416b07a 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Listing latest transactions: ``` ## Conflict error -[Fio api documentation](http://www.fio.cz/docs/cz/API_Bankovnictvi.pdf) (Section 8.2) states that a single token should be used only once per 30s. Otherwise a HTTP conflict will be returned and `Fiobank.ThrottlingError` will be raised. +[Fio API documentation](http://www.fio.cz/docs/cz/API_Bankovnictvi.pdf) (Section 8.2) states that a single token should be used only once per 30s. Otherwise a HTTP conflict will be returned and `Fiobank.ThrottlingError` will be raised. For further information [read code](https://github.com/honzajavorek/fiobank/blob/master/fiobank.py).