BankingCircle.Schemas.BulkPayment (banking_circle v1.0.0)

Copy Markdown View Source

Validates a batch of payment rows destined for POST /payments/bulks and renders them into the CSV format that endpoint expects.

Each row is validated with BankingCircle.Schemas.Payment.changeset/1. Per Banking Circle's documented bulk error shape, a failing row is reported by its 1-based elementIndex, which skips blank linesbuild/1 preserves row ordering (including any caller-supplied blank separators) so that index maps back correctly if the API rejects part of a batch.

Summary

Functions

Validates every row and, if all are valid, returns {:ok, csv_binary}.

Functions

build(rows)

@spec build([map()]) ::
  {:ok, binary()} | {:error, [{pos_integer(), Ecto.Changeset.t()}]}

Validates every row and, if all are valid, returns {:ok, csv_binary}.

If any row fails validation, returns {:error, [{index, changeset}, ...]} with 1-based indices matching Banking Circle's elementIndex semantics, so client-side and server-side validation errors are reportable the same way.