BilldogEng.Surveys (BilldogEng v1.0.0-beta.1)

Copy Markdown View Source

Surveys DATA API (no UI rendering). Wraps the bdsurvey-* edge functions.

Lifecycle: listfetchstartrecord_partial* → submit (or abandon). The same :idempotency_key SHOULD be carried across start and submit so retries are safe.

Answer shape: %{question_id: ..., choice_id?: ..., answer_text?: ..., answer_number?: ..., answer_json?: ...} (string or atom keys accepted).

Mirrors the Node SDK surveys.ts. Each function takes a %BilldogEng{} client and returns {:ok, result} or {:error, %BilldogEng.Error{}}.

Summary

Functions

Mark an in-progress response as abandoned.

Fetch the full configuration for a single survey.

List active surveys eligible for the (optionally identified) user.

Progressively persist a partial set of answers under an in-progress respondent.

Begin a survey response. Returns {:ok, %{"respondent_id" => ...}}.

Submit the final answers, completing the response.

Types

client()

@type client() :: BilldogEng.t()

result()

@type result() :: {:ok, term()} | {:error, BilldogEng.Error.t()}

Functions

abandon(client, survey_id, respondent_id)

@spec abandon(client(), String.t(), String.t()) :: result()

Mark an in-progress response as abandoned.

fetch(client, survey_id, opts \\ [])

@spec fetch(client(), String.t(), keyword()) :: result()

Fetch the full configuration for a single survey.

list(client, opts \\ [])

@spec list(
  client(),
  keyword()
) :: {:ok, [map()]} | {:error, BilldogEng.Error.t()}

List active surveys eligible for the (optionally identified) user.

record_partial(client, survey_id, respondent_id, answers, context \\ [])

@spec record_partial(client(), String.t(), String.t(), [map()], keyword()) :: result()

Progressively persist a partial set of answers under an in-progress respondent.

start(client, survey_id, context \\ [])

@spec start(client(), String.t(), keyword()) :: result()

Begin a survey response. Returns {:ok, %{"respondent_id" => ...}}.

submit(client, survey_id, answers, context \\ [])

@spec submit(client(), String.t(), [map()], keyword()) :: result()

Submit the final answers, completing the response.