Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ print(invoice.due_on)

Returns `Account` instance. Account is readonly and can't be updated by API.

<code>Fakturoid.<b>bank_accounts()</b></code>

Returns list of `BankAccount` instances. Bank accounts are readonly and can't be updated by API.

<code>Fakturoid.<b>subject(id)</b></code>

Returns `Subject` instance.
Expand Down Expand Up @@ -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)

<code>Fakturoid.<b>BankAccount</b></code>

[http://docs.fakturoid.apiary.io/#reference/bank-accounts](http://docs.fakturoid.apiary.io/#reference/bank-accounts)

<code>Fakturoid.<b>Subject</b></code>

[http://docs.fakturoid.apiary.io/#reference/subjects](http://docs.fakturoid.apiary.io/#reference/subjects)
Expand Down
15 changes: 14 additions & 1 deletion fakturoid/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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),
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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'
Expand Down
16 changes: 15 additions & 1 deletion fakturoid/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down