Liking cljdoc? Tell your friends :D

stripe-clojure.http.util


flatten-paramsclj

(flatten-params params)

Recursively flattens a nested map into a single-level map with keys formatted in a way that matches Stripe API's expectations for form data.

Transformations performed:

  1. Kebab-case keys are converted to snake_case (e.g., :first-name → "first_name")
  2. Nested maps use bracket notation (e.g., {:customer {:name "Jane"}} → {"customer[name]" "Jane"})
  3. Arrays/collections use indexed brackets (e.g., {:items [{:price "x"}]} → {"items[0][price]" "x"})
  4. String values are preserved as-is (not treated as collections)

Parameters:

  • params: A nested map of parameters.

Returns: A flat map with formatted keys suitable for Stripe API requests.

Recursively flattens a nested map into a single-level map with keys formatted
in a way that matches Stripe API's expectations for form data.

Transformations performed:
1. Kebab-case keys are converted to snake_case (e.g., :first-name → "first_name")
2. Nested maps use bracket notation (e.g., {:customer {:name "Jane"}} → {"customer[name]" "Jane"})
3. Arrays/collections use indexed brackets (e.g., {:items [{:price "x"}]} → {"items[0][price]" "x"})
4. String values are preserved as-is (not treated as collections)

Parameters:
- params: A nested map of parameters.

Returns:
A flat map with formatted keys suitable for Stripe API requests.
sourceraw docstring

format-expandclj

(format-expand expand)

Converts an expand parameter into the indexed format required by Stripe's v1 API.

Examples: (format-expand "customer") => {"expand[0]" "customer"}

(format-expand ["customer", "invoice.subscription"]) => {"expand[0]" "customer", "expand[1]" "invoice.subscription"}

Converts an expand parameter into the indexed format required by Stripe's v1 API.

Examples:
(format-expand "customer")
=> {"expand[0]" "customer"}

(format-expand ["customer", "invoice.subscription"])
=> {"expand[0]" "customer", "expand[1]" "invoice.subscription"}
sourceraw docstring

format-indexed-paramsclj

(format-indexed-params prefix fields)

Converts a string or sequence of strings into indexed bracket notation.

Produces a map of {"prefix[0]" val0, "prefix[1]" val1, ...} suitable for Stripe API query parameters (expand, include, etc.).

Returns an empty map if the input is nil or empty.

Parameters:

  • prefix: The parameter name prefix (e.g., "expand", "include")
  • fields: Either a string or a sequence of strings.

Returns: A map with indexed bracket keys.

Converts a string or sequence of strings into indexed bracket notation.

Produces a map of {"prefix[0]" val0, "prefix[1]" val1, ...} suitable
for Stripe API query parameters (expand, include, etc.).

Returns an empty map if the input is nil or empty.

Parameters:
- prefix: The parameter name prefix (e.g., "expand", "include")
- fields: Either a string or a sequence of strings.

Returns:
A map with indexed bracket keys.
sourceraw docstring

kebab-to-snakeclj

(kebab-to-snake s)

Converts a string from kebab-case to snake_case.

Converts a string from kebab-case to snake_case.
sourceraw docstring

transform-keysclj

(transform-keys m)

Recursively transforms all keys in a map from underscore_case to kebab-case.

This function walks through the map (including nested maps and vectors) and converts each keyword key to kebab-case. It leverages transients for efficient accumulation on larger maps.

Parameters:

  • m: A map whose keys need to be transformed. If m is not a map, it's returned unchanged.

Returns: A new map with all keys converted to kebab-case.

Example: (transform-keys {:some_key {:nested_key "value"}}) => {:some-key {:nested-key "value"}}

Recursively transforms all keys in a map from underscore_case to kebab-case.

This function walks through the map (including nested maps and vectors)
and converts each keyword key to kebab-case. It leverages transients for
efficient accumulation on larger maps.

Parameters:
- m: A map whose keys need to be transformed. If `m` is not a map, it's returned unchanged.

Returns:
A new map with all keys converted to kebab-case.

Example:
(transform-keys {:some_key {:nested_key "value"}})
=> {:some-key {:nested-key "value"}}
sourceraw docstring

underscore-to-kebabclj

(underscore-to-kebab s)

Converts a string from underscore_case to kebab-case.

Examples:

  • "hello_mello" => "hello-mello"
  • "some_example_string" => "some-example-string"

Parameters:

  • s: A string in underscore_case.

Returns: A kebab-case version of the input string.

Converts a string from underscore_case to kebab-case.

Examples:
- "hello_mello" => "hello-mello"
- "some_example_string" => "some-example-string"

Parameters:
- s: A string in underscore_case.

Returns:
A kebab-case version of the input string.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close