Boldsign.Multipart (Boldsign v0.10.0)

Copy Markdown View Source

Converts a params map into a raw multipart/form-data binary.

BoldSign's multipart API uses bracket notation for nested objects:

  • signers[0][name] = "Neil"
  • signers[0][formFields][0][bounds][x] = "50"

Recursively flattens arbitrarily nested maps and lists. Use encode_raw/1 to build the request body and content-type header directly, avoiding String.to_atom/1 on dynamic bracket-notation field names.

Summary

Functions

Splits files from params and returns {file_parts, field_parts}.

Encodes params as a raw multipart/form-data binary.

Flattens a map into form field tuples with recursive bracket notation.

Functions

encode(params)

Splits files from params and returns {file_parts, field_parts}.

encode_raw(params)

Encodes params as a raw multipart/form-data binary.

Returns {body, content_type} where body is the encoded binary and content_type is "multipart/form-data; boundary=BOUNDARY".

Use with Req's :body option and set the content-type header manually:

{body, content_type} = Boldsign.Multipart.encode_raw(params)
Req.post!(client, url: "/some/endpoint", body: body, headers: [{"content-type", content_type}])

flatten(params)

Flattens a map into form field tuples with recursive bracket notation.