finautapi package

Module contents

Subpackages

Submodules

finautapi.admin module

finautapi.apps module

class finautapi.apps.Finautapi(app_name, app_module)

Bases: AppConfig

name = 'finautapi'
ready()

Override this method in subclasses to run code when Django starts.

verbose_name = 'Finautapi'

finautapi.decorators module

finautapi decorators

finautapi.decorators.finaut_token_user(fn)

Fetch user from oauth application and attach it to token.

finautapi.finautapi_middleware module

finautapi.models module

finautapi.permissions module

class finautapi.permissions.CanViewCompany

Bases: BasePermission

Can the client view the given company?

has_object_permission(request, view, obj)

Return True if permission is granted, False otherwise.

finautapi.signals module

finautapi.urls module

finautapi.views module

finautapi.webhooks module

Asynchronous delivery of finautapi webhooks.

WebHook.process_data (models.py) decides which webhooks a saved record should reach and serializes the payload inside the request. The HTTP POST itself is handed to the dkdramatiq worker through schedule_delivery(), so a slow customer endpoint never holds a gunicorn worker – or the transaction the signal runs in – hostage.

deliver_webhook() is the function the worker imports by dotted name (see dkdramatiq.models.Job.process), so it must stay importable on its own and take JSON-serializable arguments only.

finautapi.webhooks.DELIVER_FN = 'finautapi.webhooks.deliver_webhook'

dotted path the dkdramatiq worker imports

finautapi.webhooks.WEBHOOK_TIMEOUT = 10

seconds to wait for the customer endpoint

finautapi.webhooks.deliver_webhook(webhook_id, json_data, headers, correlation_id)

POST json_data to the webhook’s target and record a WebHookLog.

Runs in the dkdramatiq worker, or inline as a fallback. Errors end up in the log row, they are never raised.

finautapi.webhooks.schedule_delivery(webhook, json_data, headers, correlation_id)

Queue deliver_webhook() to run once the current transaction has committed.

Signal handlers run inside the saving transaction; queueing on commit means a rolled-back save never produces a webhook, and the customer is never told about a record that does not exist.

Falls back to inline delivery when the queue is unavailable (or when settings.WEBHOOK_SYNC_DELIVERY is set), so a broker outage degrades to the old synchronous behaviour instead of dropping the webhook.