Behaviour for implementing typed Codat webhook event handlers.
Example
defmodule MyApp.CodatWebhookHandler do
use Codat.Webhooks.Handler
@impl true
def handle_event("invoices.write.successful", payload, _metadata) do
MyApp.InvoiceSync.handle_success(payload["companyId"], payload["data"])
:ok
end
@impl true
def handle_event(_event_type, _payload, _metadata), do: :ok
endReturn Values
:ok— processed; Plug responds200 OK{:error, reason}— app error; Plug logs and responds200 OK{:retry, reason}— Plug responds500to trigger Codat retry
Summary
Types
Callbacks
@callback handle_event(event_type(), payload(), metadata()) :: result()
@callback on_exception(event_type(), payload(), Exception.t(), list()) :: :ok