ExQuickbooks.Query (ex_quickbooks v0.9.0)

Copy Markdown View Source

Generic query helpers for QuickBooks Online.

The query helper accepts raw QuickBooks query statements and optionally appends STARTPOSITION / MAXRESULTS clauses for caller-driven pagination.

Summary

Functions

Runs a raw QuickBooks query statement.

Extracts the primary top-level collection from a QueryResponse payload.

Functions

run(client, statement, options \\ [])

@spec run(ExQuickbooks.Client.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, ExQuickbooks.Error.t()}

Runs a raw QuickBooks query statement.

When :start_position or :max_results are provided, the helper appends the matching STARTPOSITION and MAXRESULTS clauses unless the statement already includes them.

top_level_collection(query_response)

@spec top_level_collection(map()) ::
  {:ok, {String.t(), list()}} | {:error, ExQuickbooks.Error.t()}

Extracts the primary top-level collection from a QueryResponse payload.

Examples

iex> ExQuickbooks.Query.top_level_collection(%{
...>   "Customer" => [%{"Id" => "123"}],
...>   "startPosition" => 1,
...>   "maxResults" => 1
...> })
{:ok, {"Customer", [%{"Id" => "123"}]}}