BankingCircle.Cases.RFI (banking_circle v1.0.0)

Copy Markdown View Source

Convenience helpers for building the :answers list passed to BankingCircle.Cases.submit_rfi_answers/3.

Summary

Functions

Builds an answers list from a map of question_index => answer_or_attachment_ids.

Functions

build_answers(answers_by_index)

@spec build_answers(%{required(non_neg_integer()) => term()}) :: [map()]

Builds an answers list from a map of question_index => answer_or_attachment_ids.

A plain string/number value becomes a text answer; a {:attachments, [id, ...]} tuple becomes an attachment-question answer.

Example

RFI.build_answers(%{
  0 => "1994-06-01",
  1 => {:attachments, ["att_123", "att_456"]},
  2 => ""  # explicitly declining to answer question 2
})
#=> [
#     %{index: 0, answer: "1994-06-01", attachment_ids: []},
#     %{index: 1, answer: "", attachment_ids: ["att_123", "att_456"]},
#     %{index: 2, answer: "", attachment_ids: []}
#   ]