View Source Appwrite.Utils.Client (appwrite v0.1.9)
Client module for handling requests to Appwrite.
Summary
Functions
Makes an HTTP call using the given method, URL, headers, and parameters.
Handles chunked uploads for large files.
Flattens a nested map or list into a single-level map with prefixed keys.
Prepares an HTTP request with the specified method, URL, headers, and parameters.
Sets the JWT.
Sets the locale.
Sets the Project.
Sets the session.
Types
Functions
@spec call( String.t(), String.t(), Appwrite.Types.Client.Headers.t(), Appwrite.Types.Client.Payload.t(), String.t() ) :: response()
Makes an HTTP call using the given method, URL, headers, and parameters.
Parameters
method
: HTTP method.url
: Target URL.headers
: Map of headers.params
: Parameters for the request.response_type
: Type of response expected (default:"json"
).
Returns
- Response data or raises an
AppwriteException
on error.
@spec chunked_upload( String.t(), String.t(), Appwrite.Types.Client.Headers.t(), Appwrite.Types.Client.Payload.t(), (Appwrite.Types.Client.UploadProgress.t() -> any()) ) :: any()
Handles chunked uploads for large files.
Parameters
method
: HTTP method (e.g., "POST").url
: Target URL.headers
: Map of headers.payload
: Original payload with file details.on_progress
: Function to call with progress updates.
Returns
- Response from the final chunk.
Flattens a nested map or list into a single-level map with prefixed keys.
Examples
iex> Client.flatten(%{"key1" => %{"key2" => "value"}}, "prefix")
%{"prefix[key1][key2]" => "value"}
iex> Client.flatten(%{"key1" => ["a", "b"]}, "prefix")
%{"prefix[key1][0]" => "a", "prefix[key1][1]" => "b"}
@spec prepare_request( String.t(), String.t(), Appwrite.Types.Client.Headers.t(), Appwrite.Types.Client.Payload.t() ) :: {String.t(), map()}
Prepares an HTTP request with the specified method, URL, headers, and parameters.
Parameters
method
: HTTP method as a string (e.g., "GET", "POST").url
: Base URL as a string.headers
: Map of headers (default:%{}
).params
: Map of query or body parameters (default:%{}
).
Returns
- Tuple containing the URI and options for the request.
Sets the JWT.
Parameters
jwt
: The JSON Web Token.
Returns
- Updated Header map.
@spec set_locale(String.t()) :: Appwrite.Types.Client.Headers.t()
@spec set_locale(String.t()) :: Appwrite.Types.Client.Headers.t()
Sets the locale.
Parameters
locale
: The locale string.
Returns
- Updated client instance.
@spec set_project(String.t()) :: Appwrite.Types.Client.Config.t()
Sets the Project.
Parameters
project
: The Project Name.
Returns
- Updated Config map.
@spec set_session(String.t()) :: Appwrite.Types.Client.Headers.t()
Sets the session.
Parameters
session
: The session string.
Returns
- Updated client instance.