Polyjuice Client v0.3.1 Polyjuice.Client.LowLevel View Source

A lower-level client than Polyjuice.Client.

Compared to Polyjuice.Client, this module:

  • does not manage the access token, user ID, or device ID; whenever these change (e.g. after logging in), the application must create a new client to use the new values
  • does not provide a process for syncing with the server
  • does not ensure that room requests (such as sending messages) are run in a queue
  • does not start any processes

This module would be suitable, for example, for a bot that only sends messages and does not respond to messages.

Link to this section Summary

Link to this section Types

Link to this type

t()

View Source
t() :: %Polyjuice.Client.LowLevel{
  access_token: String.t(),
  base_url: String.t(),
  device_id: String.t(),
  storage: Polyjuice.Client.Storage.t(),
  test: boolean(),
  user_id: String.t()
}

Link to this section Functions

Link to this function

create(base_url, opts \\ [])

View Source
create(base_url :: String.t(), opts :: Keyword.t()) :: t()

Create a client.

opts may contain:

  • access_token: (required to make calls that require authorization) the access token to use.
  • user_id: (required by some endpoints) the ID of the user
  • device_id: the device ID
  • storage: (required by sync) the storage backend to use (see Polyjuice.Client.Storage)
Link to this function

log_in_with_password(client, identifier, password, opts \\ [])

View Source
log_in_with_password(
  client :: Polyjuice.Client.LowLevel.t(),
  identifier :: String.t() | tuple() | map(),
  password :: String.t(),
  opts :: list()
) :: {:ok, map()} | any()

Log in with a password.

identifier may be a single string (in which case it represents a username -- either just the localpart or the full MXID), a tuple of the form {:email, "email@address"}, a tuple of the form {:phone, "country_code", "phone_number"}, or a map that is passed directly to the login endpoint.

opts is a keyword list of options:

  • device_id: (string) the device ID to use
  • initial_device_display_name: (string) the display name to use for the device
Link to this function

log_out(client)

View Source
log_out(client :: Polyjuice.Client.LowLevel.t()) :: :ok | any()

Log out an existing session.