(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:
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.
(format-expand expand)
Converts an expand parameter (either a single string or a sequence of strings) into the indexed format required by Stripe's API.
Transformations performed:
Examples:
Single field: (format-expand "customer") => {"expand[0]" "customer"}
Multiple fields: (format-expand ["customer", "invoice.subscription"]) => {"expand[0]" "customer", "expand[1]" "invoice.subscription"}
Empty input: (format-expand nil) => {}
Parameters:
Returns: A map with formatted expand parameters suitable for Stripe API requests.
Converts an expand parameter (either a single string or a sequence of strings) into the indexed format required by Stripe's API. Transformations performed: 1. Single string is wrapped in a vector first 2. Each value is assigned an indexed key: "expand[0]", "expand[1]", etc. 3. Returns an empty map if the input is nil or empty Examples: Single field: (format-expand "customer") => {"expand[0]" "customer"} Multiple fields: (format-expand ["customer", "invoice.subscription"]) => {"expand[0]" "customer", "expand[1]" "invoice.subscription"} Empty input: (format-expand nil) => {} Parameters: - expand: Either a string or a sequence of strings representing the fields to expand. Returns: A map with formatted expand parameters suitable for Stripe API requests.
(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
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"}}
(underscore-to-kebab s)
Converts a string from underscore_case to kebab-case.
Examples:
Parameters:
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.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close