BankingCircle.HTTP.Middleware.Idempotency (banking_circle v1.0.0)

Copy Markdown View Source

Attaches an Idempotency-Key header to a request, either from a caller supplied value or a generated UUIDv4.

As of this writing, Banking Circle documents idempotency-key support specifically for Direct Debit Collections endpoints, with a note that other payment operations are planned to align with the same pattern later. Attaching the header on unsupported endpoints is harmless (it will simply be ignored), but callers should not rely on idempotency protection outside the documented scope — check BankingCircle.Payments function docs for per-endpoint guidance before assuming a blind retry is safe.

A replayed key returns HTTP 400 with a body identifying the original acceptance; BankingCircle.Error.parse/2 normalizes that like any other error.

Summary

Functions

Generates a UUIDv4 suitable for use as an idempotency key.

Functions

attach(request, key \\ nil)

@spec attach(Req.Request.t(), String.t() | nil) :: Req.Request.t()

generate_key()

@spec generate_key() :: String.t()

Generates a UUIDv4 suitable for use as an idempotency key.