Appwrite. Utils. Client
(appwrite v1.0.0)
View Source
HTTP client for the Appwrite SDK.
Handles request preparation, authentication headers, chunked file uploads, and response normalisation for all Appwrite service calls.
Summary
Functions
Makes a synchronous HTTP call and returns the decoded response.
Uploads a file, splitting into 5 MB chunks when the file exceeds the limit.
Returns the resolved runtime configuration map.
Flattens a nested map or list into a single-level map with bracket-notation
keys, suitable for URI.encode_query/1.
Builds the final URI string and HTTPoison options map for a request.
Returns headers with the JWT token set.
Returns headers with the locale set.
Updates the project ID in the configuration.
Returns headers with the session token set.
Functions
@spec call( String.t(), String.t(), Appwrite.Types.Client.Headers.t(), Appwrite.Types.Client.Payload.t(), String.t() ) :: map() | nil | binary()
Makes a synchronous HTTP call and returns the decoded response.
Raises AppwriteException on network or server errors.
Parameters
method— HTTP verb (e.g."get","POST").api_path— Path relative to the configured endpoint.headers— Extra headers merged on top of defaults.params— Query params (GET) or body params (other methods).response_type—"json"(default),"arrayBuffer", or other.
@spec chunked_upload( String.t(), String.t(), Appwrite.Types.Client.Headers.t(), Appwrite.Types.Client.Payload.t(), (Appwrite.Types.Client.UploadProgress.t() -> any()) | nil ) :: map() | nil | binary()
Uploads a file, splitting into 5 MB chunks when the file exceeds the limit.
The payload["file"] value must be a map with:
"data"— base64-encoded binary"name"— filename string"type"— MIME type string"size"— byte length integer
@spec default_config() :: Appwrite.Types.Client.Config.t()
Returns the resolved runtime configuration map.
Flattens a nested map or list into a single-level map with bracket-notation
keys, suitable for URI.encode_query/1.
Examples
iex> Appwrite.Utils.Client.flatten(%{"a" => %{"b" => "v"}})
%{"a[b]" => "v"}
iex> Appwrite.Utils.Client.flatten(%{"list" => ["x", "y"]})
%{"list[0]" => "x", "list[1]" => "y"}
@spec prepare_request( String.t(), String.t(), Appwrite.Types.Client.Headers.t(), Appwrite.Types.Client.Payload.t() ) :: {String.t(), map()}
Builds the final URI string and HTTPoison options map for a request.
For GET requests all params are encoded into the query string.
For other methods the body is JSON- or multipart-encoded depending on
the content-type header.
@spec set_jwt(String.t()) :: Appwrite.Types.Client.Headers.t()
Returns headers with the JWT token set.
@spec set_locale(String.t()) :: Appwrite.Types.Client.Headers.t()
Returns headers with the locale set.
@spec set_project(String.t()) :: Appwrite.Types.Client.Config.t()
Updates the project ID in the configuration.
@spec set_session(String.t()) :: Appwrite.Types.Client.Headers.t()
Returns headers with the session token set.