Manage expense sync sessions.
The Expenses API works via a sync session model:
initialize/3— create a sync to hold transactions- Push expense transactions to the sync
complete/3— finalize and write transactions to the accounting platform- Receive
expenses.sync.successfulorexpenses.sync.failedwebhook
Example
# 1. Start a sync
{:ok, sync} = Codat.Expenses.Sync.initialize(client, company_id, %{
dataType: "expense"
})
sync_id = sync["id"]
# 2. Push transactions into the sync
{:ok, _} = Codat.Expenses.Transactions.create(client, company_id, sync_id, [%{...}])
# 3. Complete the sync to write to the accounting platform
{:ok, _} = Codat.Expenses.Sync.complete(client, company_id, sync_id)
Summary
Functions
Completes (finalizes) an expense sync, triggering the write to the accounting platform.
Returns a single sync by ID.
Returns the list of transaction updates from a sync.
Initializes a new expense sync session.
Lists all expense syncs for a company.
Functions
@spec complete(Codat.Client.t() | String.t(), String.t(), String.t() | keyword()) :: {:ok, map()} | {:error, Codat.Error.t()}
Completes (finalizes) an expense sync, triggering the write to the accounting platform.
Example
{:ok, _} = Codat.Expenses.Sync.complete(client, company_id, sync_id)
@spec get(Codat.Client.t() | String.t(), String.t(), String.t() | keyword()) :: {:ok, map()} | {:error, Codat.Error.t()}
Returns a single sync by ID.
@spec get_transaction_updates( Codat.Client.t() | String.t(), String.t(), String.t() | keyword() ) :: {:ok, map()} | {:error, Codat.Error.t()}
Returns the list of transaction updates from a sync.
@spec initialize(Codat.Client.t() | String.t(), String.t() | map(), map() | keyword()) :: {:ok, map()} | {:error, Codat.Error.t()}
Initializes a new expense sync session.
Example
{:ok, sync} = Codat.Expenses.Sync.initialize(client, company_id, %{
dataType: "expense"
})
@spec list(Codat.Client.t() | String.t(), String.t() | keyword(), keyword()) :: {:ok, Codat.Pagination.t()} | {:error, Codat.Error.t()}
Lists all expense syncs for a company.