View Source Appwrite.Helpers.Client (appwrite v0.1.4)

Client module for handling requests to Appwrite.

Summary

Functions

Makes an HTTP call using the given method, URL, headers, and parameters.

Creates a new client instance with default configuration.

Prepares an HTTP request with the specified method, URL, headers, and parameters.

Sets the API endpoint.

Sets the JWT.

Sets the locale.

Sets the project ID.

Sets the session.

Types

@type headers() :: %{optional(String.t()) => String.t()}
@type method() :: String.t()
@type params() :: %{optional(String.t()) => any()}
@type response() :: {:ok, any()} | {:error, any()}
@type response_type() :: String.t()
@type t() :: %Appwrite.Helpers.Client{
  endpoint: String.t() | nil,
  endpoint_realtime: String.t() | nil,
  headers: %{required(String.t()) => String.t()},
  jwt: String.t() | nil,
  locale: String.t() | nil,
  project: String.t() | nil,
  session: String.t() | nil
}
@type url() :: String.t()

Functions

Link to this function

call(method, url, headers \\ %{}, params \\ %{}, response_type \\ "json")

View Source
@spec call(method(), url(), headers(), params(), response_type()) :: any()

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.
Link to this function

chunked_upload(method, url, headers \\ %{}, payload \\ %{}, on_progress \\ nil)

View Source
@spec chunked_upload(
  method(),
  url(),
  headers(),
  params(),
  (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.

Creates a new client instance with default configuration.

Link to this function

prepare_request(method, url, headers \\ %{}, params \\ %{})

View Source
@spec prepare_request(method(), url(), headers(), params()) :: {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.
Link to this function

set_endpoint(client, endpoint)

View Source

Sets the API endpoint.

Parameters

  • client: The current client instance.
  • endpoint: The API endpoint.

Returns

  • Updated client instance.
Link to this function

set_endpoint_realtime(client, endpoint_realtime)

View Source

Sets the realtime endpoint.

Parameters

  • client: The current client instance.
  • endpoint_realtime: The realtime endpoint.

Returns

  • Updated client instance.

Sets the JWT.

Parameters

  • client: The current client instance.
  • jwt: The JSON Web Token.

Returns

  • Updated client instance.
Link to this function

set_locale(client, locale)

View Source

Sets the locale.

Parameters

  • client: The current client instance.
  • locale: The locale string.

Returns

  • Updated client instance.
Link to this function

set_project(client, project)

View Source

Sets the project ID.

Parameters

  • client: The current client instance.
  • project: The project ID.

Returns

  • Updated client instance.
Link to this function

set_session(client, session)

View Source

Sets the session.

Parameters

  • client: The current client instance.
  • session: The session string.

Returns

  • Updated client instance.