From 28d8c7af3edb54c7887d4817dc158a91ed964644 Mon Sep 17 00:00:00 2001 From: "martin.novak" Date: Thu, 24 Oct 2019 12:15:15 +0200 Subject: [PATCH 1/4] Bank Accounts API --- fakturoid/api.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/fakturoid/api.py b/fakturoid/api.py index 9b7201d..55c4056 100644 --- a/fakturoid/api.py +++ b/fakturoid/api.py @@ -5,7 +5,7 @@ import requests -from fakturoid.models import Account, Subject, Invoice, Generator, Message +from fakturoid.models import Account, Subject, Invoice, Generator, Message, BankAccount from fakturoid.paging import ModelList __all__ = ['Fakturoid'] @@ -29,6 +29,7 @@ def __init__(self, slug, email, api_key, user_agent=None): self._models_api = { Account: AccountApi(self), + BankAccount: BankAccountsApi(self), Subject: SubjectsApi(self), Invoice: InvoicesApi(self), Generator: GeneratorsApi(self), @@ -63,6 +64,9 @@ def wrapper(self, *args, **kwargs): def account(self): return self._models_api[Account].load() + def bank_accounts(self): + return self._models_api[BankAccount].find() + @model_api(Subject) def subject(self, mapi, id): return mapi.load(id) @@ -213,6 +217,15 @@ def load(self): return self.unpack(response) +class BankAccountsApi(ModelApi): + model_type = BankAccount + endpoint = 'bank_accounts' + + def find(self, params={}, endpoint=None): + response = self.session._get(endpoint or self.endpoint, params=params) + return self.unpack(response) + + class SubjectsApi(CrudModelApi): model_type = Subject endpoint = 'subjects' From 3cc451d47bb33a5c3b89132b28e13d68ca5d40f4 Mon Sep 17 00:00:00 2001 From: "martin.novak" Date: Thu, 24 Oct 2019 12:49:00 +0200 Subject: [PATCH 2/4] Bank Account model --- fakturoid/models.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/fakturoid/models.py b/fakturoid/models.py index d5954ed..41e600b 100644 --- a/fakturoid/models.py +++ b/fakturoid/models.py @@ -72,6 +72,20 @@ def __repr__(self): return "<{0}:{1}>".format(self.__class__.__name__, self.name) +class BankAccount(Model): + """See http://docs.fakturoid.apiary.io/ for complete field reference.""" + name = None + + class Meta: + decimal = [] + + def __unicode__(self): + return self.name + + def __repr__(self): + return "<{0}:{1}>".format(self.__class__.__name__, self.name) + + class Subject(Model): """See http://docs.fakturoid.apiary.io/ for complete field reference.""" name = None From a4f16879e91168faa3c6b062e57bba3860bb0e86 Mon Sep 17 00:00:00 2001 From: "martin.novak" Date: Thu, 24 Oct 2019 12:50:49 +0200 Subject: [PATCH 3/4] BankAccount added to __all__ --- fakturoid/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fakturoid/models.py b/fakturoid/models.py index 41e600b..7e1da84 100644 --- a/fakturoid/models.py +++ b/fakturoid/models.py @@ -5,7 +5,7 @@ from fakturoid import six -__all__ = ['Account', 'Subject', 'InvoiceLine', 'Invoice', 'Generator', 'Message'] +__all__ = ['Account', 'BankAccount', 'Subject', 'InvoiceLine', 'Invoice', 'Generator', 'Message'] class Model(six.UnicodeMixin): From 28b67a699de16c6b4cf81acb98c9ebd200ce53d3 Mon Sep 17 00:00:00 2001 From: "martin.novak" Date: Thu, 24 Oct 2019 18:14:16 +0200 Subject: [PATCH 4/4] Readme update --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 7db96bf..cba64d6 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,10 @@ print(invoice.due_on) Returns `Account` instance. Account is readonly and can't be updated by API. +Fakturoid.bank_accounts() + +Returns list of `BankAccount` instances. Bank accounts are readonly and can't be updated by API. + Fakturoid.subject(id) Returns `Subject` instance. @@ -147,6 +151,10 @@ Values are mapped to corresponding `int`, `decimal.Decimal`, `datetime.date` and [http://docs.fakturoid.apiary.io/#reference/account](http://docs.fakturoid.apiary.io/#reference/account) +Fakturoid.BankAccount + +[http://docs.fakturoid.apiary.io/#reference/bank-accounts](http://docs.fakturoid.apiary.io/#reference/bank-accounts) + Fakturoid.Subject [http://docs.fakturoid.apiary.io/#reference/subjects](http://docs.fakturoid.apiary.io/#reference/subjects)