View Source Appwrite.Utils.Service (appwrite v0.1.9)
A service utility module for operations like chunked uploads and payload flattening.
Summary
Functions
Returns the size for chunked uploads in bytes.
Validates that the given data is not nil.
Flattens a nested map or list structure into a key-value map with prefixed keys.
Functions
@spec chunk_size() :: non_neg_integer()
Returns the size for chunked uploads in bytes.
Examples
iex> Appwrite.Service.chunk_size()
5242880
Validates that the given data is not nil.
Parameters
data(any): The data to check.
Returns
- The data itself if it is valid.
Raises
ArgumentErrorif the data isnil.
Examples
iex> Appwrite.Service.ensure_not_nil(%{})
%{}
iex> Appwrite.Service.ensure_not_nil(nil)
** (ArgumentError) Input cannot be nil
@spec flatten(Appwrite.Types.Client.Payload.t(), String.t()) :: Appwrite.Types.Client.Payload.t()
Flattens a nested map or list structure into a key-value map with prefixed keys.
Parameters
data(Payload.t): The nested map or list to flatten.prefix(String.t): The prefix for keys (default:"").
Returns
- A flattened map with keys prefixed appropriately.
Examples
iex> Appwrite.Service.flatten(%{"key1" => %{"key2" => "value"}}, "prefix")
%{"prefix[key1][key2]" => "value"}
iex> Appwrite.Service.flatten(%{"key1" => ["value1", "value2"]})
%{"key1[0]" => "value1", "key1[1]" => "value2"}