ExQuickBooks.CDC (ex_quickbooks v0.9.0)

Copy Markdown View Source

Change Data Capture helpers for incremental QuickBooks synchronization.

CDC responses are returned as grouped per-entity maps so callers can process changed records and deleted IDs without re-parsing the raw QuickBooks payload.

Summary

Functions

Fetches grouped CDC changes since the given checkpoint.

Groups a CDC response by entity name and preserves deleted IDs per entity.

Returns the currently supported CDC entity names.

Types

entity_group()

@type entity_group() :: %{records: [map()], deleted_ids: [map()]}

grouped_changes()

@type grouped_changes() :: %{optional(String.t()) => entity_group()}

Functions

fetch(client, entity_names, changed_since, options \\ [])

@spec fetch(
  ExQuickBooks.Client.t(),
  [String.t() | atom()] | String.t() | atom(),
  String.t() | DateTime.t(),
  keyword()
) :: {:ok, grouped_changes()} | {:error, ExQuickBooks.Error.t()}

Fetches grouped CDC changes since the given checkpoint.

group_changes(cdc_response)

@spec group_changes([map()] | map()) ::
  {:ok, grouped_changes()} | {:error, ExQuickBooks.Error.t()}

Groups a CDC response by entity name and preserves deleted IDs per entity.

Examples

iex> ExQuickBooks.CDC.group_changes(%{
...>   "CDCResponse" => [
...>     %{
...>       "Customer" => [%{"Id" => "123"}],
...>       "DeletedId" => [%{"Type" => "Customer", "Id" => "456"}]
...>     }
...>   ]
...> })
{:ok,
 %{
   "Customer" => %{
     records: [%{"Id" => "123"}],
     deleted_ids: [%{"Type" => "Customer", "Id" => "456"}]
   }
 }}

supported_entity_names()

@spec supported_entity_names() :: [String.t()]

Returns the currently supported CDC entity names.

Examples

iex> "Customer" in ExQuickBooks.CDC.supported_entity_names()
true